diff --git a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/CHANGELOG.md b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/CHANGELOG.md index 441cba8f41d4..fc83cb3abcb1 100644 --- a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/CHANGELOG.md +++ b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/marketplaceordering/armmarketplaceordering` 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/marketplaceordering/armmarketplaceordering/README.md b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/README.md index d7f069d4850f..a97eb2615b92 100644 --- a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/README.md +++ b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Marketplace Ordering modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Marketplace Ordering module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armmarketplaceordering.NewMarketplaceAgreementsClient(, cred, nil) +clientFactory, err := armmarketplaceordering.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armmarketplaceordering.NewMarketplaceAgreementsClient(, cred, &options) +clientFactory, err := armmarketplaceordering.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewMarketplaceAgreementsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/autorest.md b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/autorest.md index 583c60ec596f..8e72c2721dd6 100644 --- a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/autorest.md +++ b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/marketplaceordering/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/marketplaceordering/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/client_factory.go b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/client_factory.go new file mode 100644 index 000000000000..e8aaa1ac1b69 --- /dev/null +++ b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/client_factory.go @@ -0,0 +1,49 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armmarketplaceordering + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The subscription ID that identifies an Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewMarketplaceAgreementsClient() *MarketplaceAgreementsClient { + subClient, _ := NewMarketplaceAgreementsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_constants.go b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/constants.go similarity index 96% rename from sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_constants.go rename to sdk/resourcemanager/marketplaceordering/armmarketplaceordering/constants.go index 659242c1c225..dc31f3bdd084 100644 --- a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_constants.go +++ b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/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 armmarketplaceordering const ( moduleName = "armmarketplaceordering" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/go.mod b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/go.mod index eeff1b40bcdd..1f7c1f7d10ea 100644 --- a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/go.mod +++ b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/marketplaceordering go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) 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/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/go.sum b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/go.sum +++ b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= 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/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_marketplaceagreements_client.go b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/marketplaceagreements_client.go similarity index 84% rename from sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_marketplaceagreements_client.go rename to sdk/resourcemanager/marketplaceordering/armmarketplaceordering/marketplaceagreements_client.go index e2cb375fdc28..e7b0737a42eb 100644 --- a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_marketplaceagreements_client.go +++ b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/marketplaceagreements_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 armmarketplaceordering @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,49 +24,41 @@ import ( // MarketplaceAgreementsClient contains the methods for the MarketplaceAgreements group. // Don't use this type directly, use NewMarketplaceAgreementsClient() instead. type MarketplaceAgreementsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewMarketplaceAgreementsClient creates a new instance of MarketplaceAgreementsClient with the specified values. -// subscriptionID - The subscription ID that identifies an Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID that identifies an Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewMarketplaceAgreementsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MarketplaceAgreementsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".MarketplaceAgreementsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &MarketplaceAgreementsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Cancel - Cancel marketplace terms. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-01-01 -// publisherID - Publisher identifier string of image being deployed. -// offerID - Offer identifier string of image being deployed. -// planID - Plan identifier string of image being deployed. -// options - MarketplaceAgreementsClientCancelOptions contains the optional parameters for the MarketplaceAgreementsClient.Cancel -// method. +// - publisherID - Publisher identifier string of image being deployed. +// - offerID - Offer identifier string of image being deployed. +// - planID - Plan identifier string of image being deployed. +// - options - MarketplaceAgreementsClientCancelOptions contains the optional parameters for the MarketplaceAgreementsClient.Cancel +// method. func (client *MarketplaceAgreementsClient) Cancel(ctx context.Context, publisherID string, offerID string, planID string, options *MarketplaceAgreementsClientCancelOptions) (MarketplaceAgreementsClientCancelResponse, error) { req, err := client.cancelCreateRequest(ctx, publisherID, offerID, planID, options) if err != nil { return MarketplaceAgreementsClientCancelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MarketplaceAgreementsClientCancelResponse{}, err } @@ -96,7 +87,7 @@ func (client *MarketplaceAgreementsClient) cancelCreateRequest(ctx context.Conte return nil, errors.New("parameter planID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{planId}", url.PathEscape(planID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -118,20 +109,21 @@ func (client *MarketplaceAgreementsClient) cancelHandleResponse(resp *http.Respo // Create - Save marketplace terms. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-01-01 -// offerType - Offer Type, currently only virtualmachine type is supported. -// publisherID - Publisher identifier string of image being deployed. -// offerID - Offer identifier string of image being deployed. -// planID - Plan identifier string of image being deployed. -// parameters - Parameters supplied to the Create Marketplace Terms operation. -// options - MarketplaceAgreementsClientCreateOptions contains the optional parameters for the MarketplaceAgreementsClient.Create -// method. +// - offerType - Offer Type, currently only virtualmachine type is supported. +// - publisherID - Publisher identifier string of image being deployed. +// - offerID - Offer identifier string of image being deployed. +// - planID - Plan identifier string of image being deployed. +// - parameters - Parameters supplied to the Create Marketplace Terms operation. +// - options - MarketplaceAgreementsClientCreateOptions contains the optional parameters for the MarketplaceAgreementsClient.Create +// method. func (client *MarketplaceAgreementsClient) Create(ctx context.Context, offerType OfferType, publisherID string, offerID string, planID string, parameters AgreementTerms, options *MarketplaceAgreementsClientCreateOptions) (MarketplaceAgreementsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, offerType, publisherID, offerID, planID, parameters, options) if err != nil { return MarketplaceAgreementsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MarketplaceAgreementsClientCreateResponse{}, err } @@ -164,7 +156,7 @@ func (client *MarketplaceAgreementsClient) createCreateRequest(ctx context.Conte return nil, errors.New("parameter planID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{planId}", url.PathEscape(planID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -186,19 +178,20 @@ func (client *MarketplaceAgreementsClient) createHandleResponse(resp *http.Respo // Get - Get marketplace terms. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-01-01 -// offerType - Offer Type, currently only virtualmachine type is supported. -// publisherID - Publisher identifier string of image being deployed. -// offerID - Offer identifier string of image being deployed. -// planID - Plan identifier string of image being deployed. -// options - MarketplaceAgreementsClientGetOptions contains the optional parameters for the MarketplaceAgreementsClient.Get -// method. +// - offerType - Offer Type, currently only virtualmachine type is supported. +// - publisherID - Publisher identifier string of image being deployed. +// - offerID - Offer identifier string of image being deployed. +// - planID - Plan identifier string of image being deployed. +// - options - MarketplaceAgreementsClientGetOptions contains the optional parameters for the MarketplaceAgreementsClient.Get +// method. func (client *MarketplaceAgreementsClient) Get(ctx context.Context, offerType OfferType, publisherID string, offerID string, planID string, options *MarketplaceAgreementsClientGetOptions) (MarketplaceAgreementsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, offerType, publisherID, offerID, planID, options) if err != nil { return MarketplaceAgreementsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MarketplaceAgreementsClientGetResponse{}, err } @@ -231,7 +224,7 @@ func (client *MarketplaceAgreementsClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter planID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{planId}", url.PathEscape(planID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -253,18 +246,19 @@ func (client *MarketplaceAgreementsClient) getHandleResponse(resp *http.Response // GetAgreement - Get marketplace agreement. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-01-01 -// publisherID - Publisher identifier string of image being deployed. -// offerID - Offer identifier string of image being deployed. -// planID - Plan identifier string of image being deployed. -// options - MarketplaceAgreementsClientGetAgreementOptions contains the optional parameters for the MarketplaceAgreementsClient.GetAgreement -// method. +// - publisherID - Publisher identifier string of image being deployed. +// - offerID - Offer identifier string of image being deployed. +// - planID - Plan identifier string of image being deployed. +// - options - MarketplaceAgreementsClientGetAgreementOptions contains the optional parameters for the MarketplaceAgreementsClient.GetAgreement +// method. func (client *MarketplaceAgreementsClient) GetAgreement(ctx context.Context, publisherID string, offerID string, planID string, options *MarketplaceAgreementsClientGetAgreementOptions) (MarketplaceAgreementsClientGetAgreementResponse, error) { req, err := client.getAgreementCreateRequest(ctx, publisherID, offerID, planID, options) if err != nil { return MarketplaceAgreementsClientGetAgreementResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MarketplaceAgreementsClientGetAgreementResponse{}, err } @@ -293,7 +287,7 @@ func (client *MarketplaceAgreementsClient) getAgreementCreateRequest(ctx context return nil, errors.New("parameter planID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{planId}", url.PathEscape(planID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -315,15 +309,16 @@ func (client *MarketplaceAgreementsClient) getAgreementHandleResponse(resp *http // List - List marketplace agreements in the subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-01-01 -// options - MarketplaceAgreementsClientListOptions contains the optional parameters for the MarketplaceAgreementsClient.List -// method. +// - options - MarketplaceAgreementsClientListOptions contains the optional parameters for the MarketplaceAgreementsClient.List +// method. func (client *MarketplaceAgreementsClient) List(ctx context.Context, options *MarketplaceAgreementsClientListOptions) (MarketplaceAgreementsClientListResponse, error) { req, err := client.listCreateRequest(ctx, options) if err != nil { return MarketplaceAgreementsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MarketplaceAgreementsClientListResponse{}, err } @@ -340,7 +335,7 @@ func (client *MarketplaceAgreementsClient) listCreateRequest(ctx context.Context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -362,18 +357,19 @@ func (client *MarketplaceAgreementsClient) listHandleResponse(resp *http.Respons // Sign - Sign marketplace terms. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-01-01 -// publisherID - Publisher identifier string of image being deployed. -// offerID - Offer identifier string of image being deployed. -// planID - Plan identifier string of image being deployed. -// options - MarketplaceAgreementsClientSignOptions contains the optional parameters for the MarketplaceAgreementsClient.Sign -// method. +// - publisherID - Publisher identifier string of image being deployed. +// - offerID - Offer identifier string of image being deployed. +// - planID - Plan identifier string of image being deployed. +// - options - MarketplaceAgreementsClientSignOptions contains the optional parameters for the MarketplaceAgreementsClient.Sign +// method. func (client *MarketplaceAgreementsClient) Sign(ctx context.Context, publisherID string, offerID string, planID string, options *MarketplaceAgreementsClientSignOptions) (MarketplaceAgreementsClientSignResponse, error) { req, err := client.signCreateRequest(ctx, publisherID, offerID, planID, options) if err != nil { return MarketplaceAgreementsClientSignResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MarketplaceAgreementsClientSignResponse{}, err } @@ -402,7 +398,7 @@ func (client *MarketplaceAgreementsClient) signCreateRequest(ctx context.Context return nil, errors.New("parameter planID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{planId}", url.PathEscape(planID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/marketplaceagreements_client_example_test.go b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/marketplaceagreements_client_example_test.go new file mode 100644 index 000000000000..87c470176150 --- /dev/null +++ b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/marketplaceagreements_client_example_test.go @@ -0,0 +1,250 @@ +//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 armmarketplaceordering_test + +import ( + "context" + "log" + + "time" + + "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/marketplaceordering/armmarketplaceordering" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/GetMarketplaceTerms.json +func ExampleMarketplaceAgreementsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmarketplaceordering.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMarketplaceAgreementsClient().Get(ctx, armmarketplaceordering.OfferTypeVirtualmachine, "pubid", "offid", "planid", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AgreementTerms = armmarketplaceordering.AgreementTerms{ + // Name: to.Ptr("planid"), + // Type: to.Ptr("Microsoft.MarketplaceOrdering/offertypes"), + // ID: to.Ptr("id"), + // Properties: &armmarketplaceordering.AgreementProperties{ + // Accepted: to.Ptr(true), + // LicenseTextLink: to.Ptr("test.licenseLink"), + // MarketplaceTermsLink: to.Ptr("test.marketplaceTermsLink"), + // Plan: to.Ptr("planid"), + // PrivacyPolicyLink: to.Ptr("test.privacyPolicyLink"), + // Product: to.Ptr("offid"), + // Publisher: to.Ptr("pubid"), + // RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-15T11:33:07.12132Z"); return t}()), + // Signature: to.Ptr("ASDFSDAFWEFASDGWERLWER"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/SetMarketplaceTerms.json +func ExampleMarketplaceAgreementsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmarketplaceordering.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMarketplaceAgreementsClient().Create(ctx, armmarketplaceordering.OfferTypeVirtualmachine, "pubid", "offid", "planid", armmarketplaceordering.AgreementTerms{ + Properties: &armmarketplaceordering.AgreementProperties{ + Accepted: to.Ptr(false), + LicenseTextLink: to.Ptr("test.licenseLink"), + MarketplaceTermsLink: to.Ptr("test.marketplaceTermsLink"), + Plan: to.Ptr("planid"), + PrivacyPolicyLink: to.Ptr("test.privacyPolicyLink"), + Product: to.Ptr("offid"), + Publisher: to.Ptr("pubid"), + RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-15T11:33:07.12132Z"); return t }()), + Signature: to.Ptr("ASDFSDAFWEFASDGWERLWER"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AgreementTerms = armmarketplaceordering.AgreementTerms{ + // Name: to.Ptr("planid"), + // Type: to.Ptr("Microsoft.MarketplaceOrdering/offertypes"), + // ID: to.Ptr("id"), + // Properties: &armmarketplaceordering.AgreementProperties{ + // Accepted: to.Ptr(true), + // LicenseTextLink: to.Ptr("test.licenseLink"), + // MarketplaceTermsLink: to.Ptr("test.marketplaceTermsLink"), + // Plan: to.Ptr("planid"), + // PrivacyPolicyLink: to.Ptr("test.privacyPolicyLink"), + // Product: to.Ptr("offid"), + // Publisher: to.Ptr("pubid"), + // RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-15T11:33:07.12132Z"); return t}()), + // Signature: to.Ptr("ASDFSDAFWEFASDGWERLWER"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/SignMarketplaceTerms.json +func ExampleMarketplaceAgreementsClient_Sign() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmarketplaceordering.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMarketplaceAgreementsClient().Sign(ctx, "pubid", "offid", "planid", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AgreementTerms = armmarketplaceordering.AgreementTerms{ + // Name: to.Ptr("planid"), + // Type: to.Ptr("Microsoft.MarketplaceOrdering/offertypes"), + // ID: to.Ptr("id"), + // Properties: &armmarketplaceordering.AgreementProperties{ + // Accepted: to.Ptr(true), + // LicenseTextLink: to.Ptr("test.licenseLink"), + // MarketplaceTermsLink: to.Ptr("test.marketplaceTermsLink"), + // Plan: to.Ptr("planid"), + // PrivacyPolicyLink: to.Ptr("test.privacyPolicyLink"), + // Product: to.Ptr("offid"), + // Publisher: to.Ptr("pubid"), + // RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-15T11:33:07.12132Z"); return t}()), + // Signature: to.Ptr("ASDFSDAFWEFASDGWERLWER"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/CancelMarketplaceTerms.json +func ExampleMarketplaceAgreementsClient_Cancel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmarketplaceordering.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMarketplaceAgreementsClient().Cancel(ctx, "pubid", "offid", "planid", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AgreementTerms = armmarketplaceordering.AgreementTerms{ + // Name: to.Ptr("planid"), + // Type: to.Ptr("Microsoft.MarketplaceOrdering/offertypes"), + // ID: to.Ptr("id"), + // Properties: &armmarketplaceordering.AgreementProperties{ + // Accepted: to.Ptr(false), + // LicenseTextLink: to.Ptr("test.licenseLink"), + // MarketplaceTermsLink: to.Ptr("test.marketplaceTermsLink"), + // Plan: to.Ptr("planid"), + // PrivacyPolicyLink: to.Ptr("test.privacyPolicyLink"), + // Product: to.Ptr("offid"), + // Publisher: to.Ptr("pubid"), + // RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-15T11:33:07.12132Z"); return t}()), + // Signature: to.Ptr("ASDFSDAFWEFASDGWERLWER"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/GetAgreementMarketplaceTerms.json +func ExampleMarketplaceAgreementsClient_GetAgreement() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmarketplaceordering.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMarketplaceAgreementsClient().GetAgreement(ctx, "pubid", "offid", "planid", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AgreementTerms = armmarketplaceordering.AgreementTerms{ + // Name: to.Ptr("planid"), + // Type: to.Ptr("Microsoft.MarketplaceOrdering/offertypes"), + // ID: to.Ptr("id"), + // Properties: &armmarketplaceordering.AgreementProperties{ + // Accepted: to.Ptr(true), + // LicenseTextLink: to.Ptr("test.licenseLink"), + // MarketplaceTermsLink: to.Ptr("test.marketplaceTermsLink"), + // Plan: to.Ptr("planid"), + // PrivacyPolicyLink: to.Ptr("test.privacyPolicyLink"), + // Product: to.Ptr("offid"), + // Publisher: to.Ptr("pubid"), + // RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-15T11:33:07.12132Z"); return t}()), + // Signature: to.Ptr("ASDFSDAFWEFASDGWERLWER"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/ListMarketplaceTerms.json +func ExampleMarketplaceAgreementsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmarketplaceordering.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMarketplaceAgreementsClient().List(ctx, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AgreementTermsArray = []*armmarketplaceordering.AgreementTerms{ + // { + // Name: to.Ptr("planid"), + // Type: to.Ptr("Microsoft.MarketplaceOrdering/offertypes"), + // ID: to.Ptr("id"), + // Properties: &armmarketplaceordering.AgreementProperties{ + // Accepted: to.Ptr(true), + // LicenseTextLink: to.Ptr("test.licenseLink"), + // MarketplaceTermsLink: to.Ptr("test.marketplaceTermsLink"), + // Plan: to.Ptr("planid"), + // PrivacyPolicyLink: to.Ptr("test.privacyPolicyLink"), + // Product: to.Ptr("offid"), + // Publisher: to.Ptr("pubid"), + // RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-15T11:33:07.12132Z"); return t}()), + // Signature: to.Ptr("ASDFSDAFWEFASDGWERLWER"), + // }, + // }} +} diff --git a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_models.go b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/models.go similarity index 99% rename from sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_models.go rename to sdk/resourcemanager/marketplaceordering/armmarketplaceordering/models.go index 99f3f9df4951..14e52ad41ff6 100644 --- a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_models.go +++ b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/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 armmarketplaceordering @@ -139,7 +140,7 @@ type OperationListResult struct { NextLink *string `json:"nextLink,omitempty" azure:"ro"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/models_serde.go b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/models_serde.go new file mode 100644 index 000000000000..f54d25952aa5 --- /dev/null +++ b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/models_serde.go @@ -0,0 +1,380 @@ +//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 armmarketplaceordering + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AgreementProperties. +func (a AgreementProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accepted", a.Accepted) + populate(objectMap, "licenseTextLink", a.LicenseTextLink) + populate(objectMap, "marketplaceTermsLink", a.MarketplaceTermsLink) + populate(objectMap, "plan", a.Plan) + populate(objectMap, "privacyPolicyLink", a.PrivacyPolicyLink) + populate(objectMap, "product", a.Product) + populate(objectMap, "publisher", a.Publisher) + populateTimeRFC3339(objectMap, "retrieveDatetime", a.RetrieveDatetime) + populate(objectMap, "signature", a.Signature) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgreementProperties. +func (a *AgreementProperties) 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 "accepted": + err = unpopulate(val, "Accepted", &a.Accepted) + delete(rawMsg, key) + case "licenseTextLink": + err = unpopulate(val, "LicenseTextLink", &a.LicenseTextLink) + delete(rawMsg, key) + case "marketplaceTermsLink": + err = unpopulate(val, "MarketplaceTermsLink", &a.MarketplaceTermsLink) + delete(rawMsg, key) + case "plan": + err = unpopulate(val, "Plan", &a.Plan) + delete(rawMsg, key) + case "privacyPolicyLink": + err = unpopulate(val, "PrivacyPolicyLink", &a.PrivacyPolicyLink) + delete(rawMsg, key) + case "product": + err = unpopulate(val, "Product", &a.Product) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &a.Publisher) + delete(rawMsg, key) + case "retrieveDatetime": + err = unpopulateTimeRFC3339(val, "RetrieveDatetime", &a.RetrieveDatetime) + delete(rawMsg, key) + case "signature": + err = unpopulate(val, "Signature", &a.Signature) + 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 AgreementTerms. +func (a AgreementTerms) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgreementTerms. +func (a *AgreementTerms) 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 "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponseError. +func (e ErrorResponseError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", e.Code) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponseError. +func (e *ErrorResponseError) 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 "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + 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 Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "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]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_operations_client.go b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/operations_client.go similarity index 77% rename from sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_operations_client.go rename to sdk/resourcemanager/marketplaceordering/armmarketplaceordering/operations_client.go index a4ae6ae53d5e..f028717f3130 100644 --- a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_operations_client.go +++ b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/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 armmarketplaceordering @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,36 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists all of the available Microsoft.MarketplaceOrdering REST API operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-01-01 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -68,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -83,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.MarketplaceOrdering/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_response_types.go b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/response_types.go similarity index 97% rename from sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_response_types.go rename to sdk/resourcemanager/marketplaceordering/armmarketplaceordering/response_types.go index f10932f5a4fa..93e048ffaeb1 100644 --- a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_response_types.go +++ b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/response_types.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armmarketplaceordering @@ -39,7 +40,7 @@ type MarketplaceAgreementsClientSignResponse struct { AgreementTerms } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult } diff --git a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_time_rfc3339.go b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/marketplaceordering/armmarketplaceordering/time_rfc3339.go index 530bf894b9bc..8133f962dc6a 100644 --- a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/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 armmarketplaceordering @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/ze_generated_example_marketplaceagreements_client_test.go b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/ze_generated_example_marketplaceagreements_client_test.go deleted file mode 100644 index 3229e3de0719..000000000000 --- a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/ze_generated_example_marketplaceagreements_client_test.go +++ /dev/null @@ -1,170 +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 armmarketplaceordering_test - -import ( - "context" - "log" - - "time" - - "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/marketplaceordering/armmarketplaceordering" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/GetMarketplaceTerms.json -func ExampleMarketplaceAgreementsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmarketplaceordering.NewMarketplaceAgreementsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - armmarketplaceordering.OfferTypeVirtualmachine, - "pubid", - "offid", - "planid", - 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/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/SetMarketplaceTerms.json -func ExampleMarketplaceAgreementsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmarketplaceordering.NewMarketplaceAgreementsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, - armmarketplaceordering.OfferTypeVirtualmachine, - "pubid", - "offid", - "planid", - armmarketplaceordering.AgreementTerms{ - Properties: &armmarketplaceordering.AgreementProperties{ - Accepted: to.Ptr(false), - LicenseTextLink: to.Ptr("test.licenseLink"), - MarketplaceTermsLink: to.Ptr("test.marketplaceTermsLink"), - Plan: to.Ptr("planid"), - PrivacyPolicyLink: to.Ptr("test.privacyPolicyLink"), - Product: to.Ptr("offid"), - Publisher: to.Ptr("pubid"), - RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-15T11:33:07.12132Z"); return t }()), - Signature: to.Ptr("ASDFSDAFWEFASDGWERLWER"), - }, - }, - 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/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/SignMarketplaceTerms.json -func ExampleMarketplaceAgreementsClient_Sign() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmarketplaceordering.NewMarketplaceAgreementsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Sign(ctx, - "pubid", - "offid", - "planid", - 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/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/CancelMarketplaceTerms.json -func ExampleMarketplaceAgreementsClient_Cancel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmarketplaceordering.NewMarketplaceAgreementsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Cancel(ctx, - "pubid", - "offid", - "planid", - 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/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/GetAgreementMarketplaceTerms.json -func ExampleMarketplaceAgreementsClient_GetAgreement() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmarketplaceordering.NewMarketplaceAgreementsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetAgreement(ctx, - "pubid", - "offid", - "planid", - 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/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/ListMarketplaceTerms.json -func ExampleMarketplaceAgreementsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmarketplaceordering.NewMarketplaceAgreementsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_models_serde.go b/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_models_serde.go deleted file mode 100644 index 2c6eaf7503bb..000000000000 --- a/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/zz_generated_models_serde.go +++ /dev/null @@ -1,142 +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 armmarketplaceordering - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type AgreementProperties. -func (a AgreementProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "accepted", a.Accepted) - populate(objectMap, "licenseTextLink", a.LicenseTextLink) - populate(objectMap, "marketplaceTermsLink", a.MarketplaceTermsLink) - populate(objectMap, "plan", a.Plan) - populate(objectMap, "privacyPolicyLink", a.PrivacyPolicyLink) - populate(objectMap, "product", a.Product) - populate(objectMap, "publisher", a.Publisher) - populateTimeRFC3339(objectMap, "retrieveDatetime", a.RetrieveDatetime) - populate(objectMap, "signature", a.Signature) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AgreementProperties. -func (a *AgreementProperties) 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 "accepted": - err = unpopulate(val, "Accepted", &a.Accepted) - delete(rawMsg, key) - case "licenseTextLink": - err = unpopulate(val, "LicenseTextLink", &a.LicenseTextLink) - delete(rawMsg, key) - case "marketplaceTermsLink": - err = unpopulate(val, "MarketplaceTermsLink", &a.MarketplaceTermsLink) - delete(rawMsg, key) - case "plan": - err = unpopulate(val, "Plan", &a.Plan) - delete(rawMsg, key) - case "privacyPolicyLink": - err = unpopulate(val, "PrivacyPolicyLink", &a.PrivacyPolicyLink) - delete(rawMsg, key) - case "product": - err = unpopulate(val, "Product", &a.Product) - delete(rawMsg, key) - case "publisher": - err = unpopulate(val, "Publisher", &a.Publisher) - delete(rawMsg, key) - case "retrieveDatetime": - err = unpopulateTimeRFC3339(val, "RetrieveDatetime", &a.RetrieveDatetime) - delete(rawMsg, key) - case "signature": - err = unpopulate(val, "Signature", &a.Signature) - 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 SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -} diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/CHANGELOG.md b/sdk/resourcemanager/mediaservices/armmediaservices/CHANGELOG.md index 15e00d3e9c92..47c3fd8f24ad 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/CHANGELOG.md +++ b/sdk/resourcemanager/mediaservices/armmediaservices/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 3.3.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 3.2.0 (2023-01-13) ### Features Added diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/README.md b/sdk/resourcemanager/mediaservices/armmediaservices/README.md index adcee19ece0d..e76e730bc86f 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/README.md +++ b/sdk/resourcemanager/mediaservices/armmediaservices/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Media Services modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Media Services module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armmediaservices.NewClient(, cred, nil) +clientFactory, err := armmediaservices.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armmediaservices.NewClient(, cred, &options) +clientFactory, err := armmediaservices.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewClient() ``` ## Major Version Upgrade diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/accountfilters_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/accountfilters_client.go index ab6660e24877..bf44d4d6d554 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/accountfilters_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/accountfilters_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,50 +24,42 @@ import ( // AccountFiltersClient contains the methods for the AccountFilters group. // Don't use this type directly, use NewAccountFiltersClient() instead. type AccountFiltersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAccountFiltersClient creates a new instance of AccountFiltersClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAccountFiltersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AccountFiltersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AccountFiltersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AccountFiltersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Creates or updates an Account Filter in the Media Services account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// filterName - The Account Filter name -// parameters - The request parameters -// options - AccountFiltersClientCreateOrUpdateOptions contains the optional parameters for the AccountFiltersClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - filterName - The Account Filter name +// - parameters - The request parameters +// - options - AccountFiltersClientCreateOrUpdateOptions contains the optional parameters for the AccountFiltersClient.CreateOrUpdate +// method. func (client *AccountFiltersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, filterName string, parameters AccountFilter, options *AccountFiltersClientCreateOrUpdateOptions) (AccountFiltersClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, filterName, parameters, options) if err != nil { return AccountFiltersClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountFiltersClientCreateOrUpdateResponse{}, err } @@ -98,7 +88,7 @@ func (client *AccountFiltersClient) createOrUpdateCreateRequest(ctx context.Cont return nil, errors.New("parameter filterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{filterName}", url.PathEscape(filterName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -120,17 +110,18 @@ func (client *AccountFiltersClient) createOrUpdateHandleResponse(resp *http.Resp // Delete - Deletes an Account Filter in the Media Services account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// filterName - The Account Filter name -// options - AccountFiltersClientDeleteOptions contains the optional parameters for the AccountFiltersClient.Delete method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - filterName - The Account Filter name +// - options - AccountFiltersClientDeleteOptions contains the optional parameters for the AccountFiltersClient.Delete method. func (client *AccountFiltersClient) Delete(ctx context.Context, resourceGroupName string, accountName string, filterName string, options *AccountFiltersClientDeleteOptions) (AccountFiltersClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, filterName, options) if err != nil { return AccountFiltersClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountFiltersClientDeleteResponse{}, err } @@ -159,7 +150,7 @@ func (client *AccountFiltersClient) deleteCreateRequest(ctx context.Context, res return nil, errors.New("parameter filterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{filterName}", url.PathEscape(filterName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -172,17 +163,18 @@ func (client *AccountFiltersClient) deleteCreateRequest(ctx context.Context, res // Get - Get the details of an Account Filter in the Media Services account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// filterName - The Account Filter name -// options - AccountFiltersClientGetOptions contains the optional parameters for the AccountFiltersClient.Get method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - filterName - The Account Filter name +// - options - AccountFiltersClientGetOptions contains the optional parameters for the AccountFiltersClient.Get method. func (client *AccountFiltersClient) Get(ctx context.Context, resourceGroupName string, accountName string, filterName string, options *AccountFiltersClientGetOptions) (AccountFiltersClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, filterName, options) if err != nil { return AccountFiltersClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountFiltersClientGetResponse{}, err } @@ -211,7 +203,7 @@ func (client *AccountFiltersClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter filterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{filterName}", url.PathEscape(filterName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -232,10 +224,11 @@ func (client *AccountFiltersClient) getHandleResponse(resp *http.Response) (Acco } // NewListPager - List Account Filters in the Media Services account. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// options - AccountFiltersClientListOptions contains the optional parameters for the AccountFiltersClient.List method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - options - AccountFiltersClientListOptions contains the optional parameters for the AccountFiltersClient.NewListPager method. func (client *AccountFiltersClient) NewListPager(resourceGroupName string, accountName string, options *AccountFiltersClientListOptions) *runtime.Pager[AccountFiltersClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AccountFiltersClientListResponse]{ More: func(page AccountFiltersClientListResponse) bool { @@ -252,7 +245,7 @@ func (client *AccountFiltersClient) NewListPager(resourceGroupName string, accou if err != nil { return AccountFiltersClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountFiltersClientListResponse{}, err } @@ -279,7 +272,7 @@ func (client *AccountFiltersClient) listCreateRequest(ctx context.Context, resou return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -301,18 +294,19 @@ func (client *AccountFiltersClient) listHandleResponse(resp *http.Response) (Acc // Update - Updates an existing Account Filter in the Media Services account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// filterName - The Account Filter name -// parameters - The request parameters -// options - AccountFiltersClientUpdateOptions contains the optional parameters for the AccountFiltersClient.Update method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - filterName - The Account Filter name +// - parameters - The request parameters +// - options - AccountFiltersClientUpdateOptions contains the optional parameters for the AccountFiltersClient.Update method. func (client *AccountFiltersClient) Update(ctx context.Context, resourceGroupName string, accountName string, filterName string, parameters AccountFilter, options *AccountFiltersClientUpdateOptions) (AccountFiltersClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, filterName, parameters, options) if err != nil { return AccountFiltersClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountFiltersClientUpdateResponse{}, err } @@ -341,7 +335,7 @@ func (client *AccountFiltersClient) updateCreateRequest(ctx context.Context, res return nil, errors.New("parameter filterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{filterName}", url.PathEscape(filterName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/accountfilters_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/accountfilters_client_example_test.go index 6fa9661de8eb..054df5d82a65 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/accountfilters_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/accountfilters_client_example_test.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 armmediaservices_test @@ -17,61 +18,194 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/accountFilters-list-all.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/accountFilters-list-all.json func ExampleAccountFiltersClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAccountFiltersClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contoso", "contosomedia", nil) + pager := clientFactory.NewAccountFiltersClient().NewListPager("contoso", "contosomedia", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AccountFilterCollection = armmediaservices.AccountFilterCollection{ + // Value: []*armmediaservices.AccountFilter{ + // { + // Name: to.Ptr("accountFilterWithTimeWindowAndTrack"), + // Type: to.Ptr("Microsoft.Media/mediaservices/accountFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/accountFilters/accountFilterWithTimeWindowAndTrack"), + // Properties: &armmediaservices.MediaFilterProperties{ + // FirstQuality: &armmediaservices.FirstQuality{ + // Bitrate: to.Ptr[int32](128000), + // }, + // PresentationTimeRange: &armmediaservices.PresentationTimeRange{ + // EndTimestamp: to.Ptr[int64](170000000), + // ForceEndTimestamp: to.Ptr(false), + // LiveBackoffDuration: to.Ptr[int64](0), + // PresentationWindowDuration: to.Ptr[int64](9223372036854775000), + // StartTimestamp: to.Ptr[int64](0), + // Timescale: to.Ptr[int64](10000000), + // }, + // Tracks: []*armmediaservices.FilterTrackSelection{ + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Audio"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeLanguage), + // Value: to.Ptr("en"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeFourCC), + // Value: to.Ptr("EC-3"), + // }}, + // }, + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Video"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeBitrate), + // Value: to.Ptr("3000000-5000000"), + // }}, + // }}, + // }, + // }, + // { + // Name: to.Ptr("accountFilterWithTrack"), + // Type: to.Ptr("Microsoft.Media/mediaservices/accountFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/accountFilters/accountFilterWithTrack"), + // Properties: &armmediaservices.MediaFilterProperties{ + // Tracks: []*armmediaservices.FilterTrackSelection{ + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Audio"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeLanguage), + // Value: to.Ptr("en"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeFourCC), + // Value: to.Ptr("EC-3"), + // }}, + // }, + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Video"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeBitrate), + // Value: to.Ptr("3000000-5000000"), + // }}, + // }}, + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/accountFilters-get-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/accountFilters-get-by-name.json func ExampleAccountFiltersClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAccountFiltersClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contoso", "contosomedia", "accountFilterWithTrack", nil) + res, err := clientFactory.NewAccountFiltersClient().Get(ctx, "contoso", "contosomedia", "accountFilterWithTrack", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccountFilter = armmediaservices.AccountFilter{ + // Name: to.Ptr("accountFilterWithTrack"), + // Type: to.Ptr("Microsoft.Media/mediaservices/accountFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/accountFilters/accountFilterWithTrack"), + // Properties: &armmediaservices.MediaFilterProperties{ + // Tracks: []*armmediaservices.FilterTrackSelection{ + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Audio"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeLanguage), + // Value: to.Ptr("en"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeFourCC), + // Value: to.Ptr("EC-3"), + // }}, + // }, + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Video"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeBitrate), + // Value: to.Ptr("3000000-5000000"), + // }}, + // }}, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/accountFilters-create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/accountFilters-create.json func ExampleAccountFiltersClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAccountFiltersClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "contoso", "contosomedia", "newAccountFilter", armmediaservices.AccountFilter{ + res, err := clientFactory.NewAccountFiltersClient().CreateOrUpdate(ctx, "contoso", "contosomedia", "newAccountFilter", armmediaservices.AccountFilter{ Properties: &armmediaservices.MediaFilterProperties{ FirstQuality: &armmediaservices.FirstQuality{ Bitrate: to.Ptr[int32](128000), @@ -121,39 +255,90 @@ func ExampleAccountFiltersClient_CreateOrUpdate() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccountFilter = armmediaservices.AccountFilter{ + // Name: to.Ptr("newAccountFilter"), + // Type: to.Ptr("Microsoft.Media/mediaservices/accountFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/accountFilters/newAccountFilter"), + // Properties: &armmediaservices.MediaFilterProperties{ + // FirstQuality: &armmediaservices.FirstQuality{ + // Bitrate: to.Ptr[int32](128000), + // }, + // PresentationTimeRange: &armmediaservices.PresentationTimeRange{ + // EndTimestamp: to.Ptr[int64](170000000), + // ForceEndTimestamp: to.Ptr(false), + // LiveBackoffDuration: to.Ptr[int64](0), + // PresentationWindowDuration: to.Ptr[int64](9223372036854775000), + // StartTimestamp: to.Ptr[int64](0), + // Timescale: to.Ptr[int64](10000000), + // }, + // Tracks: []*armmediaservices.FilterTrackSelection{ + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Audio"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeLanguage), + // Value: to.Ptr("en"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeFourCC), + // Value: to.Ptr("EC-3"), + // }}, + // }, + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Video"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeBitrate), + // Value: to.Ptr("3000000-5000000"), + // }}, + // }}, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/accountFilters-delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/accountFilters-delete.json func ExampleAccountFiltersClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAccountFiltersClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "contoso", "contosomedia", "accountFilterWithTimeWindowAndTrack", nil) + _, err = clientFactory.NewAccountFiltersClient().Delete(ctx, "contoso", "contosomedia", "accountFilterWithTimeWindowAndTrack", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/accountFilters-update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/accountFilters-update.json func ExampleAccountFiltersClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAccountFiltersClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "contoso", "contosomedia", "accountFilterWithTimeWindowAndTrack", armmediaservices.AccountFilter{ + res, err := clientFactory.NewAccountFiltersClient().Update(ctx, "contoso", "contosomedia", "accountFilterWithTimeWindowAndTrack", armmediaservices.AccountFilter{ Properties: &armmediaservices.MediaFilterProperties{ FirstQuality: &armmediaservices.FirstQuality{ Bitrate: to.Ptr[int32](128000), @@ -171,6 +356,57 @@ func ExampleAccountFiltersClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccountFilter = armmediaservices.AccountFilter{ + // Name: to.Ptr("accountFilterWithTimeWindowAndTrack"), + // Type: to.Ptr("Microsoft.Media/mediaservices/accountFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/accountFilters/accountFilterWithTimeWindowAndTrack"), + // Properties: &armmediaservices.MediaFilterProperties{ + // FirstQuality: &armmediaservices.FirstQuality{ + // Bitrate: to.Ptr[int32](128000), + // }, + // PresentationTimeRange: &armmediaservices.PresentationTimeRange{ + // EndTimestamp: to.Ptr[int64](170000000), + // ForceEndTimestamp: to.Ptr(false), + // LiveBackoffDuration: to.Ptr[int64](0), + // PresentationWindowDuration: to.Ptr[int64](9223372036854775000), + // StartTimestamp: to.Ptr[int64](10), + // Timescale: to.Ptr[int64](10000000), + // }, + // Tracks: []*armmediaservices.FilterTrackSelection{ + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Audio"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeLanguage), + // Value: to.Ptr("en"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeFourCC), + // Value: to.Ptr("EC-3"), + // }}, + // }, + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Video"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeBitrate), + // Value: to.Ptr("3000000-5000000"), + // }}, + // }}, + // }, + // } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/assetfilters_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/assetfilters_client.go index 9976359f527b..5c8dd172a921 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/assetfilters_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/assetfilters_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,51 +24,43 @@ import ( // AssetFiltersClient contains the methods for the AssetFilters group. // Don't use this type directly, use NewAssetFiltersClient() instead. type AssetFiltersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAssetFiltersClient creates a new instance of AssetFiltersClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAssetFiltersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssetFiltersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AssetFiltersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AssetFiltersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Creates or updates an Asset Filter associated with the specified Asset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// filterName - The Asset Filter name -// parameters - The request parameters -// options - AssetFiltersClientCreateOrUpdateOptions contains the optional parameters for the AssetFiltersClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - filterName - The Asset Filter name +// - parameters - The request parameters +// - options - AssetFiltersClientCreateOrUpdateOptions contains the optional parameters for the AssetFiltersClient.CreateOrUpdate +// method. func (client *AssetFiltersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, assetName string, filterName string, parameters AssetFilter, options *AssetFiltersClientCreateOrUpdateOptions) (AssetFiltersClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, assetName, filterName, parameters, options) if err != nil { return AssetFiltersClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssetFiltersClientCreateOrUpdateResponse{}, err } @@ -103,7 +93,7 @@ func (client *AssetFiltersClient) createOrUpdateCreateRequest(ctx context.Contex return nil, errors.New("parameter filterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{filterName}", url.PathEscape(filterName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -125,18 +115,19 @@ func (client *AssetFiltersClient) createOrUpdateHandleResponse(resp *http.Respon // Delete - Deletes an Asset Filter associated with the specified Asset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// filterName - The Asset Filter name -// options - AssetFiltersClientDeleteOptions contains the optional parameters for the AssetFiltersClient.Delete method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - filterName - The Asset Filter name +// - options - AssetFiltersClientDeleteOptions contains the optional parameters for the AssetFiltersClient.Delete method. func (client *AssetFiltersClient) Delete(ctx context.Context, resourceGroupName string, accountName string, assetName string, filterName string, options *AssetFiltersClientDeleteOptions) (AssetFiltersClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, assetName, filterName, options) if err != nil { return AssetFiltersClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssetFiltersClientDeleteResponse{}, err } @@ -169,7 +160,7 @@ func (client *AssetFiltersClient) deleteCreateRequest(ctx context.Context, resou return nil, errors.New("parameter filterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{filterName}", url.PathEscape(filterName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -182,18 +173,19 @@ func (client *AssetFiltersClient) deleteCreateRequest(ctx context.Context, resou // Get - Get the details of an Asset Filter associated with the specified Asset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// filterName - The Asset Filter name -// options - AssetFiltersClientGetOptions contains the optional parameters for the AssetFiltersClient.Get method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - filterName - The Asset Filter name +// - options - AssetFiltersClientGetOptions contains the optional parameters for the AssetFiltersClient.Get method. func (client *AssetFiltersClient) Get(ctx context.Context, resourceGroupName string, accountName string, assetName string, filterName string, options *AssetFiltersClientGetOptions) (AssetFiltersClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, assetName, filterName, options) if err != nil { return AssetFiltersClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssetFiltersClientGetResponse{}, err } @@ -226,7 +218,7 @@ func (client *AssetFiltersClient) getCreateRequest(ctx context.Context, resource return nil, errors.New("parameter filterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{filterName}", url.PathEscape(filterName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -247,11 +239,12 @@ func (client *AssetFiltersClient) getHandleResponse(resp *http.Response) (AssetF } // NewListPager - List Asset Filters associated with the specified Asset. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// options - AssetFiltersClientListOptions contains the optional parameters for the AssetFiltersClient.List method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - options - AssetFiltersClientListOptions contains the optional parameters for the AssetFiltersClient.NewListPager method. func (client *AssetFiltersClient) NewListPager(resourceGroupName string, accountName string, assetName string, options *AssetFiltersClientListOptions) *runtime.Pager[AssetFiltersClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AssetFiltersClientListResponse]{ More: func(page AssetFiltersClientListResponse) bool { @@ -268,7 +261,7 @@ func (client *AssetFiltersClient) NewListPager(resourceGroupName string, account if err != nil { return AssetFiltersClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssetFiltersClientListResponse{}, err } @@ -299,7 +292,7 @@ func (client *AssetFiltersClient) listCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter assetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assetName}", url.PathEscape(assetName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -321,19 +314,20 @@ func (client *AssetFiltersClient) listHandleResponse(resp *http.Response) (Asset // Update - Updates an existing Asset Filter associated with the specified Asset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// filterName - The Asset Filter name -// parameters - The request parameters -// options - AssetFiltersClientUpdateOptions contains the optional parameters for the AssetFiltersClient.Update method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - filterName - The Asset Filter name +// - parameters - The request parameters +// - options - AssetFiltersClientUpdateOptions contains the optional parameters for the AssetFiltersClient.Update method. func (client *AssetFiltersClient) Update(ctx context.Context, resourceGroupName string, accountName string, assetName string, filterName string, parameters AssetFilter, options *AssetFiltersClientUpdateOptions) (AssetFiltersClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, assetName, filterName, parameters, options) if err != nil { return AssetFiltersClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssetFiltersClientUpdateResponse{}, err } @@ -366,7 +360,7 @@ func (client *AssetFiltersClient) updateCreateRequest(ctx context.Context, resou return nil, errors.New("parameter filterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{filterName}", url.PathEscape(filterName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/assetfilters_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/assetfilters_client_example_test.go index 6112557c9a56..9a1fca52564e 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/assetfilters_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/assetfilters_client_example_test.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 armmediaservices_test @@ -17,61 +18,225 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assetFilters-list-all.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assetFilters-list-all.json func ExampleAssetFiltersClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetFiltersClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contoso", "contosomedia", "ClimbingMountRainer", nil) + pager := clientFactory.NewAssetFiltersClient().NewListPager("contoso", "contosomedia", "ClimbingMountRainer", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AssetFilterCollection = armmediaservices.AssetFilterCollection{ + // Value: []*armmediaservices.AssetFilter{ + // { + // Name: to.Ptr("assetFilterWithTimeWindowAndTrack"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets/assetFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/assetFilters/assetFilterWithTimeWindowAndTrack"), + // Properties: &armmediaservices.MediaFilterProperties{ + // FirstQuality: &armmediaservices.FirstQuality{ + // Bitrate: to.Ptr[int32](128000), + // }, + // PresentationTimeRange: &armmediaservices.PresentationTimeRange{ + // EndTimestamp: to.Ptr[int64](170000000), + // ForceEndTimestamp: to.Ptr(false), + // LiveBackoffDuration: to.Ptr[int64](0), + // PresentationWindowDuration: to.Ptr[int64](9223372036854775000), + // StartTimestamp: to.Ptr[int64](0), + // Timescale: to.Ptr[int64](10000000), + // }, + // Tracks: []*armmediaservices.FilterTrackSelection{ + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Audio"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeLanguage), + // Value: to.Ptr("en"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeFourCC), + // Value: to.Ptr("EC-3"), + // }}, + // }, + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Video"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeBitrate), + // Value: to.Ptr("3000000-5000000"), + // }}, + // }}, + // }, + // }, + // { + // Name: to.Ptr("assetFilterWithTimeWindow"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets/assetFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/assetFilters/assetFilterWithTimeWindow"), + // Properties: &armmediaservices.MediaFilterProperties{ + // FirstQuality: &armmediaservices.FirstQuality{ + // Bitrate: to.Ptr[int32](128000), + // }, + // PresentationTimeRange: &armmediaservices.PresentationTimeRange{ + // EndTimestamp: to.Ptr[int64](170000000), + // ForceEndTimestamp: to.Ptr(false), + // LiveBackoffDuration: to.Ptr[int64](0), + // PresentationWindowDuration: to.Ptr[int64](9223372036854775000), + // StartTimestamp: to.Ptr[int64](0), + // Timescale: to.Ptr[int64](10000000), + // }, + // Tracks: []*armmediaservices.FilterTrackSelection{ + // }, + // }, + // }, + // { + // Name: to.Ptr("assetFilterWithTrack"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets/assetFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/assetFilters/assetFilterWithTrack"), + // Properties: &armmediaservices.MediaFilterProperties{ + // Tracks: []*armmediaservices.FilterTrackSelection{ + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Audio"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeLanguage), + // Value: to.Ptr("en"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeFourCC), + // Value: to.Ptr("EC-3"), + // }}, + // }, + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Video"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeBitrate), + // Value: to.Ptr("3000000-5000000"), + // }}, + // }}, + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assetFilters-get-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assetFilters-get-by-name.json func ExampleAssetFiltersClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetFiltersClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "assetFilterWithTimeWindowAndTrack", nil) + res, err := clientFactory.NewAssetFiltersClient().Get(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "assetFilterWithTimeWindowAndTrack", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AssetFilter = armmediaservices.AssetFilter{ + // Name: to.Ptr("assetFilterWithTimeWindowAndTrack"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets/assetFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/assetFilters/assetFilterWithTimeWindowAndTrack"), + // Properties: &armmediaservices.MediaFilterProperties{ + // FirstQuality: &armmediaservices.FirstQuality{ + // Bitrate: to.Ptr[int32](128000), + // }, + // PresentationTimeRange: &armmediaservices.PresentationTimeRange{ + // EndTimestamp: to.Ptr[int64](170000000), + // ForceEndTimestamp: to.Ptr(false), + // LiveBackoffDuration: to.Ptr[int64](0), + // PresentationWindowDuration: to.Ptr[int64](9223372036854775000), + // StartTimestamp: to.Ptr[int64](0), + // Timescale: to.Ptr[int64](10000000), + // }, + // Tracks: []*armmediaservices.FilterTrackSelection{ + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Audio"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeLanguage), + // Value: to.Ptr("en"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeFourCC), + // Value: to.Ptr("EC-3"), + // }}, + // }, + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Video"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeBitrate), + // Value: to.Ptr("3000000-5000000"), + // }}, + // }}, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assetFilters-create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assetFilters-create.json func ExampleAssetFiltersClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetFiltersClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "newAssetFilter", armmediaservices.AssetFilter{ + res, err := clientFactory.NewAssetFiltersClient().CreateOrUpdate(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "newAssetFilter", armmediaservices.AssetFilter{ Properties: &armmediaservices.MediaFilterProperties{ FirstQuality: &armmediaservices.FirstQuality{ Bitrate: to.Ptr[int32](128000), @@ -121,39 +286,90 @@ func ExampleAssetFiltersClient_CreateOrUpdate() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AssetFilter = armmediaservices.AssetFilter{ + // Name: to.Ptr("newAssetFilter"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets/assetFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/assetFilters/newAssetFilter"), + // Properties: &armmediaservices.MediaFilterProperties{ + // FirstQuality: &armmediaservices.FirstQuality{ + // Bitrate: to.Ptr[int32](128000), + // }, + // PresentationTimeRange: &armmediaservices.PresentationTimeRange{ + // EndTimestamp: to.Ptr[int64](170000000), + // ForceEndTimestamp: to.Ptr(false), + // LiveBackoffDuration: to.Ptr[int64](0), + // PresentationWindowDuration: to.Ptr[int64](9223372036854775000), + // StartTimestamp: to.Ptr[int64](0), + // Timescale: to.Ptr[int64](10000000), + // }, + // Tracks: []*armmediaservices.FilterTrackSelection{ + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Audio"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeLanguage), + // Value: to.Ptr("en"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeFourCC), + // Value: to.Ptr("EC-3"), + // }}, + // }, + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Video"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeBitrate), + // Value: to.Ptr("3000000-5000000"), + // }}, + // }}, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assetFilters-delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assetFilters-delete.json func ExampleAssetFiltersClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetFiltersClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "assetFilterWithTimeWindowAndTrack", nil) + _, err = clientFactory.NewAssetFiltersClient().Delete(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "assetFilterWithTimeWindowAndTrack", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assetFilters-update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assetFilters-update.json func ExampleAssetFiltersClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetFiltersClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "assetFilterWithTimeWindowAndTrack", armmediaservices.AssetFilter{ + res, err := clientFactory.NewAssetFiltersClient().Update(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "assetFilterWithTimeWindowAndTrack", armmediaservices.AssetFilter{ Properties: &armmediaservices.MediaFilterProperties{ FirstQuality: &armmediaservices.FirstQuality{ Bitrate: to.Ptr[int32](128000), @@ -171,6 +387,57 @@ func ExampleAssetFiltersClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AssetFilter = armmediaservices.AssetFilter{ + // Name: to.Ptr("assetFilterWithTimeWindowAndTrack"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets/assetFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/assetFilters/assetFilterWithTimeWindowAndTrack"), + // Properties: &armmediaservices.MediaFilterProperties{ + // FirstQuality: &armmediaservices.FirstQuality{ + // Bitrate: to.Ptr[int32](128000), + // }, + // PresentationTimeRange: &armmediaservices.PresentationTimeRange{ + // EndTimestamp: to.Ptr[int64](170000000), + // ForceEndTimestamp: to.Ptr(false), + // LiveBackoffDuration: to.Ptr[int64](0), + // PresentationWindowDuration: to.Ptr[int64](9223372036854775000), + // StartTimestamp: to.Ptr[int64](10), + // Timescale: to.Ptr[int64](10000000), + // }, + // Tracks: []*armmediaservices.FilterTrackSelection{ + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Audio"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeLanguage), + // Value: to.Ptr("en"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationNotEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeFourCC), + // Value: to.Ptr("EC-3"), + // }}, + // }, + // { + // TrackSelections: []*armmediaservices.FilterTrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeType), + // Value: to.Ptr("Video"), + // }, + // { + // Operation: to.Ptr(armmediaservices.FilterTrackPropertyCompareOperationEqual), + // Property: to.Ptr(armmediaservices.FilterTrackPropertyTypeBitrate), + // Value: to.Ptr("3000000-5000000"), + // }}, + // }}, + // }, + // } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/assets_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/assets_client.go index 2bbc116ffe11..6f4a507df925 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/assets_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/assets_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,49 +25,41 @@ import ( // AssetsClient contains the methods for the Assets group. // Don't use this type directly, use NewAssetsClient() instead. type AssetsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAssetsClient creates a new instance of AssetsClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAssetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssetsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AssetsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AssetsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Creates or updates an Asset in the Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// parameters - The request parameters -// options - AssetsClientCreateOrUpdateOptions contains the optional parameters for the AssetsClient.CreateOrUpdate method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - parameters - The request parameters +// - options - AssetsClientCreateOrUpdateOptions contains the optional parameters for the AssetsClient.CreateOrUpdate method. func (client *AssetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, assetName string, parameters Asset, options *AssetsClientCreateOrUpdateOptions) (AssetsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, assetName, parameters, options) if err != nil { return AssetsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssetsClientCreateOrUpdateResponse{}, err } @@ -98,7 +88,7 @@ func (client *AssetsClient) createOrUpdateCreateRequest(ctx context.Context, res return nil, errors.New("parameter assetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assetName}", url.PathEscape(assetName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -120,17 +110,18 @@ func (client *AssetsClient) createOrUpdateHandleResponse(resp *http.Response) (A // Delete - Deletes an Asset in the Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// options - AssetsClientDeleteOptions contains the optional parameters for the AssetsClient.Delete method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - options - AssetsClientDeleteOptions contains the optional parameters for the AssetsClient.Delete method. func (client *AssetsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, assetName string, options *AssetsClientDeleteOptions) (AssetsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, assetName, options) if err != nil { return AssetsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssetsClientDeleteResponse{}, err } @@ -159,7 +150,7 @@ func (client *AssetsClient) deleteCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter assetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assetName}", url.PathEscape(assetName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -172,17 +163,18 @@ func (client *AssetsClient) deleteCreateRequest(ctx context.Context, resourceGro // Get - Get the details of an Asset in the Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// options - AssetsClientGetOptions contains the optional parameters for the AssetsClient.Get method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - options - AssetsClientGetOptions contains the optional parameters for the AssetsClient.Get method. func (client *AssetsClient) Get(ctx context.Context, resourceGroupName string, accountName string, assetName string, options *AssetsClientGetOptions) (AssetsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, assetName, options) if err != nil { return AssetsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssetsClientGetResponse{}, err } @@ -211,7 +203,7 @@ func (client *AssetsClient) getCreateRequest(ctx context.Context, resourceGroupN return nil, errors.New("parameter assetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assetName}", url.PathEscape(assetName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -234,17 +226,18 @@ func (client *AssetsClient) getHandleResponse(resp *http.Response) (AssetsClient // GetEncryptionKey - Gets the Asset storage encryption keys used to decrypt content created by version 2 of the Media Services // API // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// options - AssetsClientGetEncryptionKeyOptions contains the optional parameters for the AssetsClient.GetEncryptionKey method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - options - AssetsClientGetEncryptionKeyOptions contains the optional parameters for the AssetsClient.GetEncryptionKey method. func (client *AssetsClient) GetEncryptionKey(ctx context.Context, resourceGroupName string, accountName string, assetName string, options *AssetsClientGetEncryptionKeyOptions) (AssetsClientGetEncryptionKeyResponse, error) { req, err := client.getEncryptionKeyCreateRequest(ctx, resourceGroupName, accountName, assetName, options) if err != nil { return AssetsClientGetEncryptionKeyResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssetsClientGetEncryptionKeyResponse{}, err } @@ -273,7 +266,7 @@ func (client *AssetsClient) getEncryptionKeyCreateRequest(ctx context.Context, r return nil, errors.New("parameter assetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assetName}", url.PathEscape(assetName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -294,10 +287,11 @@ func (client *AssetsClient) getEncryptionKeyHandleResponse(resp *http.Response) } // NewListPager - List Assets in the Media Services account with optional filtering and ordering +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// options - AssetsClientListOptions contains the optional parameters for the AssetsClient.List method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - options - AssetsClientListOptions contains the optional parameters for the AssetsClient.NewListPager method. func (client *AssetsClient) NewListPager(resourceGroupName string, accountName string, options *AssetsClientListOptions) *runtime.Pager[AssetsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AssetsClientListResponse]{ More: func(page AssetsClientListResponse) bool { @@ -314,7 +308,7 @@ func (client *AssetsClient) NewListPager(resourceGroupName string, accountName s if err != nil { return AssetsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssetsClientListResponse{}, err } @@ -341,7 +335,7 @@ func (client *AssetsClient) listCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -373,18 +367,19 @@ func (client *AssetsClient) listHandleResponse(resp *http.Response) (AssetsClien // ListContainerSas - Lists storage container URLs with shared access signatures (SAS) for uploading and downloading Asset // content. The signatures are derived from the storage account keys. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// parameters - The request parameters -// options - AssetsClientListContainerSasOptions contains the optional parameters for the AssetsClient.ListContainerSas method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - parameters - The request parameters +// - options - AssetsClientListContainerSasOptions contains the optional parameters for the AssetsClient.ListContainerSas method. func (client *AssetsClient) ListContainerSas(ctx context.Context, resourceGroupName string, accountName string, assetName string, parameters ListContainerSasInput, options *AssetsClientListContainerSasOptions) (AssetsClientListContainerSasResponse, error) { req, err := client.listContainerSasCreateRequest(ctx, resourceGroupName, accountName, assetName, parameters, options) if err != nil { return AssetsClientListContainerSasResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssetsClientListContainerSasResponse{}, err } @@ -413,7 +408,7 @@ func (client *AssetsClient) listContainerSasCreateRequest(ctx context.Context, r return nil, errors.New("parameter assetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assetName}", url.PathEscape(assetName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -435,18 +430,19 @@ func (client *AssetsClient) listContainerSasHandleResponse(resp *http.Response) // ListStreamingLocators - Lists Streaming Locators which are associated with this asset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// options - AssetsClientListStreamingLocatorsOptions contains the optional parameters for the AssetsClient.ListStreamingLocators -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - options - AssetsClientListStreamingLocatorsOptions contains the optional parameters for the AssetsClient.ListStreamingLocators +// method. func (client *AssetsClient) ListStreamingLocators(ctx context.Context, resourceGroupName string, accountName string, assetName string, options *AssetsClientListStreamingLocatorsOptions) (AssetsClientListStreamingLocatorsResponse, error) { req, err := client.listStreamingLocatorsCreateRequest(ctx, resourceGroupName, accountName, assetName, options) if err != nil { return AssetsClientListStreamingLocatorsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssetsClientListStreamingLocatorsResponse{}, err } @@ -475,7 +471,7 @@ func (client *AssetsClient) listStreamingLocatorsCreateRequest(ctx context.Conte return nil, errors.New("parameter assetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assetName}", url.PathEscape(assetName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -497,18 +493,19 @@ func (client *AssetsClient) listStreamingLocatorsHandleResponse(resp *http.Respo // Update - Updates an existing Asset in the Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// parameters - The request parameters -// options - AssetsClientUpdateOptions contains the optional parameters for the AssetsClient.Update method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - parameters - The request parameters +// - options - AssetsClientUpdateOptions contains the optional parameters for the AssetsClient.Update method. func (client *AssetsClient) Update(ctx context.Context, resourceGroupName string, accountName string, assetName string, parameters Asset, options *AssetsClientUpdateOptions) (AssetsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, assetName, parameters, options) if err != nil { return AssetsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssetsClientUpdateResponse{}, err } @@ -537,7 +534,7 @@ func (client *AssetsClient) updateCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter assetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assetName}", url.PathEscape(assetName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/assets_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/assets_client_example_test.go index d0292b1ff69f..0fff0b45cc1d 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/assets_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/assets_client_example_test.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 armmediaservices_test @@ -19,118 +20,357 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-list-in-date-range.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-list-in-date-range.json func ExampleAssetsClient_NewListPager_listAssetCreatedInADateRange() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contoso", "contosomedia", &armmediaservices.AssetsClientListOptions{Filter: to.Ptr("properties/created gt 2012-06-01 and properties/created lt 2013-07-01"), + pager := clientFactory.NewAssetsClient().NewListPager("contoso", "contosomedia", &armmediaservices.AssetsClientListOptions{Filter: to.Ptr("properties/created gt 2012-06-01 and properties/created lt 2013-07-01"), Top: nil, Orderby: to.Ptr("properties/created"), }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AssetCollection = armmediaservices.AssetCollection{ + // Value: []*armmediaservices.Asset{ + // { + // Name: to.Ptr("ClimbingMountRainier"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainier"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Mount Rainier"), + // AlternateID: to.Ptr("CLIMB00001"), + // AssetID: to.Ptr("f8eea45c-b814-44c2-9c42-a5174ebdee4c"), + // Container: to.Ptr("asset-f8eea45c-b814-44c2-9c42-a5174ebdee4c"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2012-11-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2012-11-01T00:00:00Z"); return t}()), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatNone), + // }, + // }, + // { + // Name: to.Ptr("ClimbingMountAdams"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountAdams"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Mount Adams"), + // AlternateID: to.Ptr("CLIMB00002"), + // AssetID: to.Ptr("1b648c1a-2268-461d-a1da-742bde23db40"), + // Container: to.Ptr("asset-1b648c1a-2268-461d-a1da-742bde23db40"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2013-02-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-11-01T00:00:00Z"); return t}()), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatNone), + // }, + // }, + // { + // Name: to.Ptr("ClimbingMountSaintHelens"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountSaintHelens"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Saint Helens"), + // AlternateID: to.Ptr("CLIMB00005"), + // AssetID: to.Ptr("14d58c40-ec1f-446c-b041-f5cff949bd1d"), + // Container: to.Ptr("asset-14d58c40-ec1f-446c-b041-f5cff949bd1d"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2013-03-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2013-04-01T00:00:00Z"); return t}()), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatMediaStorageClientEncryption), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-list-by-date.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-list-by-date.json func ExampleAssetsClient_NewListPager_listAssetOrderedByDate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contoso", "contosomedia", &armmediaservices.AssetsClientListOptions{Filter: nil, + pager := clientFactory.NewAssetsClient().NewListPager("contoso", "contosomedia", &armmediaservices.AssetsClientListOptions{Filter: nil, Top: nil, Orderby: to.Ptr("properties/created"), }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AssetCollection = armmediaservices.AssetCollection{ + // Value: []*armmediaservices.Asset{ + // { + // Name: to.Ptr("ClimbingMountBaker"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountBaker"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Mount Baker"), + // AlternateID: to.Ptr("CLIMB00004"), + // AssetID: to.Ptr("89af1750-e681-4fbe-8c4c-9a5567867a6b"), + // Container: to.Ptr("asset-89af1750-e681-4fbe-8c4c-9a5567867a6b"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2011-02-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-11-01T00:00:00Z"); return t}()), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatNone), + // }, + // }, + // { + // Name: to.Ptr("ClimbingLittleTahoma"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingLittleTahoma"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Little Tahoma"), + // AlternateID: to.Ptr("CLIMB00003"), + // AssetID: to.Ptr("e6c7ee55-d1f5-48bc-9c36-2d2157aadbbe"), + // Container: to.Ptr("asset-e6c7ee55-d1f5-48bc-9c36-2d2157aadbbe"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2012-04-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-11-01T00:00:00Z"); return t}()), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatNone), + // }, + // }, + // { + // Name: to.Ptr("ClimbingMountRainier"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainier"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Mount Rainier"), + // AlternateID: to.Ptr("CLIMB00001"), + // AssetID: to.Ptr("f8eea45c-b814-44c2-9c42-a5174ebdee4c"), + // Container: to.Ptr("asset-f8eea45c-b814-44c2-9c42-a5174ebdee4c"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2012-11-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2012-11-01T00:00:00Z"); return t}()), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatNone), + // }, + // }, + // { + // Name: to.Ptr("ClimbingMountAdams"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountAdams"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Mount Adams"), + // AlternateID: to.Ptr("CLIMB00002"), + // AssetID: to.Ptr("1b648c1a-2268-461d-a1da-742bde23db40"), + // Container: to.Ptr("asset-1b648c1a-2268-461d-a1da-742bde23db40"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2013-02-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-11-01T00:00:00Z"); return t}()), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatNone), + // }, + // }, + // { + // Name: to.Ptr("ClimbingMountSaintHelens"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountSaintHelens"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Saint Helens"), + // AlternateID: to.Ptr("CLIMB00005"), + // AssetID: to.Ptr("14d58c40-ec1f-446c-b041-f5cff949bd1d"), + // Container: to.Ptr("asset-14d58c40-ec1f-446c-b041-f5cff949bd1d"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2013-03-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2013-04-01T00:00:00Z"); return t}()), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatMediaStorageClientEncryption), + // }, + // }, + // { + // Name: to.Ptr("ClimbingMountRainer"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("descClimbingMountRainer"), + // AlternateID: to.Ptr("altClimbingMountRainer"), + // AssetID: to.Ptr("8cdacfe5-8473-413a-9aec-dd2a478b37c8"), + // Container: to.Ptr("testasset0"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:25.0514734Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T21:29:25.0514734Z"); return t}()), + // StorageAccountName: to.Ptr("storage0"), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatNone), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-list-all.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-list-all.json func ExampleAssetsClient_NewListPager_listAllAssets() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contoso", "contosomedia", &armmediaservices.AssetsClientListOptions{Filter: nil, + pager := clientFactory.NewAssetsClient().NewListPager("contoso", "contosomedia", &armmediaservices.AssetsClientListOptions{Filter: nil, Top: nil, Orderby: nil, }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AssetCollection = armmediaservices.AssetCollection{ + // Value: []*armmediaservices.Asset{ + // { + // Name: to.Ptr("ClimbingLittleTahoma"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingLittleTahoma"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Little Tahoma"), + // AlternateID: to.Ptr("CLIMB00003"), + // AssetID: to.Ptr("e6c7ee55-d1f5-48bc-9c36-2d2157aadbbe"), + // Container: to.Ptr("asset-e6c7ee55-d1f5-48bc-9c36-2d2157aadbbe"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2012-04-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-11-01T00:00:00Z"); return t}()), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatNone), + // }, + // }, + // { + // Name: to.Ptr("ClimbingMountAdams"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountAdams"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Mount Adams"), + // AlternateID: to.Ptr("CLIMB00002"), + // AssetID: to.Ptr("1b648c1a-2268-461d-a1da-742bde23db40"), + // Container: to.Ptr("asset-1b648c1a-2268-461d-a1da-742bde23db40"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2013-02-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-11-01T00:00:00Z"); return t}()), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatNone), + // }, + // }, + // { + // Name: to.Ptr("ClimbingMountBaker"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountBaker"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Mount Baker"), + // AlternateID: to.Ptr("CLIMB00004"), + // AssetID: to.Ptr("89af1750-e681-4fbe-8c4c-9a5567867a6b"), + // Container: to.Ptr("asset-89af1750-e681-4fbe-8c4c-9a5567867a6b"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2011-02-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-11-01T00:00:00Z"); return t}()), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatNone), + // }, + // }, + // { + // Name: to.Ptr("ClimbingMountRainer"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("descClimbingMountRainer"), + // AlternateID: to.Ptr("altClimbingMountRainer"), + // AssetID: to.Ptr("258878ef-fe05-4518-988f-052e86dc19f6"), + // Container: to.Ptr("testasset0"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:24.3948982Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T21:29:24.3948982Z"); return t}()), + // StorageAccountName: to.Ptr("storage0"), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatNone), + // }, + // }, + // { + // Name: to.Ptr("ClimbingMountRainier"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainier"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Mount Rainier"), + // AlternateID: to.Ptr("CLIMB00001"), + // AssetID: to.Ptr("f8eea45c-b814-44c2-9c42-a5174ebdee4c"), + // Container: to.Ptr("asset-f8eea45c-b814-44c2-9c42-a5174ebdee4c"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2012-11-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2012-11-01T00:00:00Z"); return t}()), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatNone), + // }, + // }, + // { + // Name: to.Ptr("ClimbingMountSaintHelens"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountSaintHelens"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Saint Helens"), + // AlternateID: to.Ptr("CLIMB00005"), + // AssetID: to.Ptr("14d58c40-ec1f-446c-b041-f5cff949bd1d"), + // Container: to.Ptr("asset-14d58c40-ec1f-446c-b041-f5cff949bd1d"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2013-03-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2013-04-01T00:00:00Z"); return t}()), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatMediaStorageClientEncryption), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-get-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-get-by-name.json func ExampleAssetsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contoso", "contosomedia", "ClimbingMountAdams", nil) + res, err := clientFactory.NewAssetsClient().Get(ctx, "contoso", "contosomedia", "ClimbingMountAdams", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Asset = armmediaservices.Asset{ + // Name: to.Ptr("ClimbingMountAdams"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountAdams"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Mount Adams"), + // AlternateID: to.Ptr("CLIMB00002"), + // AssetID: to.Ptr("1b648c1a-2268-461d-a1da-742bde23db40"), + // Container: to.Ptr("asset-1b648c1a-2268-461d-a1da-742bde23db40"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2013-02-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-11-01T00:00:00Z"); return t}()), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatNone), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-create.json func ExampleAssetsClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "contoso", "contosomedia", "ClimbingMountLogan", armmediaservices.Asset{ + res, err := clientFactory.NewAssetsClient().CreateOrUpdate(ctx, "contoso", "contosomedia", "ClimbingMountLogan", armmediaservices.Asset{ Properties: &armmediaservices.AssetProperties{ Description: to.Ptr("A documentary showing the ascent of Mount Logan"), StorageAccountName: to.Ptr("storage0"), @@ -139,39 +379,54 @@ func ExampleAssetsClient_CreateOrUpdate() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Asset = armmediaservices.Asset{ + // Name: to.Ptr("ClimbingMountLogan"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountLogan"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Mount Logan"), + // AssetID: to.Ptr("09194258-36ba-4403-abb3-68780e6bc545"), + // Container: to.Ptr("asset-09194258-36ba-4403-abb3-68780e6bc545"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:26.08Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:26.107Z"); return t}()), + // StorageAccountName: to.Ptr("storage0"), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatNone), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-delete.json func ExampleAssetsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "contoso", "contosomedia", "ClimbingMountAdams", nil) + _, err = clientFactory.NewAssetsClient().Delete(ctx, "contoso", "contosomedia", "ClimbingMountAdams", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-update.json func ExampleAssetsClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "contoso", "contosomedia", "ClimbingMountBaker", armmediaservices.Asset{ + res, err := clientFactory.NewAssetsClient().Update(ctx, "contoso", "contosomedia", "ClimbingMountBaker", armmediaservices.Asset{ Properties: &armmediaservices.AssetProperties{ Description: to.Ptr("A documentary showing the ascent of Mount Baker in HD"), }, @@ -179,66 +434,127 @@ func ExampleAssetsClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Asset = armmediaservices.Asset{ + // Name: to.Ptr("ClimbingMountBaker"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountBaker"), + // Properties: &armmediaservices.AssetProperties{ + // Description: to.Ptr("A documentary showing the ascent of Mount Baker in HD"), + // AlternateID: to.Ptr("CLIMB00004"), + // AssetID: to.Ptr("89af1750-e681-4fbe-8c4c-9a5567867a6b"), + // Container: to.Ptr("asset-89af1750-e681-4fbe-8c4c-9a5567867a6b"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2011-02-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:26.503Z"); return t}()), + // StorageEncryptionFormat: to.Ptr(armmediaservices.AssetStorageEncryptionFormatNone), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-list-sas-urls.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-list-sas-urls.json func ExampleAssetsClient_ListContainerSas() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListContainerSas(ctx, "contoso", "contosomedia", "ClimbingMountBaker", armmediaservices.ListContainerSasInput{ + res, err := clientFactory.NewAssetsClient().ListContainerSas(ctx, "contoso", "contosomedia", "ClimbingMountBaker", armmediaservices.ListContainerSasInput{ ExpiryTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T10:00:00.007Z"); return t }()), Permissions: to.Ptr(armmediaservices.AssetContainerPermissionReadWrite), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AssetContainerSas = armmediaservices.AssetContainerSas{ + // AssetContainerSasUrls: []*string{ + // to.Ptr("https://storage0.blob.core.windows.net/asset-89af1750-e681-4fbe-8c4c-9a5567867a6b?sr=b&sig=&se=2018-01-01T10:00:00Z&sp=lrw"), + // to.Ptr("https://storage0.blob.core.windows.net/asset-89af1750-e681-4fbe-8c4c-9a5567867a6b?sr=b&sig=&se=2018-01-01T10:00:00Z&sp=lrw")}, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-get-encryption-keys.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-get-encryption-keys.json func ExampleAssetsClient_GetEncryptionKey() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GetEncryptionKey(ctx, "contoso", "contosomedia", "ClimbingMountSaintHelens", nil) + res, err := clientFactory.NewAssetsClient().GetEncryptionKey(ctx, "contoso", "contosomedia", "ClimbingMountSaintHelens", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.StorageEncryptedAssetDecryptionData = armmediaservices.StorageEncryptedAssetDecryptionData{ + // AssetFileEncryptionMetadata: []*armmediaservices.AssetFileEncryptionMetadata{ + // { + // AssetFileID: to.Ptr("a9536fa7-bd5d-4f84-a137-d1290982fe95"), + // AssetFileName: to.Ptr("AssetFile0"), + // InitializationVector: to.Ptr("-988929866"), + // }, + // { + // AssetFileID: to.Ptr("f4060046-94ac-422d-824c-3f1d6aa3ecf2"), + // AssetFileName: to.Ptr("AssetFile1"), + // InitializationVector: to.Ptr("1604993689"), + // }, + // { + // AssetFileID: to.Ptr("485968d3-ddae-4b13-98e7-901201a9620b"), + // AssetFileName: to.Ptr("AssetFile2"), + // InitializationVector: to.Ptr("100082635"), + // }}, + // Key: []byte("AAAAAAAAAAAAAAAAAAAAAA=="), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-list-streaming-locators.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/assets-list-streaming-locators.json func ExampleAssetsClient_ListStreamingLocators() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListStreamingLocators(ctx, "contoso", "contosomedia", "ClimbingMountSaintHelens", nil) + res, err := clientFactory.NewAssetsClient().ListStreamingLocators(ctx, "contoso", "contosomedia", "ClimbingMountSaintHelens", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ListStreamingLocatorsResponse = armmediaservices.ListStreamingLocatorsResponse{ + // StreamingLocators: []*armmediaservices.AssetStreamingLocator{ + // { + // Name: to.Ptr("secureStreamingLocator"), + // AssetName: to.Ptr("ClimbingMountSaintHelens"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:26.9729344Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "9999-12-31T23:59:59.9999999Z"); return t}()), + // StreamingLocatorID: to.Ptr("36b74ce3-20b4-4de0-84f1-97e9138e886c"), + // StreamingPolicyName: to.Ptr("secureStreamingPolicy"), + // }, + // { + // Name: to.Ptr("clearStreamingLocator"), + // AssetName: to.Ptr("ClimbingMountSaintHelens"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:26.9487636Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "9999-12-31T23:59:59.9999999Z"); return t}()), + // StreamingLocatorID: to.Ptr("3e8d9ac3-50f6-4f6d-8482-078ceb56f23a"), + // StreamingPolicyName: to.Ptr("clearStreamingPolicy"), + // }}, + // } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationresults_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationresults_client.go index 5112c1fc2a74..90c8e326e0cb 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationresults_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationresults_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,51 +25,43 @@ import ( // AssetTrackOperationResultsClient contains the methods for the AssetTrackOperationResults group. // Don't use this type directly, use NewAssetTrackOperationResultsClient() instead. type AssetTrackOperationResultsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAssetTrackOperationResultsClient creates a new instance of AssetTrackOperationResultsClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAssetTrackOperationResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssetTrackOperationResultsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AssetTrackOperationResultsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AssetTrackOperationResultsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get asset track operation result. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// trackName - The Asset Track name. -// operationID - Operation Id. -// options - AssetTrackOperationResultsClientGetOptions contains the optional parameters for the AssetTrackOperationResultsClient.Get -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - trackName - The Asset Track name. +// - operationID - Operation Id. +// - options - AssetTrackOperationResultsClientGetOptions contains the optional parameters for the AssetTrackOperationResultsClient.Get +// method. func (client *AssetTrackOperationResultsClient) Get(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, operationID string, options *AssetTrackOperationResultsClientGetOptions) (AssetTrackOperationResultsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, assetName, trackName, operationID, options) if err != nil { return AssetTrackOperationResultsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssetTrackOperationResultsClientGetResponse{}, err } @@ -108,7 +98,7 @@ func (client *AssetTrackOperationResultsClient) getCreateRequest(ctx context.Con return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationresults_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationresults_client_example_test.go index cf9e72c8eb3a..a9b13c0f4edc 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationresults_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationresults_client_example_test.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 armmediaservices_test @@ -16,21 +17,36 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-operation-result-by-id.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-operation-result-by-id.json func ExampleAssetTrackOperationResultsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetTrackOperationResultsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text1", "e78f8d40-7aaa-4f2f-8ae6-73987e7c5a08", nil) + res, err := clientFactory.NewAssetTrackOperationResultsClient().Get(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text1", "e78f8d40-7aaa-4f2f-8ae6-73987e7c5a08", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AssetTrack = armmediaservices.AssetTrack{ + // Name: to.Ptr("text1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets/tracks/operationResults"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/tracks/text1/operationResults/e78f8d40-7aaa-4f2f-8ae6-73987e7c5a08"), + // Properties: &armmediaservices.AssetTrackProperties{ + // ProvisioningState: to.Ptr(armmediaservices.ProvisioningStateSucceeded), + // Track: &armmediaservices.TextTrack{ + // ODataType: to.Ptr("#Microsoft.Media.TextTrack"), + // DisplayName: to.Ptr("Auto generated"), + // LanguageCode: to.Ptr("en-us"), + // PlayerVisibility: to.Ptr(armmediaservices.VisibilityVisible), + // }, + // }, + // } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationstatuses_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationstatuses_client.go index b0b154abc42e..9337d547d34c 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationstatuses_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationstatuses_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,51 +24,43 @@ import ( // AssetTrackOperationStatusesClient contains the methods for the AssetTrackOperationStatuses group. // Don't use this type directly, use NewAssetTrackOperationStatusesClient() instead. type AssetTrackOperationStatusesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAssetTrackOperationStatusesClient creates a new instance of AssetTrackOperationStatusesClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAssetTrackOperationStatusesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssetTrackOperationStatusesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AssetTrackOperationStatusesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AssetTrackOperationStatusesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get asset track operation status. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// trackName - The Asset Track name. -// operationID - Operation Id. -// options - AssetTrackOperationStatusesClientGetOptions contains the optional parameters for the AssetTrackOperationStatusesClient.Get -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - trackName - The Asset Track name. +// - operationID - Operation Id. +// - options - AssetTrackOperationStatusesClientGetOptions contains the optional parameters for the AssetTrackOperationStatusesClient.Get +// method. func (client *AssetTrackOperationStatusesClient) Get(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, operationID string, options *AssetTrackOperationStatusesClientGetOptions) (AssetTrackOperationStatusesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, assetName, trackName, operationID, options) if err != nil { return AssetTrackOperationStatusesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssetTrackOperationStatusesClientGetResponse{}, err } @@ -107,7 +97,7 @@ func (client *AssetTrackOperationStatusesClient) getCreateRequest(ctx context.Co return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationstatuses_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationstatuses_client_example_test.go index 41137f0c8e50..07965baf5cc7 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationstatuses_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/assettrackoperationstatuses_client_example_test.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 armmediaservices_test @@ -16,59 +17,86 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-operation-status-by-id-terminal-state-failed.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-operation-status-by-id-terminal-state-failed.json func ExampleAssetTrackOperationStatusesClient_Get_getStatusOfAsynchronousOperationWhenItIsCompletedWithError() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetTrackOperationStatusesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text1", "86835197-3b47-402e-b313-70b82eaba296", nil) + res, err := clientFactory.NewAssetTrackOperationStatusesClient().Get(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text1", "86835197-3b47-402e-b313-70b82eaba296", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AssetTrackOperationStatus = armmediaservices.AssetTrackOperationStatus{ + // Name: to.Ptr("86835197-3b47-402e-b313-70b82eaba296"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:30Z"); return t}()), + // Error: &armmediaservices.ErrorDetail{ + // Code: to.Ptr("ClientError"), + // Message: to.Ptr("Error while parsing WEBVTT file and creating CMFT header."), + // }, + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/tracks/text1/operationStatuses/86835197-3b47-402e-b313-70b82eaba296"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00Z"); return t}()), + // Status: to.Ptr("Failed"), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-operation-status-by-id-terminal-state.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-operation-status-by-id-terminal-state.json func ExampleAssetTrackOperationStatusesClient_Get_getStatusOfAsynchronousOperationWhenItIsCompleted() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetTrackOperationStatusesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text1", "e78f8d40-7aaa-4f2f-8ae6-73987e7c5a08", nil) + res, err := clientFactory.NewAssetTrackOperationStatusesClient().Get(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text1", "e78f8d40-7aaa-4f2f-8ae6-73987e7c5a08", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AssetTrackOperationStatus = armmediaservices.AssetTrackOperationStatus{ + // Name: to.Ptr("e78f8d40-7aaa-4f2f-8ae6-73987e7c5a08"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:30Z"); return t}()), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/tracks/text1/operationStatuses/e78f8d40-7aaa-4f2f-8ae6-73987e7c5a08"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00Z"); return t}()), + // Status: to.Ptr("Succeeded"), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-operation-status-by-id-non-terminal-state.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-operation-status-by-id-non-terminal-state.json func ExampleAssetTrackOperationStatusesClient_Get_getStatusOfAsynchronousOperationWhenItIsOngoing() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewAssetTrackOperationStatusesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text1", "5827d9a1-1fb4-4e54-ac40-8eeed9b862c8", nil) + res, err := clientFactory.NewAssetTrackOperationStatusesClient().Get(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text1", "5827d9a1-1fb4-4e54-ac40-8eeed9b862c8", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AssetTrackOperationStatus = armmediaservices.AssetTrackOperationStatus{ + // Name: to.Ptr("5827d9a1-1fb4-4e54-ac40-8eeed9b862c8"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/tracks/text1/operationStatuses/5827d9a1-1fb4-4e54-ac40-8eeed9b862c8"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00Z"); return t}()), + // Status: to.Ptr("InProgress"), + // } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/autorest.md b/sdk/resourcemanager/mediaservices/armmediaservices/autorest.md index 9b1a90e57325..d47a0fca7362 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/autorest.md +++ b/sdk/resourcemanager/mediaservices/armmediaservices/autorest.md @@ -8,5 +8,5 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 3.2.0 +module-version: 3.3.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/client.go b/sdk/resourcemanager/mediaservices/armmediaservices/client.go index 670ef5004345..5574c0a011d3 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,63 +24,56 @@ import ( // Client contains the methods for the Mediaservices group. // Don't use this type directly, use NewClient() instead. type Client struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewClient creates a new instance of Client with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".Client", moduleVersion, credential, options) if err != nil { return nil, err } client := &Client{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// parameters - The request parameters -// options - ClientBeginCreateOrUpdateOptions contains the optional parameters for the Client.BeginCreateOrUpdate method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - parameters - The request parameters +// - options - ClientBeginCreateOrUpdateOptions contains the optional parameters for the Client.BeginCreateOrUpdate method. func (client *Client) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, parameters MediaService, options *ClientBeginCreateOrUpdateOptions) (*runtime.Poller[ClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, accountName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[ClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[ClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 func (client *Client) createOrUpdate(ctx context.Context, resourceGroupName string, accountName string, parameters MediaService, options *ClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -107,7 +98,7 @@ func (client *Client) createOrUpdateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -120,16 +111,17 @@ func (client *Client) createOrUpdateCreateRequest(ctx context.Context, resourceG // Delete - Deletes a Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// options - ClientDeleteOptions contains the optional parameters for the Client.Delete method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - options - ClientDeleteOptions contains the optional parameters for the Client.Delete method. func (client *Client) Delete(ctx context.Context, resourceGroupName string, accountName string, options *ClientDeleteOptions) (ClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return ClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientDeleteResponse{}, err } @@ -154,7 +146,7 @@ func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -167,16 +159,17 @@ func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName // Get - Get the details of a Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// options - ClientGetOptions contains the optional parameters for the Client.Get method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - options - ClientGetOptions contains the optional parameters for the Client.Get method. func (client *Client) Get(ctx context.Context, resourceGroupName string, accountName string, options *ClientGetOptions) (ClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return ClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientGetResponse{}, err } @@ -201,7 +194,7 @@ func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName st return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -222,9 +215,10 @@ func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, } // NewListPager - List Media Services accounts in the resource group +// // Generated from API version 2021-11-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// options - ClientListOptions contains the optional parameters for the Client.List method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - options - ClientListOptions contains the optional parameters for the Client.NewListPager method. func (client *Client) NewListPager(resourceGroupName string, options *ClientListOptions) *runtime.Pager[ClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ClientListResponse]{ More: func(page ClientListResponse) bool { @@ -241,7 +235,7 @@ func (client *Client) NewListPager(resourceGroupName string, options *ClientList if err != nil { return ClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientListResponse{}, err } @@ -264,7 +258,7 @@ func (client *Client) listCreateRequest(ctx context.Context, resourceGroupName s return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -285,8 +279,9 @@ func (client *Client) listHandleResponse(resp *http.Response) (ClientListRespons } // NewListBySubscriptionPager - List Media Services accounts in the subscription. +// // Generated from API version 2021-11-01 -// options - ClientListBySubscriptionOptions contains the optional parameters for the Client.ListBySubscription method. +// - options - ClientListBySubscriptionOptions contains the optional parameters for the Client.NewListBySubscriptionPager method. func (client *Client) NewListBySubscriptionPager(options *ClientListBySubscriptionOptions) *runtime.Pager[ClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[ClientListBySubscriptionResponse]{ More: func(page ClientListBySubscriptionResponse) bool { @@ -303,7 +298,7 @@ func (client *Client) NewListBySubscriptionPager(options *ClientListBySubscripti if err != nil { return ClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientListBySubscriptionResponse{}, err } @@ -322,7 +317,7 @@ func (client *Client) listBySubscriptionCreateRequest(ctx context.Context, optio return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -344,17 +339,18 @@ func (client *Client) listBySubscriptionHandleResponse(resp *http.Response) (Cli // ListEdgePolicies - List all the media edge policies associated with the Media Services account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// parameters - The request parameters -// options - ClientListEdgePoliciesOptions contains the optional parameters for the Client.ListEdgePolicies method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - parameters - The request parameters +// - options - ClientListEdgePoliciesOptions contains the optional parameters for the Client.ListEdgePolicies method. func (client *Client) ListEdgePolicies(ctx context.Context, resourceGroupName string, accountName string, parameters ListEdgePoliciesInput, options *ClientListEdgePoliciesOptions) (ClientListEdgePoliciesResponse, error) { req, err := client.listEdgePoliciesCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { return ClientListEdgePoliciesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientListEdgePoliciesResponse{}, err } @@ -379,7 +375,7 @@ func (client *Client) listEdgePoliciesCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -401,17 +397,18 @@ func (client *Client) listEdgePoliciesHandleResponse(resp *http.Response) (Clien // SyncStorageKeys - Synchronizes storage account keys for a storage account associated with the Media Service account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// parameters - The request parameters -// options - ClientSyncStorageKeysOptions contains the optional parameters for the Client.SyncStorageKeys method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - parameters - The request parameters +// - options - ClientSyncStorageKeysOptions contains the optional parameters for the Client.SyncStorageKeys method. func (client *Client) SyncStorageKeys(ctx context.Context, resourceGroupName string, accountName string, parameters SyncStorageKeysInput, options *ClientSyncStorageKeysOptions) (ClientSyncStorageKeysResponse, error) { req, err := client.syncStorageKeysCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { return ClientSyncStorageKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientSyncStorageKeysResponse{}, err } @@ -436,7 +433,7 @@ func (client *Client) syncStorageKeysCreateRequest(ctx context.Context, resource return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -449,32 +446,34 @@ func (client *Client) syncStorageKeysCreateRequest(ctx context.Context, resource // BeginUpdate - Updates an existing Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// parameters - The request parameters -// options - ClientBeginUpdateOptions contains the optional parameters for the Client.BeginUpdate method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - parameters - The request parameters +// - options - ClientBeginUpdateOptions contains the optional parameters for the Client.BeginUpdate method. func (client *Client) BeginUpdate(ctx context.Context, resourceGroupName string, accountName string, parameters MediaServiceUpdate, options *ClientBeginUpdateOptions) (*runtime.Poller[ClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, accountName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[ClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[ClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates an existing Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 func (client *Client) update(ctx context.Context, resourceGroupName string, accountName string, parameters MediaServiceUpdate, options *ClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -499,7 +498,7 @@ func (client *Client) updateCreateRequest(ctx context.Context, resourceGroupName return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/client_example_test.go index eaedef2ccdfb..ad8be4cc0bc9 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/client_example_test.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 armmediaservices_test @@ -17,61 +18,277 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/accounts-list-all-accounts.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/accounts-list-all-accounts.json func ExampleClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contoso", nil) + pager := clientFactory.NewClient().NewListPager("contoso", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.MediaServiceCollection = armmediaservices.MediaServiceCollection{ + // Value: []*armmediaservices.MediaService{ + // { + // Name: to.Ptr("contosotv"), + // Type: to.Ptr("Microsoft.Media/mediaservices"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosotv"), + // Location: to.Ptr("South Central US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Identity: &armmediaservices.MediaServiceIdentity{ + // Type: to.Ptr("UserAssigned"), + // UserAssignedIdentities: map[string]*armmediaservices.UserAssignedManagedIdentity{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armmediaservices.UserAssignedManagedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2": &armmediaservices.UserAssignedManagedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armmediaservices.MediaServiceProperties{ + // Encryption: &armmediaservices.AccountEncryption{ + // Type: to.Ptr(armmediaservices.AccountEncryptionKeyTypeCustomerKey), + // Identity: &armmediaservices.ResourceIdentity{ + // UseSystemAssignedIdentity: to.Ptr(false), + // UserAssignedIdentity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), + // }, + // KeyVaultProperties: &armmediaservices.KeyVaultProperties{ + // CurrentKeyIdentifier: to.Ptr("https://keyvault.vault.azure.net/keys/key1/ver1"), + // KeyIdentifier: to.Ptr("https://keyvault.vault.azure.net/keys/key1"), + // }, + // }, + // KeyDelivery: &armmediaservices.KeyDelivery{ + // AccessControl: &armmediaservices.AccessControl{ + // DefaultAction: to.Ptr(armmediaservices.DefaultActionAllow), + // }, + // }, + // MediaServiceID: to.Ptr("6ac94f91-283c-4492-85a7-57976928c17d"), + // PrivateEndpointConnections: []*armmediaservices.PrivateEndpointConnection{ + // { + // Name: to.Ptr("00000000-0000-0000-0000-000000000001"), + // Type: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosotv/privateEndpointConnections/00000000-0000-0000-0000-000000000001"), + // Properties: &armmediaservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmediaservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/reosuceGroup1/providers/Microsoft.Network/privateEndpoints/pe1"), + // }, + // PrivateLinkServiceConnectionState: &armmediaservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("test description"), + // Status: to.Ptr(armmediaservices.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armmediaservices.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }, + // { + // Name: to.Ptr("00000000-0000-0000-0000-000000000002"), + // Type: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosotv/privateEndpointConnections/00000000-0000-0000-0000-000000000002"), + // Properties: &armmediaservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmediaservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/22222222-2222-2222-2222-222222222222/resourceGroups/reosuceGroup2/providers/Microsoft.Network/privateEndpoints/pe2"), + // }, + // PrivateLinkServiceConnectionState: &armmediaservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("test description"), + // Status: to.Ptr(armmediaservices.PrivateEndpointServiceConnectionStatusPending), + // }, + // ProvisioningState: to.Ptr(armmediaservices.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }}, + // PublicNetworkAccess: to.Ptr(armmediaservices.PublicNetworkAccessEnabled), + // StorageAccounts: []*armmediaservices.StorageAccount{ + // { + // Type: to.Ptr(armmediaservices.StorageAccountTypePrimary), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Storage/storageAccounts/contosotvstore"), + // }}, + // StorageAuthentication: to.Ptr(armmediaservices.StorageAuthenticationManagedIdentity), + // }, + // }, + // { + // Name: to.Ptr("contosomovies"), + // Type: to.Ptr("Microsoft.Media/mediaservices"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomovies"), + // Location: to.Ptr("South Central US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Identity: &armmediaservices.MediaServiceIdentity{ + // Type: to.Ptr("UserAssigned"), + // UserAssignedIdentities: map[string]*armmediaservices.UserAssignedManagedIdentity{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armmediaservices.UserAssignedManagedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2": &armmediaservices.UserAssignedManagedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armmediaservices.MediaServiceProperties{ + // Encryption: &armmediaservices.AccountEncryption{ + // Type: to.Ptr(armmediaservices.AccountEncryptionKeyTypeCustomerKey), + // Identity: &armmediaservices.ResourceIdentity{ + // UseSystemAssignedIdentity: to.Ptr(false), + // UserAssignedIdentity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), + // }, + // KeyVaultProperties: &armmediaservices.KeyVaultProperties{ + // CurrentKeyIdentifier: to.Ptr("https://keyvault.vault.azure.net/keys/key1/ver1"), + // KeyIdentifier: to.Ptr("https://keyvault.vault.azure.net/keys/key1"), + // }, + // }, + // KeyDelivery: &armmediaservices.KeyDelivery{ + // AccessControl: &armmediaservices.AccessControl{ + // DefaultAction: to.Ptr(armmediaservices.DefaultActionAllow), + // }, + // }, + // MediaServiceID: to.Ptr("72681c0f-9dd1-4f1c-95c9-8a8d7d31c4ee"), + // PrivateEndpointConnections: []*armmediaservices.PrivateEndpointConnection{ + // }, + // PublicNetworkAccess: to.Ptr(armmediaservices.PublicNetworkAccessEnabled), + // StorageAccounts: []*armmediaservices.StorageAccount{ + // { + // Type: to.Ptr(armmediaservices.StorageAccountTypePrimary), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Storage/storageAccounts/contosomoviesstore"), + // }}, + // StorageAuthentication: to.Ptr(armmediaservices.StorageAuthenticationManagedIdentity), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/accounts-get-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/accounts-get-by-name.json func ExampleClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contoso", "contosotv", nil) + res, err := clientFactory.NewClient().Get(ctx, "contoso", "contosotv", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.MediaService = armmediaservices.MediaService{ + // Location: to.Ptr("South Central US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Identity: &armmediaservices.MediaServiceIdentity{ + // Type: to.Ptr("UserAssigned"), + // UserAssignedIdentities: map[string]*armmediaservices.UserAssignedManagedIdentity{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armmediaservices.UserAssignedManagedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2": &armmediaservices.UserAssignedManagedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armmediaservices.MediaServiceProperties{ + // Encryption: &armmediaservices.AccountEncryption{ + // Type: to.Ptr(armmediaservices.AccountEncryptionKeyTypeCustomerKey), + // Identity: &armmediaservices.ResourceIdentity{ + // UseSystemAssignedIdentity: to.Ptr(false), + // UserAssignedIdentity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), + // }, + // KeyVaultProperties: &armmediaservices.KeyVaultProperties{ + // CurrentKeyIdentifier: to.Ptr("https://keyvault.vault.azure.net/keys/key1/ver1"), + // KeyIdentifier: to.Ptr("https://keyvault.vault.azure.net/keys/key1"), + // }, + // }, + // KeyDelivery: &armmediaservices.KeyDelivery{ + // AccessControl: &armmediaservices.AccessControl{ + // DefaultAction: to.Ptr(armmediaservices.DefaultActionAllow), + // }, + // }, + // PrivateEndpointConnections: []*armmediaservices.PrivateEndpointConnection{ + // { + // Name: to.Ptr("00000000-0000-0000-0000-000000000001"), + // Type: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosotv/privateEndpointConnections/00000000-0000-0000-0000-000000000001"), + // Properties: &armmediaservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmediaservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/reosuceGroup1/providers/Microsoft.Network/privateEndpoints/pe1"), + // }, + // PrivateLinkServiceConnectionState: &armmediaservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("test description"), + // Status: to.Ptr(armmediaservices.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armmediaservices.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }, + // { + // Name: to.Ptr("00000000-0000-0000-0000-000000000002"), + // Type: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosotv/privateEndpointConnections/00000000-0000-0000-0000-000000000002"), + // Properties: &armmediaservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmediaservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/22222222-2222-2222-2222-222222222222/resourceGroups/reosuceGroup2/providers/Microsoft.Network/privateEndpoints/pe2"), + // }, + // PrivateLinkServiceConnectionState: &armmediaservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("test description"), + // Status: to.Ptr(armmediaservices.PrivateEndpointServiceConnectionStatusPending), + // }, + // ProvisioningState: to.Ptr(armmediaservices.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }}, + // PublicNetworkAccess: to.Ptr(armmediaservices.PublicNetworkAccessEnabled), + // StorageAccounts: []*armmediaservices.StorageAccount{ + // { + // Type: to.Ptr(armmediaservices.StorageAccountTypePrimary), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Storage/storageAccounts/contososportsstore"), + // Identity: &armmediaservices.ResourceIdentity{ + // UseSystemAssignedIdentity: to.Ptr(false), + // UserAssignedIdentity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), + // }, + // }}, + // StorageAuthentication: to.Ptr(armmediaservices.StorageAuthenticationManagedIdentity), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/async-accounts-create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/async-accounts-create.json func ExampleClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "contoso", "contososports", armmediaservices.MediaService{ + poller, err := clientFactory.NewClient().BeginCreateOrUpdate(ctx, "contoso", "contososports", armmediaservices.MediaService{ Location: to.Ptr("South Central US"), Tags: map[string]*string{ "key1": to.Ptr("value1"), @@ -117,39 +334,117 @@ func ExampleClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.MediaService = armmediaservices.MediaService{ + // Location: to.Ptr("South Central US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Identity: &armmediaservices.MediaServiceIdentity{ + // Type: to.Ptr("UserAssigned"), + // UserAssignedIdentities: map[string]*armmediaservices.UserAssignedManagedIdentity{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armmediaservices.UserAssignedManagedIdentity{ + // }, + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2": &armmediaservices.UserAssignedManagedIdentity{ + // }, + // }, + // }, + // Properties: &armmediaservices.MediaServiceProperties{ + // Encryption: &armmediaservices.AccountEncryption{ + // Type: to.Ptr(armmediaservices.AccountEncryptionKeyTypeCustomerKey), + // Identity: &armmediaservices.ResourceIdentity{ + // UseSystemAssignedIdentity: to.Ptr(false), + // UserAssignedIdentity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), + // }, + // KeyVaultProperties: &armmediaservices.KeyVaultProperties{ + // CurrentKeyIdentifier: to.Ptr("https://keyvault.vault.azure.net/keys/key1/ver1"), + // KeyIdentifier: to.Ptr("https://keyvault.vault.azure.net/keys/key1"), + // }, + // }, + // KeyDelivery: &armmediaservices.KeyDelivery{ + // AccessControl: &armmediaservices.AccessControl{ + // DefaultAction: to.Ptr(armmediaservices.DefaultActionAllow), + // }, + // }, + // PrivateEndpointConnections: []*armmediaservices.PrivateEndpointConnection{ + // { + // Name: to.Ptr("00000000-0000-0000-0000-000000000001"), + // Type: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contososports/privateEndpointConnections/00000000-0000-0000-0000-000000000001"), + // Properties: &armmediaservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmediaservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/reosuceGroup1/providers/Microsoft.Network/privateEndpoints/pe1"), + // }, + // PrivateLinkServiceConnectionState: &armmediaservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("test description"), + // Status: to.Ptr(armmediaservices.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armmediaservices.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }, + // { + // Name: to.Ptr("00000000-0000-0000-0000-000000000002"), + // Type: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contososports/privateEndpointConnections/00000000-0000-0000-0000-000000000002"), + // Properties: &armmediaservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmediaservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/22222222-2222-2222-2222-222222222222/resourceGroups/reosuceGroup2/providers/Microsoft.Network/privateEndpoints/pe2"), + // }, + // PrivateLinkServiceConnectionState: &armmediaservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("test description"), + // Status: to.Ptr(armmediaservices.PrivateEndpointServiceConnectionStatusPending), + // }, + // ProvisioningState: to.Ptr(armmediaservices.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }}, + // ProvisioningState: to.Ptr(armmediaservices.ProvisioningStateSucceeded), + // PublicNetworkAccess: to.Ptr(armmediaservices.PublicNetworkAccessEnabled), + // StorageAccounts: []*armmediaservices.StorageAccount{ + // { + // Type: to.Ptr(armmediaservices.StorageAccountTypePrimary), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Storage/storageAccounts/contososportsstore"), + // Identity: &armmediaservices.ResourceIdentity{ + // UseSystemAssignedIdentity: to.Ptr(false), + // UserAssignedIdentity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), + // }, + // }}, + // StorageAuthentication: to.Ptr(armmediaservices.StorageAuthenticationManagedIdentity), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/accounts-delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/accounts-delete.json func ExampleClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "contoso", "contososports", nil) + _, err = clientFactory.NewClient().Delete(ctx, "contoso", "contososports", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/async-accounts-update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/async-accounts-update.json func ExampleClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "contoso", "contososports", armmediaservices.MediaServiceUpdate{ + poller, err := clientFactory.NewClient().BeginUpdate(ctx, "contoso", "contososports", armmediaservices.MediaServiceUpdate{ Tags: map[string]*string{ "key1": to.Ptr("value3"), }, @@ -163,18 +458,18 @@ func ExampleClient_BeginUpdate() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/accounts-sync-storage-keys.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/accounts-sync-storage-keys.json func ExampleClient_SyncStorageKeys() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.SyncStorageKeys(ctx, "contoso", "contososports", armmediaservices.SyncStorageKeysInput{ + _, err = clientFactory.NewClient().SyncStorageKeys(ctx, "contoso", "contososports", armmediaservices.SyncStorageKeysInput{ ID: to.Ptr("contososportsstore"), }, nil) if err != nil { @@ -182,47 +477,124 @@ func ExampleClient_SyncStorageKeys() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/accounts-list-media-edge-policies.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/accounts-list-media-edge-policies.json func ExampleClient_ListEdgePolicies() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListEdgePolicies(ctx, "contoso", "contososports", armmediaservices.ListEdgePoliciesInput{ + res, err := clientFactory.NewClient().ListEdgePolicies(ctx, "contoso", "contososports", armmediaservices.ListEdgePoliciesInput{ DeviceID: to.Ptr("contosiothubhost_contosoiotdevice"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.EdgePolicies = armmediaservices.EdgePolicies{ + // UsageDataCollectionPolicy: &armmediaservices.EdgeUsageDataCollectionPolicy{ + // DataCollectionFrequency: to.Ptr("PT10M"), + // DataReportingFrequency: to.Ptr("PT1H"), + // EventHubDetails: &armmediaservices.EdgeUsageDataEventHub{ + // Name: to.Ptr("ams-x"), + // Namespace: to.Ptr("ams-y-1-1"), + // Token: to.Ptr("SharedAccessSignature sr=sb%3a%2f%2fams-x.servicebus.windows.net%2fams-y-1-1%2fPublishers%2f96a510a1-0565-492a-a67f-83d1aed1d1f6_SampleDeviceId&sig=signature_value%3d&se=1584073736&skn=EdgeUsageData"), + // }, + // MaxAllowedUnreportedUsageDuration: to.Ptr("PT36H"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/accounts-subscription-list-all-accounts.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/accounts-subscription-list-all-accounts.json func ExampleClient_NewListBySubscriptionPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySubscriptionPager(nil) + pager := clientFactory.NewClient().NewListBySubscriptionPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.MediaServiceCollection = armmediaservices.MediaServiceCollection{ + // Value: []*armmediaservices.MediaService{ + // { + // Name: to.Ptr("contosotv"), + // Type: to.Ptr("Microsoft.Media/mediaservices"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosotv"), + // Location: to.Ptr("South Central US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armmediaservices.MediaServiceProperties{ + // MediaServiceID: to.Ptr("6ac94f91-283c-4492-85a7-57976928c17d"), + // PrivateEndpointConnections: []*armmediaservices.PrivateEndpointConnection{ + // }, + // StorageAccounts: []*armmediaservices.StorageAccount{ + // { + // Type: to.Ptr(armmediaservices.StorageAccountTypePrimary), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Storage/storageAccounts/contosotvstore"), + // }}, + // }, + // }, + // { + // Name: to.Ptr("contosomovies"), + // Type: to.Ptr("Microsoft.Media/mediaservices"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomovies"), + // Location: to.Ptr("South Central US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armmediaservices.MediaServiceProperties{ + // MediaServiceID: to.Ptr("72681c0f-9dd1-4f1c-95c9-8a8d7d31c4ee"), + // PrivateEndpointConnections: []*armmediaservices.PrivateEndpointConnection{ + // }, + // StorageAccounts: []*armmediaservices.StorageAccount{ + // { + // Type: to.Ptr(armmediaservices.StorageAccountTypePrimary), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Storage/storageAccounts/contosomoviesstore"), + // }}, + // }, + // }, + // { + // Name: to.Ptr("fabrikamnews"), + // Type: to.Ptr("Microsoft.Media/mediaservices"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/fabrikamnews"), + // Location: to.Ptr("East US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armmediaservices.MediaServiceProperties{ + // MediaServiceID: to.Ptr("d96036f9-4e37-491d-8c29-5bc53a29dfcd"), + // PrivateEndpointConnections: []*armmediaservices.PrivateEndpointConnection{ + // }, + // StorageAccounts: []*armmediaservices.StorageAccount{ + // { + // Type: to.Ptr(armmediaservices.StorageAccountTypePrimary), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fabrikam/providers/Microsoft.Storage/storageAccounts/fabrikamnewsstore"), + // }}, + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/client_factory.go b/sdk/resourcemanager/mediaservices/armmediaservices/client_factory.go new file mode 100644 index 000000000000..a19dc9df471d --- /dev/null +++ b/sdk/resourcemanager/mediaservices/armmediaservices/client_factory.go @@ -0,0 +1,144 @@ +//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 armmediaservices + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewAccountFiltersClient() *AccountFiltersClient { + subClient, _ := NewAccountFiltersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewClient() *Client { + subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPrivateLinkResourcesClient() *PrivateLinkResourcesClient { + subClient, _ := NewPrivateLinkResourcesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPrivateEndpointConnectionsClient() *PrivateEndpointConnectionsClient { + subClient, _ := NewPrivateEndpointConnectionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLocationsClient() *LocationsClient { + subClient, _ := NewLocationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationStatusesClient() *OperationStatusesClient { + subClient, _ := NewOperationStatusesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationResultsClient() *OperationResultsClient { + subClient, _ := NewOperationResultsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAssetsClient() *AssetsClient { + subClient, _ := NewAssetsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAssetFiltersClient() *AssetFiltersClient { + subClient, _ := NewAssetFiltersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewTracksClient() *TracksClient { + subClient, _ := NewTracksClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAssetTrackOperationStatusesClient() *AssetTrackOperationStatusesClient { + subClient, _ := NewAssetTrackOperationStatusesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAssetTrackOperationResultsClient() *AssetTrackOperationResultsClient { + subClient, _ := NewAssetTrackOperationResultsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewContentKeyPoliciesClient() *ContentKeyPoliciesClient { + subClient, _ := NewContentKeyPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewTransformsClient() *TransformsClient { + subClient, _ := NewTransformsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewJobsClient() *JobsClient { + subClient, _ := NewJobsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewStreamingPoliciesClient() *StreamingPoliciesClient { + subClient, _ := NewStreamingPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewStreamingLocatorsClient() *StreamingLocatorsClient { + subClient, _ := NewStreamingLocatorsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLiveEventsClient() *LiveEventsClient { + subClient, _ := NewLiveEventsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLiveOutputsClient() *LiveOutputsClient { + subClient, _ := NewLiveOutputsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewStreamingEndpointsClient() *StreamingEndpointsClient { + subClient, _ := NewStreamingEndpointsClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/constants.go b/sdk/resourcemanager/mediaservices/armmediaservices/constants.go index d06c95274a6a..da31f941d6b7 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/constants.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/constants.go @@ -11,7 +11,7 @@ package armmediaservices const ( moduleName = "armmediaservices" - moduleVersion = "v3.2.0" + moduleVersion = "v3.3.0" ) // AacAudioProfile - The encoding profile to be used when encoding audio with AAC. diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/contentkeypolicies_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/contentkeypolicies_client.go index 397d5ff782a9..3dd7567c1367 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/contentkeypolicies_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/contentkeypolicies_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,50 +25,42 @@ import ( // ContentKeyPoliciesClient contains the methods for the ContentKeyPolicies group. // Don't use this type directly, use NewContentKeyPoliciesClient() instead. type ContentKeyPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewContentKeyPoliciesClient creates a new instance of ContentKeyPoliciesClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewContentKeyPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ContentKeyPoliciesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ContentKeyPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ContentKeyPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or update a Content Key Policy in the Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// contentKeyPolicyName - The Content Key Policy name. -// parameters - The request parameters -// options - ContentKeyPoliciesClientCreateOrUpdateOptions contains the optional parameters for the ContentKeyPoliciesClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - contentKeyPolicyName - The Content Key Policy name. +// - parameters - The request parameters +// - options - ContentKeyPoliciesClientCreateOrUpdateOptions contains the optional parameters for the ContentKeyPoliciesClient.CreateOrUpdate +// method. func (client *ContentKeyPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, contentKeyPolicyName string, parameters ContentKeyPolicy, options *ContentKeyPoliciesClientCreateOrUpdateOptions) (ContentKeyPoliciesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, contentKeyPolicyName, parameters, options) if err != nil { return ContentKeyPoliciesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ContentKeyPoliciesClientCreateOrUpdateResponse{}, err } @@ -99,7 +89,7 @@ func (client *ContentKeyPoliciesClient) createOrUpdateCreateRequest(ctx context. return nil, errors.New("parameter contentKeyPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{contentKeyPolicyName}", url.PathEscape(contentKeyPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -121,18 +111,19 @@ func (client *ContentKeyPoliciesClient) createOrUpdateHandleResponse(resp *http. // Delete - Deletes a Content Key Policy in the Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// contentKeyPolicyName - The Content Key Policy name. -// options - ContentKeyPoliciesClientDeleteOptions contains the optional parameters for the ContentKeyPoliciesClient.Delete -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - contentKeyPolicyName - The Content Key Policy name. +// - options - ContentKeyPoliciesClientDeleteOptions contains the optional parameters for the ContentKeyPoliciesClient.Delete +// method. func (client *ContentKeyPoliciesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, contentKeyPolicyName string, options *ContentKeyPoliciesClientDeleteOptions) (ContentKeyPoliciesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, contentKeyPolicyName, options) if err != nil { return ContentKeyPoliciesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ContentKeyPoliciesClientDeleteResponse{}, err } @@ -161,7 +152,7 @@ func (client *ContentKeyPoliciesClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter contentKeyPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{contentKeyPolicyName}", url.PathEscape(contentKeyPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -174,17 +165,18 @@ func (client *ContentKeyPoliciesClient) deleteCreateRequest(ctx context.Context, // Get - Get the details of a Content Key Policy in the Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// contentKeyPolicyName - The Content Key Policy name. -// options - ContentKeyPoliciesClientGetOptions contains the optional parameters for the ContentKeyPoliciesClient.Get method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - contentKeyPolicyName - The Content Key Policy name. +// - options - ContentKeyPoliciesClientGetOptions contains the optional parameters for the ContentKeyPoliciesClient.Get method. func (client *ContentKeyPoliciesClient) Get(ctx context.Context, resourceGroupName string, accountName string, contentKeyPolicyName string, options *ContentKeyPoliciesClientGetOptions) (ContentKeyPoliciesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, contentKeyPolicyName, options) if err != nil { return ContentKeyPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ContentKeyPoliciesClientGetResponse{}, err } @@ -213,7 +205,7 @@ func (client *ContentKeyPoliciesClient) getCreateRequest(ctx context.Context, re return nil, errors.New("parameter contentKeyPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{contentKeyPolicyName}", url.PathEscape(contentKeyPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -235,18 +227,19 @@ func (client *ContentKeyPoliciesClient) getHandleResponse(resp *http.Response) ( // GetPolicyPropertiesWithSecrets - Get a Content Key Policy including secret values // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// contentKeyPolicyName - The Content Key Policy name. -// options - ContentKeyPoliciesClientGetPolicyPropertiesWithSecretsOptions contains the optional parameters for the ContentKeyPoliciesClient.GetPolicyPropertiesWithSecrets -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - contentKeyPolicyName - The Content Key Policy name. +// - options - ContentKeyPoliciesClientGetPolicyPropertiesWithSecretsOptions contains the optional parameters for the ContentKeyPoliciesClient.GetPolicyPropertiesWithSecrets +// method. func (client *ContentKeyPoliciesClient) GetPolicyPropertiesWithSecrets(ctx context.Context, resourceGroupName string, accountName string, contentKeyPolicyName string, options *ContentKeyPoliciesClientGetPolicyPropertiesWithSecretsOptions) (ContentKeyPoliciesClientGetPolicyPropertiesWithSecretsResponse, error) { req, err := client.getPolicyPropertiesWithSecretsCreateRequest(ctx, resourceGroupName, accountName, contentKeyPolicyName, options) if err != nil { return ContentKeyPoliciesClientGetPolicyPropertiesWithSecretsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ContentKeyPoliciesClientGetPolicyPropertiesWithSecretsResponse{}, err } @@ -275,7 +268,7 @@ func (client *ContentKeyPoliciesClient) getPolicyPropertiesWithSecretsCreateRequ return nil, errors.New("parameter contentKeyPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{contentKeyPolicyName}", url.PathEscape(contentKeyPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -296,10 +289,12 @@ func (client *ContentKeyPoliciesClient) getPolicyPropertiesWithSecretsHandleResp } // NewListPager - Lists the Content Key Policies in the account +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// options - ContentKeyPoliciesClientListOptions contains the optional parameters for the ContentKeyPoliciesClient.List method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - options - ContentKeyPoliciesClientListOptions contains the optional parameters for the ContentKeyPoliciesClient.NewListPager +// method. func (client *ContentKeyPoliciesClient) NewListPager(resourceGroupName string, accountName string, options *ContentKeyPoliciesClientListOptions) *runtime.Pager[ContentKeyPoliciesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ContentKeyPoliciesClientListResponse]{ More: func(page ContentKeyPoliciesClientListResponse) bool { @@ -316,7 +311,7 @@ func (client *ContentKeyPoliciesClient) NewListPager(resourceGroupName string, a if err != nil { return ContentKeyPoliciesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ContentKeyPoliciesClientListResponse{}, err } @@ -343,7 +338,7 @@ func (client *ContentKeyPoliciesClient) listCreateRequest(ctx context.Context, r return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -374,19 +369,20 @@ func (client *ContentKeyPoliciesClient) listHandleResponse(resp *http.Response) // Update - Updates an existing Content Key Policy in the Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// contentKeyPolicyName - The Content Key Policy name. -// parameters - The request parameters -// options - ContentKeyPoliciesClientUpdateOptions contains the optional parameters for the ContentKeyPoliciesClient.Update -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - contentKeyPolicyName - The Content Key Policy name. +// - parameters - The request parameters +// - options - ContentKeyPoliciesClientUpdateOptions contains the optional parameters for the ContentKeyPoliciesClient.Update +// method. func (client *ContentKeyPoliciesClient) Update(ctx context.Context, resourceGroupName string, accountName string, contentKeyPolicyName string, parameters ContentKeyPolicy, options *ContentKeyPoliciesClientUpdateOptions) (ContentKeyPoliciesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, contentKeyPolicyName, parameters, options) if err != nil { return ContentKeyPoliciesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ContentKeyPoliciesClientUpdateResponse{}, err } @@ -415,7 +411,7 @@ func (client *ContentKeyPoliciesClient) updateCreateRequest(ctx context.Context, return nil, errors.New("parameter contentKeyPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{contentKeyPolicyName}", url.PathEscape(contentKeyPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/contentkeypolicies_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/contentkeypolicies_client_example_test.go index cf50db3b8cf7..9d10984b3f38 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/contentkeypolicies_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/contentkeypolicies_client_example_test.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 armmediaservices_test @@ -19,118 +20,428 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-list-by-lastModified.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-list-by-lastModified.json func ExampleContentKeyPoliciesClient_NewListPager_listsContentKeyPoliciesOrderedByLastModified() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewContentKeyPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contoso", "contosomedia", &armmediaservices.ContentKeyPoliciesClientListOptions{Filter: nil, + pager := clientFactory.NewContentKeyPoliciesClient().NewListPager("contoso", "contosomedia", &armmediaservices.ContentKeyPoliciesClientListOptions{Filter: nil, Top: nil, Orderby: to.Ptr("properties/lastModified"), }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ContentKeyPolicyCollection = armmediaservices.ContentKeyPolicyCollection{ + // Value: []*armmediaservices.ContentKeyPolicy{ + // { + // Name: to.Ptr("PolicyWithPlayReadyOptionAndOpenRestriction"), + // Type: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/contentKeyPolicies/PolicyWithPlayReadyOptionAndOpenRestriction"), + // Properties: &armmediaservices.ContentKeyPolicyProperties{ + // Description: to.Ptr("A policy with one PlayReady option and Open Restriction."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2012-11-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2012-11-01T00:00:00Z"); return t}()), + // Options: []*armmediaservices.ContentKeyPolicyOption{ + // { + // Configuration: &armmediaservices.ContentKeyPolicyPlayReadyConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyPlayReadyConfiguration"), + // Licenses: []*armmediaservices.ContentKeyPolicyPlayReadyLicense{ + // { + // AllowTestDevices: to.Ptr(false), + // ContentKeyLocation: &armmediaservices.ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader"), + // }, + // ContentType: to.Ptr(armmediaservices.ContentKeyPolicyPlayReadyContentTypeUnspecified), + // LicenseType: to.Ptr(armmediaservices.ContentKeyPolicyPlayReadyLicenseTypeNonPersistent), + // PlayRight: &armmediaservices.ContentKeyPolicyPlayReadyPlayRight{ + // AllowPassingVideoContentToUnknownOutput: to.Ptr(armmediaservices.ContentKeyPolicyPlayReadyUnknownOutputPassingOptionNotAllowed), + // DigitalVideoOnlyContentRestriction: to.Ptr(false), + // ImageConstraintForAnalogComponentVideoRestriction: to.Ptr(false), + // ImageConstraintForAnalogComputerMonitorRestriction: to.Ptr(false), + // }, + // SecurityLevel: to.Ptr(armmediaservices.SecurityLevelSL2000), + // }}, + // ResponseCustomData: to.Ptr("testCustomData"), + // }, + // PolicyOptionID: to.Ptr("294a833f-f128-48be-9edf-8d1bb5b35ff3"), + // Restriction: &armmediaservices.ContentKeyPolicyOpenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyOpenRestriction"), + // }, + // }}, + // PolicyID: to.Ptr("a9bacd1d-60f5-4af3-8d2b-cf46ca5c9b04"), + // }, + // }, + // { + // Name: to.Ptr("PolicyWithMultipleOptions"), + // Type: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/contentKeyPolicies/PolicyWithMultipleOptions"), + // Properties: &armmediaservices.ContentKeyPolicyProperties{ + // Description: to.Ptr("A policy with multiple options."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2015-12-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-12-02T00:00:00Z"); return t}()), + // Options: []*armmediaservices.ContentKeyPolicyOption{ + // { + // Configuration: &armmediaservices.ContentKeyPolicyClearKeyConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration"), + // }, + // PolicyOptionID: to.Ptr("caf1e28c-8288-4301-8c46-c0f9312c512f"), + // Restriction: &armmediaservices.ContentKeyPolicyTokenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyTokenRestriction"), + // AlternateVerificationKeys: []armmediaservices.ContentKeyPolicyRestrictionTokenKeyClassification{ + // }, + // Audience: to.Ptr("urn:test"), + // Issuer: to.Ptr("http://testacs"), + // PrimaryVerificationKey: &armmediaservices.ContentKeyPolicySymmetricTokenKey{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicySymmetricTokenKey"), + // KeyValue: []byte(""), + // }, + // RequiredClaims: []*armmediaservices.ContentKeyPolicyTokenClaim{ + // { + // ClaimType: to.Ptr("urn:microsoft:azure:mediaservices:contentkeyidentifier"), + // }, + // { + // ClaimType: to.Ptr("DRM"), + // ClaimValue: to.Ptr("Widevine"), + // }}, + // RestrictionTokenType: to.Ptr(armmediaservices.ContentKeyPolicyRestrictionTokenTypeJwt), + // }, + // }, + // { + // Configuration: &armmediaservices.ContentKeyPolicyWidevineConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyWidevineConfiguration"), + // WidevineTemplate: to.Ptr("{\"allowed_track_types\":\"SD_HD\",\"content_key_specs\":[{\"track_type\":\"SD\",\"security_level\":1,\"required_output_protection\":{\"hdcp\":\"HDCP_V2\"}}],\"policy_overrides\":{\"can_play\":true,\"can_persist\":true,\"can_renew\":false}}"), + // }, + // PolicyOptionID: to.Ptr("da346259-0cd6-4609-89dc-15ac131bd92f"), + // Restriction: &armmediaservices.ContentKeyPolicyOpenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyOpenRestriction"), + // }, + // }}, + // PolicyID: to.Ptr("ed7f3d1b-cfa7-4181-b966-e0b3027eec3a"), + // }, + // }, + // { + // Name: to.Ptr("PolicyWithClearKeyOptionAndTokenRestriction"), + // Type: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/contentKeyPolicies/PolicyWithClearKeyOptionAndTokenRestriction"), + // Properties: &armmediaservices.ContentKeyPolicyProperties{ + // Description: to.Ptr("A policy with one ClearKey option and Open Restriction."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-12-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-11-01T00:00:00Z"); return t}()), + // Options: []*armmediaservices.ContentKeyPolicyOption{ + // { + // Configuration: &armmediaservices.ContentKeyPolicyClearKeyConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration"), + // }, + // PolicyOptionID: to.Ptr("a3448d09-567a-4642-8309-d17e846be59f"), + // Restriction: &armmediaservices.ContentKeyPolicyTokenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyTokenRestriction"), + // AlternateVerificationKeys: []armmediaservices.ContentKeyPolicyRestrictionTokenKeyClassification{ + // }, + // Audience: to.Ptr("urn:test"), + // Issuer: to.Ptr("http://testacs"), + // PrimaryVerificationKey: &armmediaservices.ContentKeyPolicySymmetricTokenKey{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicySymmetricTokenKey"), + // KeyValue: []byte(""), + // }, + // RequiredClaims: []*armmediaservices.ContentKeyPolicyTokenClaim{ + // { + // ClaimType: to.Ptr("urn:microsoft:azure:mediaservices:contentkeyidentifier"), + // }, + // { + // ClaimType: to.Ptr("DRM"), + // ClaimValue: to.Ptr("Widevine"), + // }}, + // RestrictionTokenType: to.Ptr(armmediaservices.ContentKeyPolicyRestrictionTokenTypeJwt), + // }, + // }}, + // PolicyID: to.Ptr("8352435b-ebea-4681-aae7-e19277771f64"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-list-in-date-range.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-list-in-date-range.json func ExampleContentKeyPoliciesClient_NewListPager_listsContentKeyPoliciesWithCreatedAndLastModifiedFilters() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewContentKeyPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contoso", "contosomedia", &armmediaservices.ContentKeyPoliciesClientListOptions{Filter: to.Ptr("properties/lastModified gt 2016-06-01 and properties/created lt 2013-07-01"), + pager := clientFactory.NewContentKeyPoliciesClient().NewListPager("contoso", "contosomedia", &armmediaservices.ContentKeyPoliciesClientListOptions{Filter: to.Ptr("properties/lastModified gt 2016-06-01 and properties/created lt 2013-07-01"), Top: nil, Orderby: nil, }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ContentKeyPolicyCollection = armmediaservices.ContentKeyPolicyCollection{ + // Value: []*armmediaservices.ContentKeyPolicy{ + // }, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-list-all.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-list-all.json func ExampleContentKeyPoliciesClient_NewListPager_listsAllContentKeyPolicies() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewContentKeyPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contoso", "contosomedia", &armmediaservices.ContentKeyPoliciesClientListOptions{Filter: nil, + pager := clientFactory.NewContentKeyPoliciesClient().NewListPager("contoso", "contosomedia", &armmediaservices.ContentKeyPoliciesClientListOptions{Filter: nil, Top: nil, Orderby: nil, }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ContentKeyPolicyCollection = armmediaservices.ContentKeyPolicyCollection{ + // Value: []*armmediaservices.ContentKeyPolicy{ + // { + // Name: to.Ptr("PolicyWithClearKeyOptionAndTokenRestriction"), + // Type: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/contentKeyPolicies/PolicyWithClearKeyOptionAndTokenRestriction"), + // Properties: &armmediaservices.ContentKeyPolicyProperties{ + // Description: to.Ptr("A policy with one ClearKey option and Open Restriction."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-12-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-11-01T00:00:00Z"); return t}()), + // Options: []*armmediaservices.ContentKeyPolicyOption{ + // { + // Configuration: &armmediaservices.ContentKeyPolicyClearKeyConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration"), + // }, + // PolicyOptionID: to.Ptr("a3448d09-567a-4642-8309-d17e846be59f"), + // Restriction: &armmediaservices.ContentKeyPolicyTokenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyTokenRestriction"), + // AlternateVerificationKeys: []armmediaservices.ContentKeyPolicyRestrictionTokenKeyClassification{ + // }, + // Audience: to.Ptr("urn:test"), + // Issuer: to.Ptr("http://testacs"), + // PrimaryVerificationKey: &armmediaservices.ContentKeyPolicySymmetricTokenKey{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicySymmetricTokenKey"), + // KeyValue: []byte(""), + // }, + // RequiredClaims: []*armmediaservices.ContentKeyPolicyTokenClaim{ + // { + // ClaimType: to.Ptr("urn:microsoft:azure:mediaservices:contentkeyidentifier"), + // }, + // { + // ClaimType: to.Ptr("DRM"), + // ClaimValue: to.Ptr("Widevine"), + // }}, + // RestrictionTokenType: to.Ptr(armmediaservices.ContentKeyPolicyRestrictionTokenTypeJwt), + // }, + // }}, + // PolicyID: to.Ptr("8352435b-ebea-4681-aae7-e19277771f64"), + // }, + // }, + // { + // Name: to.Ptr("PolicyWithMultipleOptions"), + // Type: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/contentKeyPolicies/PolicyWithMultipleOptions"), + // Properties: &armmediaservices.ContentKeyPolicyProperties{ + // Description: to.Ptr("A policy with multiple options."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2015-12-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-12-02T00:00:00Z"); return t}()), + // Options: []*armmediaservices.ContentKeyPolicyOption{ + // { + // Configuration: &armmediaservices.ContentKeyPolicyClearKeyConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration"), + // }, + // PolicyOptionID: to.Ptr("caf1e28c-8288-4301-8c46-c0f9312c512f"), + // Restriction: &armmediaservices.ContentKeyPolicyTokenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyTokenRestriction"), + // AlternateVerificationKeys: []armmediaservices.ContentKeyPolicyRestrictionTokenKeyClassification{ + // }, + // Audience: to.Ptr("urn:test"), + // Issuer: to.Ptr("http://testacs"), + // PrimaryVerificationKey: &armmediaservices.ContentKeyPolicySymmetricTokenKey{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicySymmetricTokenKey"), + // KeyValue: []byte(""), + // }, + // RequiredClaims: []*armmediaservices.ContentKeyPolicyTokenClaim{ + // { + // ClaimType: to.Ptr("urn:microsoft:azure:mediaservices:contentkeyidentifier"), + // }, + // { + // ClaimType: to.Ptr("DRM"), + // ClaimValue: to.Ptr("Widevine"), + // }}, + // RestrictionTokenType: to.Ptr(armmediaservices.ContentKeyPolicyRestrictionTokenTypeJwt), + // }, + // }, + // { + // Configuration: &armmediaservices.ContentKeyPolicyWidevineConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyWidevineConfiguration"), + // WidevineTemplate: to.Ptr("{\"allowed_track_types\":\"SD_HD\",\"content_key_specs\":[{\"track_type\":\"SD\",\"security_level\":1,\"required_output_protection\":{\"hdcp\":\"HDCP_V2\"}}],\"policy_overrides\":{\"can_play\":true,\"can_persist\":true,\"can_renew\":false}}"), + // }, + // PolicyOptionID: to.Ptr("da346259-0cd6-4609-89dc-15ac131bd92f"), + // Restriction: &armmediaservices.ContentKeyPolicyOpenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyOpenRestriction"), + // }, + // }}, + // PolicyID: to.Ptr("ed7f3d1b-cfa7-4181-b966-e0b3027eec3a"), + // }, + // }, + // { + // Name: to.Ptr("PolicyWithPlayReadyOptionAndOpenRestriction"), + // Type: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/contentKeyPolicies/PolicyWithPlayReadyOptionAndOpenRestriction"), + // Properties: &armmediaservices.ContentKeyPolicyProperties{ + // Description: to.Ptr("A policy with one PlayReady option and Open Restriction."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2012-11-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2012-11-01T00:00:00Z"); return t}()), + // Options: []*armmediaservices.ContentKeyPolicyOption{ + // { + // Configuration: &armmediaservices.ContentKeyPolicyPlayReadyConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyPlayReadyConfiguration"), + // Licenses: []*armmediaservices.ContentKeyPolicyPlayReadyLicense{ + // { + // AllowTestDevices: to.Ptr(false), + // ContentKeyLocation: &armmediaservices.ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader"), + // }, + // ContentType: to.Ptr(armmediaservices.ContentKeyPolicyPlayReadyContentTypeUnspecified), + // LicenseType: to.Ptr(armmediaservices.ContentKeyPolicyPlayReadyLicenseTypeNonPersistent), + // PlayRight: &armmediaservices.ContentKeyPolicyPlayReadyPlayRight{ + // AllowPassingVideoContentToUnknownOutput: to.Ptr(armmediaservices.ContentKeyPolicyPlayReadyUnknownOutputPassingOptionNotAllowed), + // DigitalVideoOnlyContentRestriction: to.Ptr(false), + // ImageConstraintForAnalogComponentVideoRestriction: to.Ptr(false), + // ImageConstraintForAnalogComputerMonitorRestriction: to.Ptr(false), + // }, + // SecurityLevel: to.Ptr(armmediaservices.SecurityLevelSL2000), + // }}, + // ResponseCustomData: to.Ptr("testCustomData"), + // }, + // PolicyOptionID: to.Ptr("294a833f-f128-48be-9edf-8d1bb5b35ff3"), + // Restriction: &armmediaservices.ContentKeyPolicyOpenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyOpenRestriction"), + // }, + // }}, + // PolicyID: to.Ptr("a9bacd1d-60f5-4af3-8d2b-cf46ca5c9b04"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-get-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-get-by-name.json func ExampleContentKeyPoliciesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewContentKeyPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contoso", "contosomedia", "PolicyWithMultipleOptions", nil) + res, err := clientFactory.NewContentKeyPoliciesClient().Get(ctx, "contoso", "contosomedia", "PolicyWithMultipleOptions", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ContentKeyPolicy = armmediaservices.ContentKeyPolicy{ + // Name: to.Ptr("PolicyWithMultipleOptions"), + // Type: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/contentKeyPolicies/PolicyWithMultipleOptions"), + // Properties: &armmediaservices.ContentKeyPolicyProperties{ + // Description: to.Ptr("A policy with multiple options."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2015-12-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-12-02T00:00:00Z"); return t}()), + // Options: []*armmediaservices.ContentKeyPolicyOption{ + // { + // Configuration: &armmediaservices.ContentKeyPolicyClearKeyConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration"), + // }, + // PolicyOptionID: to.Ptr("caf1e28c-8288-4301-8c46-c0f9312c512f"), + // Restriction: &armmediaservices.ContentKeyPolicyTokenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyTokenRestriction"), + // AlternateVerificationKeys: []armmediaservices.ContentKeyPolicyRestrictionTokenKeyClassification{ + // }, + // Audience: to.Ptr("urn:test"), + // Issuer: to.Ptr("http://testacs"), + // PrimaryVerificationKey: &armmediaservices.ContentKeyPolicySymmetricTokenKey{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicySymmetricTokenKey"), + // KeyValue: []byte(""), + // }, + // RequiredClaims: []*armmediaservices.ContentKeyPolicyTokenClaim{ + // { + // ClaimType: to.Ptr("urn:microsoft:azure:mediaservices:contentkeyidentifier"), + // }, + // { + // ClaimType: to.Ptr("DRM"), + // ClaimValue: to.Ptr("Widevine"), + // }}, + // RestrictionTokenType: to.Ptr(armmediaservices.ContentKeyPolicyRestrictionTokenTypeJwt), + // }, + // }, + // { + // Configuration: &armmediaservices.ContentKeyPolicyWidevineConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyWidevineConfiguration"), + // WidevineTemplate: to.Ptr("{\"allowed_track_types\":\"SD_HD\",\"content_key_specs\":[{\"track_type\":\"SD\",\"security_level\":1,\"required_output_protection\":{\"hdcp\":\"HDCP_V2\"}}],\"policy_overrides\":{\"can_play\":true,\"can_persist\":true,\"can_renew\":false}}"), + // }, + // PolicyOptionID: to.Ptr("da346259-0cd6-4609-89dc-15ac131bd92f"), + // Restriction: &armmediaservices.ContentKeyPolicyOpenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyOpenRestriction"), + // }, + // }}, + // PolicyID: to.Ptr("ed7f3d1b-cfa7-4181-b966-e0b3027eec3a"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-create-nodrm-token.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-create-nodrm-token.json func ExampleContentKeyPoliciesClient_CreateOrUpdate_createsAContentKeyPolicyWithClearKeyOptionAndTokenRestriction() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewContentKeyPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "contoso", "contosomedia", "PolicyWithClearKeyOptionAndSwtTokenRestriction", armmediaservices.ContentKeyPolicy{ + res, err := clientFactory.NewContentKeyPoliciesClient().CreateOrUpdate(ctx, "contoso", "contosomedia", "PolicyWithClearKeyOptionAndSwtTokenRestriction", armmediaservices.ContentKeyPolicy{ Properties: &armmediaservices.ContentKeyPolicyProperties{ Description: to.Ptr("ArmPolicyDescription"), Options: []*armmediaservices.ContentKeyPolicyOption{ @@ -155,22 +466,56 @@ func ExampleContentKeyPoliciesClient_CreateOrUpdate_createsAContentKeyPolicyWith if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ContentKeyPolicy = armmediaservices.ContentKeyPolicy{ + // Name: to.Ptr("PolicyWithClearKeyOptionAndSwtTokenRestriction"), + // Type: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/contentKeyPolicies/PolicyWithClearKeyOptionAndSwtTokenRestriction"), + // Properties: &armmediaservices.ContentKeyPolicyProperties{ + // Description: to.Ptr("ArmPolicyDescription"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:29.837Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:29.837Z"); return t}()), + // Options: []*armmediaservices.ContentKeyPolicyOption{ + // { + // Name: to.Ptr("ClearKeyOption"), + // Configuration: &armmediaservices.ContentKeyPolicyClearKeyConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration"), + // }, + // PolicyOptionID: to.Ptr("e7d4d465-b6f7-4830-9a21-74a7326ef797"), + // Restriction: &armmediaservices.ContentKeyPolicyTokenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyTokenRestriction"), + // AlternateVerificationKeys: []armmediaservices.ContentKeyPolicyRestrictionTokenKeyClassification{ + // }, + // Audience: to.Ptr("urn:audience"), + // Issuer: to.Ptr("urn:issuer"), + // PrimaryVerificationKey: &armmediaservices.ContentKeyPolicySymmetricTokenKey{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicySymmetricTokenKey"), + // KeyValue: []byte(""), + // }, + // RequiredClaims: []*armmediaservices.ContentKeyPolicyTokenClaim{ + // }, + // RestrictionTokenType: to.Ptr(armmediaservices.ContentKeyPolicyRestrictionTokenTypeSwt), + // }, + // }}, + // PolicyID: to.Ptr("2926c1bc-4dec-4a11-9d19-3f99006530a9"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-create-playready-open.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-create-playready-open.json func ExampleContentKeyPoliciesClient_CreateOrUpdate_createsAContentKeyPolicyWithPlayReadyOptionAndOpenRestriction() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewContentKeyPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "contoso", "contosomedia", "PolicyWithPlayReadyOptionAndOpenRestriction", armmediaservices.ContentKeyPolicy{ + res, err := clientFactory.NewContentKeyPoliciesClient().CreateOrUpdate(ctx, "contoso", "contosomedia", "PolicyWithPlayReadyOptionAndOpenRestriction", armmediaservices.ContentKeyPolicy{ Properties: &armmediaservices.ContentKeyPolicyProperties{ Description: to.Ptr("ArmPolicyDescription"), Options: []*armmediaservices.ContentKeyPolicyOption{ @@ -206,22 +551,63 @@ func ExampleContentKeyPoliciesClient_CreateOrUpdate_createsAContentKeyPolicyWith if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ContentKeyPolicy = armmediaservices.ContentKeyPolicy{ + // Name: to.Ptr("PolicyWithPlayReadyOptionAndOpenRestriction"), + // Type: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/contentKeyPolicies/PolicyWithPlayReadyOptionAndOpenRestriction"), + // Properties: &armmediaservices.ContentKeyPolicyProperties{ + // Description: to.Ptr("ArmPolicyDescription"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2012-11-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:29.51Z"); return t}()), + // Options: []*armmediaservices.ContentKeyPolicyOption{ + // { + // Name: to.Ptr("ArmPolicyOptionName"), + // Configuration: &armmediaservices.ContentKeyPolicyPlayReadyConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyPlayReadyConfiguration"), + // Licenses: []*armmediaservices.ContentKeyPolicyPlayReadyLicense{ + // { + // AllowTestDevices: to.Ptr(true), + // BeginDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-10-16T18:22:53.46Z"); return t}()), + // ContentKeyLocation: &armmediaservices.ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader"), + // }, + // ContentType: to.Ptr(armmediaservices.ContentKeyPolicyPlayReadyContentTypeUltraVioletDownload), + // LicenseType: to.Ptr(armmediaservices.ContentKeyPolicyPlayReadyLicenseTypePersistent), + // PlayRight: &armmediaservices.ContentKeyPolicyPlayReadyPlayRight{ + // AllowPassingVideoContentToUnknownOutput: to.Ptr(armmediaservices.ContentKeyPolicyPlayReadyUnknownOutputPassingOptionNotAllowed), + // DigitalVideoOnlyContentRestriction: to.Ptr(false), + // ImageConstraintForAnalogComponentVideoRestriction: to.Ptr(true), + // ImageConstraintForAnalogComputerMonitorRestriction: to.Ptr(false), + // ScmsRestriction: to.Ptr[int32](2), + // }, + // SecurityLevel: to.Ptr(armmediaservices.SecurityLevelSL150), + // }}, + // }, + // PolicyOptionID: to.Ptr("c52f9af0-1f53-4775-8edb-af2d9a6e28cd"), + // Restriction: &armmediaservices.ContentKeyPolicyOpenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyOpenRestriction"), + // }, + // }}, + // PolicyID: to.Ptr("a9bacd1d-60f5-4af3-8d2b-cf46ca5c9b04"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-create-widevine-token.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-create-widevine-token.json func ExampleContentKeyPoliciesClient_CreateOrUpdate_createsAContentKeyPolicyWithWidevineOptionAndTokenRestriction() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewContentKeyPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "contoso", "contosomedia", "PolicyWithWidevineOptionAndJwtTokenRestriction", armmediaservices.ContentKeyPolicy{ + res, err := clientFactory.NewContentKeyPoliciesClient().CreateOrUpdate(ctx, "contoso", "contosomedia", "PolicyWithWidevineOptionAndJwtTokenRestriction", armmediaservices.ContentKeyPolicy{ Properties: &armmediaservices.ContentKeyPolicyProperties{ Description: to.Ptr("ArmPolicyDescription"), Options: []*armmediaservices.ContentKeyPolicyOption{ @@ -253,22 +639,61 @@ func ExampleContentKeyPoliciesClient_CreateOrUpdate_createsAContentKeyPolicyWith if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ContentKeyPolicy = armmediaservices.ContentKeyPolicy{ + // Name: to.Ptr("PolicyWithWidevineOptionAndJwtTokenRestriction"), + // Type: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/contentKeyPolicies/PolicyWithWidevineOptionAndJwtTokenRestriction"), + // Properties: &armmediaservices.ContentKeyPolicyProperties{ + // Description: to.Ptr("ArmPolicyDescription"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:29.663Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:29.663Z"); return t}()), + // Options: []*armmediaservices.ContentKeyPolicyOption{ + // { + // Name: to.Ptr("widevineoption"), + // Configuration: &armmediaservices.ContentKeyPolicyWidevineConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyWidevineConfiguration"), + // WidevineTemplate: to.Ptr("{\"allowed_track_types\":\"SD_HD\",\"content_key_specs\":[{\"track_type\":\"SD\",\"security_level\":1,\"required_output_protection\":{\"hdcp\":\"HDCP_V2\"}}],\"policy_overrides\":{\"can_play\":true,\"can_persist\":true,\"can_renew\":false}}"), + // }, + // PolicyOptionID: to.Ptr("26fee004-8dfa-4828-bcad-5e63c637534f"), + // Restriction: &armmediaservices.ContentKeyPolicyTokenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyTokenRestriction"), + // AlternateVerificationKeys: []armmediaservices.ContentKeyPolicyRestrictionTokenKeyClassification{ + // &armmediaservices.ContentKeyPolicySymmetricTokenKey{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicySymmetricTokenKey"), + // KeyValue: []byte(""), + // }}, + // Audience: to.Ptr("urn:audience"), + // Issuer: to.Ptr("urn:issuer"), + // PrimaryVerificationKey: &armmediaservices.ContentKeyPolicyRsaTokenKey{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyRsaTokenKey"), + // Exponent: []byte(""), + // Modulus: []byte(""), + // }, + // RequiredClaims: []*armmediaservices.ContentKeyPolicyTokenClaim{ + // }, + // RestrictionTokenType: to.Ptr(armmediaservices.ContentKeyPolicyRestrictionTokenTypeJwt), + // }, + // }}, + // PolicyID: to.Ptr("bad1d030-7d5c-4643-8f1e-49807a4bf64c"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-create-multiple-options.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-create-multiple-options.json func ExampleContentKeyPoliciesClient_CreateOrUpdate_createsAContentKeyPolicyWithMultipleOptions() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewContentKeyPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "contoso", "contosomedia", "PolicyCreatedWithMultipleOptions", armmediaservices.ContentKeyPolicy{ + res, err := clientFactory.NewContentKeyPoliciesClient().CreateOrUpdate(ctx, "contoso", "contosomedia", "PolicyCreatedWithMultipleOptions", armmediaservices.ContentKeyPolicy{ Properties: &armmediaservices.ContentKeyPolicyProperties{ Description: to.Ptr("ArmPolicyDescription"), Options: []*armmediaservices.ContentKeyPolicyOption{ @@ -303,39 +728,84 @@ func ExampleContentKeyPoliciesClient_CreateOrUpdate_createsAContentKeyPolicyWith if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ContentKeyPolicy = armmediaservices.ContentKeyPolicy{ + // Name: to.Ptr("PolicyCreatedWithMultipleOptions"), + // Type: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/contentKeyPolicies/PolicyCreatedWithMultipleOptions"), + // Properties: &armmediaservices.ContentKeyPolicyProperties{ + // Description: to.Ptr("ArmPolicyDescription"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:29.98Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:29.98Z"); return t}()), + // Options: []*armmediaservices.ContentKeyPolicyOption{ + // { + // Name: to.Ptr("ClearKeyOption"), + // Configuration: &armmediaservices.ContentKeyPolicyClearKeyConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration"), + // }, + // PolicyOptionID: to.Ptr("8dac9510-770a-401f-8f2b-f72640977ed0"), + // Restriction: &armmediaservices.ContentKeyPolicyTokenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyTokenRestriction"), + // AlternateVerificationKeys: []armmediaservices.ContentKeyPolicyRestrictionTokenKeyClassification{ + // }, + // Audience: to.Ptr("urn:audience"), + // Issuer: to.Ptr("urn:issuer"), + // PrimaryVerificationKey: &armmediaservices.ContentKeyPolicySymmetricTokenKey{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicySymmetricTokenKey"), + // KeyValue: []byte(""), + // }, + // RequiredClaims: []*armmediaservices.ContentKeyPolicyTokenClaim{ + // }, + // RestrictionTokenType: to.Ptr(armmediaservices.ContentKeyPolicyRestrictionTokenTypeSwt), + // }, + // }, + // { + // Name: to.Ptr("widevineoption"), + // Configuration: &armmediaservices.ContentKeyPolicyWidevineConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyWidevineConfiguration"), + // WidevineTemplate: to.Ptr("{\"allowed_track_types\":\"SD_HD\",\"content_key_specs\":[{\"track_type\":\"SD\",\"security_level\":1,\"required_output_protection\":{\"hdcp\":\"HDCP_V2\"}}],\"policy_overrides\":{\"can_play\":true,\"can_persist\":true,\"can_renew\":false}}"), + // }, + // PolicyOptionID: to.Ptr("fc121776-6ced-4135-be92-f928dedc029a"), + // Restriction: &armmediaservices.ContentKeyPolicyOpenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyOpenRestriction"), + // }, + // }}, + // PolicyID: to.Ptr("07ad673b-dc14-4230-adab-716622f33992"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-delete.json func ExampleContentKeyPoliciesClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewContentKeyPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "contoso", "contosomedia", "PolicyWithPlayReadyOptionAndOpenRestriction", nil) + _, err = clientFactory.NewContentKeyPoliciesClient().Delete(ctx, "contoso", "contosomedia", "PolicyWithPlayReadyOptionAndOpenRestriction", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-update.json func ExampleContentKeyPoliciesClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewContentKeyPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "contoso", "contosomedia", "PolicyWithClearKeyOptionAndTokenRestriction", armmediaservices.ContentKeyPolicy{ + res, err := clientFactory.NewContentKeyPoliciesClient().Update(ctx, "contoso", "contosomedia", "PolicyWithClearKeyOptionAndTokenRestriction", armmediaservices.ContentKeyPolicy{ Properties: &armmediaservices.ContentKeyPolicyProperties{ Description: to.Ptr("Updated Policy"), Options: []*armmediaservices.ContentKeyPolicyOption{ @@ -353,25 +823,92 @@ func ExampleContentKeyPoliciesClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ContentKeyPolicy = armmediaservices.ContentKeyPolicy{ + // Name: to.Ptr("PolicyWithClearKeyOptionAndTokenRestriction"), + // Type: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/contentKeyPolicies/PolicyWithClearKeyOptionAndTokenRestriction"), + // Properties: &armmediaservices.ContentKeyPolicyProperties{ + // Description: to.Ptr("Updated Policy"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-12-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:30.303Z"); return t}()), + // Options: []*armmediaservices.ContentKeyPolicyOption{ + // { + // Name: to.Ptr("ClearKeyOption"), + // Configuration: &armmediaservices.ContentKeyPolicyClearKeyConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration"), + // }, + // PolicyOptionID: to.Ptr("7d3f4bc1-d2bf-43a3-b02e-a7e31ab15d43"), + // Restriction: &armmediaservices.ContentKeyPolicyOpenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyOpenRestriction"), + // }, + // }}, + // PolicyID: to.Ptr("8352435b-ebea-4681-aae7-e19277771f64"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-get-with-secrets.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/content-key-policies-get-with-secrets.json func ExampleContentKeyPoliciesClient_GetPolicyPropertiesWithSecrets() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewContentKeyPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GetPolicyPropertiesWithSecrets(ctx, "contoso", "contosomedia", "PolicyWithMultipleOptions", nil) + res, err := clientFactory.NewContentKeyPoliciesClient().GetPolicyPropertiesWithSecrets(ctx, "contoso", "contosomedia", "PolicyWithMultipleOptions", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ContentKeyPolicyProperties = armmediaservices.ContentKeyPolicyProperties{ + // Description: to.Ptr("A policy with multiple options."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2015-12-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-12-02T00:00:00Z"); return t}()), + // Options: []*armmediaservices.ContentKeyPolicyOption{ + // { + // Configuration: &armmediaservices.ContentKeyPolicyClearKeyConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration"), + // }, + // PolicyOptionID: to.Ptr("caf1e28c-8288-4301-8c46-c0f9312c512f"), + // Restriction: &armmediaservices.ContentKeyPolicyTokenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyTokenRestriction"), + // AlternateVerificationKeys: []armmediaservices.ContentKeyPolicyRestrictionTokenKeyClassification{ + // }, + // Audience: to.Ptr("urn:test"), + // Issuer: to.Ptr("http://testacs"), + // PrimaryVerificationKey: &armmediaservices.ContentKeyPolicySymmetricTokenKey{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicySymmetricTokenKey"), + // KeyValue: []byte("AAA="), + // }, + // RequiredClaims: []*armmediaservices.ContentKeyPolicyTokenClaim{ + // { + // ClaimType: to.Ptr("urn:microsoft:azure:mediaservices:contentkeyidentifier"), + // }, + // { + // ClaimType: to.Ptr("DRM"), + // ClaimValue: to.Ptr("Widevine"), + // }}, + // RestrictionTokenType: to.Ptr(armmediaservices.ContentKeyPolicyRestrictionTokenTypeJwt), + // }, + // }, + // { + // Configuration: &armmediaservices.ContentKeyPolicyWidevineConfiguration{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyWidevineConfiguration"), + // WidevineTemplate: to.Ptr("{\"allowed_track_types\":\"SD_HD\",\"content_key_specs\":[{\"track_type\":\"SD\",\"security_level\":1,\"required_output_protection\":{\"hdcp\":\"HDCP_V2\"}}],\"policy_overrides\":{\"can_play\":true,\"can_persist\":true,\"can_renew\":false}}"), + // }, + // PolicyOptionID: to.Ptr("da346259-0cd6-4609-89dc-15ac131bd92f"), + // Restriction: &armmediaservices.ContentKeyPolicyOpenRestriction{ + // ODataType: to.Ptr("#Microsoft.Media.ContentKeyPolicyOpenRestriction"), + // }, + // }}, + // PolicyID: to.Ptr("ed7f3d1b-cfa7-4181-b966-e0b3027eec3a"), + // } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/go.mod b/sdk/resourcemanager/mediaservices/armmediaservices/go.mod index 7782fef3f2a2..f9d8ca95bce0 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/go.mod +++ b/sdk/resourcemanager/mediaservices/armmediaservices/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armme 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.2.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 // indirect - github.com/golang-jwt/jwt/v4 v4.4.2 // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/go.sum b/sdk/resourcemanager/mediaservices/armmediaservices/go.sum index 8c0539b73123..8ba445a8c4da 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/go.sum +++ b/sdk/resourcemanager/mediaservices/armmediaservices/go.sum @@ -1,30 +1,31 @@ -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.2.0 h1:t/W5MYAuQy81cvM8VUNfRLzhtKpXhVUAN7Cd7KVbTyc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0/go.mod h1:NBanQUfSWiWn3QEpWDTCU0IjBECKOYvl2R8xdRtMtiM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.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.7.0 h1:VgSJlZH5u0k2qxSpqyghcFQKmvYckj46uymKK5XzkBM= -github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0/go.mod h1:BDJ5qMFKx9DugEg3+uQSDCdbYPr5s9vBTrL9P8TpqOU= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= 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/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= -github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -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/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/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/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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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-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= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/jobs_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/jobs_client.go index 012811c8199f..bdf78cdcb3f2 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/jobs_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/jobs_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,49 +24,41 @@ import ( // JobsClient contains the methods for the Jobs group. // Don't use this type directly, use NewJobsClient() instead. type JobsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewJobsClient creates a new instance of JobsClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewJobsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*JobsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".JobsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &JobsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CancelJob - Cancel a Job. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// transformName - The Transform name. -// jobName - The Job name. -// options - JobsClientCancelJobOptions contains the optional parameters for the JobsClient.CancelJob method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - transformName - The Transform name. +// - jobName - The Job name. +// - options - JobsClientCancelJobOptions contains the optional parameters for the JobsClient.CancelJob method. func (client *JobsClient) CancelJob(ctx context.Context, resourceGroupName string, accountName string, transformName string, jobName string, options *JobsClientCancelJobOptions) (JobsClientCancelJobResponse, error) { req, err := client.cancelJobCreateRequest(ctx, resourceGroupName, accountName, transformName, jobName, options) if err != nil { return JobsClientCancelJobResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JobsClientCancelJobResponse{}, err } @@ -101,7 +91,7 @@ func (client *JobsClient) cancelJobCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter jobName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{jobName}", url.PathEscape(jobName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -114,19 +104,20 @@ func (client *JobsClient) cancelJobCreateRequest(ctx context.Context, resourceGr // Create - Creates a Job. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// transformName - The Transform name. -// jobName - The Job name. -// parameters - The request parameters -// options - JobsClientCreateOptions contains the optional parameters for the JobsClient.Create method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - transformName - The Transform name. +// - jobName - The Job name. +// - parameters - The request parameters +// - options - JobsClientCreateOptions contains the optional parameters for the JobsClient.Create method. func (client *JobsClient) Create(ctx context.Context, resourceGroupName string, accountName string, transformName string, jobName string, parameters Job, options *JobsClientCreateOptions) (JobsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, transformName, jobName, parameters, options) if err != nil { return JobsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JobsClientCreateResponse{}, err } @@ -159,7 +150,7 @@ func (client *JobsClient) createCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter jobName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{jobName}", url.PathEscape(jobName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -181,18 +172,19 @@ func (client *JobsClient) createHandleResponse(resp *http.Response) (JobsClientC // Delete - Deletes a Job. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// transformName - The Transform name. -// jobName - The Job name. -// options - JobsClientDeleteOptions contains the optional parameters for the JobsClient.Delete method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - transformName - The Transform name. +// - jobName - The Job name. +// - options - JobsClientDeleteOptions contains the optional parameters for the JobsClient.Delete method. func (client *JobsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, transformName string, jobName string, options *JobsClientDeleteOptions) (JobsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, transformName, jobName, options) if err != nil { return JobsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JobsClientDeleteResponse{}, err } @@ -225,7 +217,7 @@ func (client *JobsClient) deleteCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter jobName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{jobName}", url.PathEscape(jobName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -238,18 +230,19 @@ func (client *JobsClient) deleteCreateRequest(ctx context.Context, resourceGroup // Get - Gets a Job. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// transformName - The Transform name. -// jobName - The Job name. -// options - JobsClientGetOptions contains the optional parameters for the JobsClient.Get method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - transformName - The Transform name. +// - jobName - The Job name. +// - options - JobsClientGetOptions contains the optional parameters for the JobsClient.Get method. func (client *JobsClient) Get(ctx context.Context, resourceGroupName string, accountName string, transformName string, jobName string, options *JobsClientGetOptions) (JobsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, transformName, jobName, options) if err != nil { return JobsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JobsClientGetResponse{}, err } @@ -282,7 +275,7 @@ func (client *JobsClient) getCreateRequest(ctx context.Context, resourceGroupNam return nil, errors.New("parameter jobName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{jobName}", url.PathEscape(jobName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -303,11 +296,12 @@ func (client *JobsClient) getHandleResponse(resp *http.Response) (JobsClientGetR } // NewListPager - Lists all of the Jobs for the Transform. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// transformName - The Transform name. -// options - JobsClientListOptions contains the optional parameters for the JobsClient.List method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - transformName - The Transform name. +// - options - JobsClientListOptions contains the optional parameters for the JobsClient.NewListPager method. func (client *JobsClient) NewListPager(resourceGroupName string, accountName string, transformName string, options *JobsClientListOptions) *runtime.Pager[JobsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[JobsClientListResponse]{ More: func(page JobsClientListResponse) bool { @@ -324,7 +318,7 @@ func (client *JobsClient) NewListPager(resourceGroupName string, accountName str if err != nil { return JobsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JobsClientListResponse{}, err } @@ -355,7 +349,7 @@ func (client *JobsClient) listCreateRequest(ctx context.Context, resourceGroupNa return nil, errors.New("parameter transformName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{transformName}", url.PathEscape(transformName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -384,19 +378,20 @@ func (client *JobsClient) listHandleResponse(resp *http.Response) (JobsClientLis // Update - Update is only supported for description and priority. Updating Priority will take effect when the Job state is // Queued or Scheduled and depending on the timing the priority update may be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// transformName - The Transform name. -// jobName - The Job name. -// parameters - The request parameters -// options - JobsClientUpdateOptions contains the optional parameters for the JobsClient.Update method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - transformName - The Transform name. +// - jobName - The Job name. +// - parameters - The request parameters +// - options - JobsClientUpdateOptions contains the optional parameters for the JobsClient.Update method. func (client *JobsClient) Update(ctx context.Context, resourceGroupName string, accountName string, transformName string, jobName string, parameters Job, options *JobsClientUpdateOptions) (JobsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, transformName, jobName, parameters, options) if err != nil { return JobsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JobsClientUpdateResponse{}, err } @@ -429,7 +424,7 @@ func (client *JobsClient) updateCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter jobName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{jobName}", url.PathEscape(jobName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/jobs_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/jobs_client_example_test.go index 31c77113a5a2..28ade18cffca 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/jobs_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/jobs_client_example_test.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 armmediaservices_test @@ -17,219 +18,895 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-list-all-filter-by-created.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-list-all-filter-by-created.json func ExampleJobsClient_NewListPager_listsJobsForTheTransformFilterByCreated() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewJobsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contosoresources", "contosomedia", "exampleTransform", &armmediaservices.JobsClientListOptions{Filter: to.Ptr("properties/created ge 2021-06-01T00:00:10.0000000Z and properties/created le 2021-06-01T00:00:20.0000000Z"), + pager := clientFactory.NewJobsClient().NewListPager("contosoresources", "contosomedia", "exampleTransform", &armmediaservices.JobsClientListOptions{Filter: to.Ptr("properties/created ge 2021-06-01T00:00:10.0000000Z and properties/created le 2021-06-01T00:00:20.0000000Z"), Orderby: to.Ptr("properties/created"), }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.JobCollection = armmediaservices.JobCollection{ + // Value: []*armmediaservices.Job{ + // { + // Name: to.Ptr("job2"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job2"), + // Properties: &armmediaservices.JobProperties{ + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job2-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](50), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:33.2334355Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateProcessing), + // AssetName: to.Ptr("job2-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityLow), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:33.2334355Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateProcessing), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }, + // { + // Name: to.Ptr("job3"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job3"), + // Properties: &armmediaservices.JobProperties{ + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:20Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:33.2334355Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job3-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:20Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:33.2334355Z"); return t}()), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](100), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:33.2334355Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateFinished), + // AssetName: to.Ptr("job3-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityLow), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:33.2334355Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateFinished), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:20Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:20Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-list-all-filter-by-lastmodified.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-list-all-filter-by-lastmodified.json func ExampleJobsClient_NewListPager_listsJobsForTheTransformFilterByLastmodified() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewJobsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contosoresources", "contosomedia", "exampleTransform", &armmediaservices.JobsClientListOptions{Filter: to.Ptr("properties/lastmodified ge 2021-06-01T00:00:10.0000000Z and properties/lastmodified le 2021-06-01T00:00:20.0000000Z"), + pager := clientFactory.NewJobsClient().NewListPager("contosoresources", "contosomedia", "exampleTransform", &armmediaservices.JobsClientListOptions{Filter: to.Ptr("properties/lastmodified ge 2021-06-01T00:00:10.0000000Z and properties/lastmodified le 2021-06-01T00:00:20.0000000Z"), Orderby: to.Ptr("properties/lastmodified desc"), }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.JobCollection = armmediaservices.JobCollection{ + // Value: []*armmediaservices.Job{ + // { + // Name: to.Ptr("job3"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job3"), + // Properties: &armmediaservices.JobProperties{ + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:20Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:33.3623605Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job3-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:20Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:33.3623605Z"); return t}()), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](100), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:33.3623605Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateFinished), + // AssetName: to.Ptr("job3-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityLow), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:33.3623605Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateFinished), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:20Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:20Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }, + // { + // Name: to.Ptr("job2"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job2"), + // Properties: &armmediaservices.JobProperties{ + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job2-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](50), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:33.3623605Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateProcessing), + // AssetName: to.Ptr("job2-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityLow), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:33.3623605Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateProcessing), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-list-all-filter-by-name-and-state.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-list-all-filter-by-name-and-state.json func ExampleJobsClient_NewListPager_listsJobsForTheTransformFilterByNameAndState() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewJobsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contosoresources", "contosomedia", "exampleTransform", &armmediaservices.JobsClientListOptions{Filter: to.Ptr("name eq 'job3' and properties/state eq Microsoft.Media.JobState'finished'"), + pager := clientFactory.NewJobsClient().NewListPager("contosoresources", "contosomedia", "exampleTransform", &armmediaservices.JobsClientListOptions{Filter: to.Ptr("name eq 'job3' and properties/state eq Microsoft.Media.JobState'finished'"), Orderby: nil, }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.JobCollection = armmediaservices.JobCollection{ + // Value: []*armmediaservices.Job{ + // { + // Name: to.Ptr("job3"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job3"), + // Properties: &armmediaservices.JobProperties{ + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:33.1104174Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job3-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:33.1104174Z"); return t}()), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](100), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:33.1104174Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateFinished), + // AssetName: to.Ptr("job3-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityLow), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:33.1104174Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateFinished), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-list-all-filter-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-list-all-filter-by-name.json func ExampleJobsClient_NewListPager_listsJobsForTheTransformFilterByName() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewJobsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contosoresources", "contosomedia", "exampleTransform", &armmediaservices.JobsClientListOptions{Filter: to.Ptr("name eq 'job1' or name eq 'job2'"), + pager := clientFactory.NewJobsClient().NewListPager("contosoresources", "contosomedia", "exampleTransform", &armmediaservices.JobsClientListOptions{Filter: to.Ptr("name eq 'job1' or name eq 'job2'"), Orderby: to.Ptr("name"), }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.JobCollection = armmediaservices.JobCollection{ + // Value: []*armmediaservices.Job{ + // { + // Name: to.Ptr("job1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job1"), + // Properties: &armmediaservices.JobProperties{ + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job1-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](0), + // State: to.Ptr(armmediaservices.JobStateQueued), + // AssetName: to.Ptr("job1-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityLow), + // State: to.Ptr(armmediaservices.JobStateQueued), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }, + // { + // Name: to.Ptr("job2"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job2"), + // Properties: &armmediaservices.JobProperties{ + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job2-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](50), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:32.6894373Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateProcessing), + // AssetName: to.Ptr("job2-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityLow), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:32.6894373Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateProcessing), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-list-all-filter-by-state-eq.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-list-all-filter-by-state-eq.json func ExampleJobsClient_NewListPager_listsJobsForTheTransformFilterByStateEqual() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewJobsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contosoresources", "contosomedia", "exampleTransform", &armmediaservices.JobsClientListOptions{Filter: to.Ptr("properties/state eq Microsoft.Media.JobState'Processing'"), + pager := clientFactory.NewJobsClient().NewListPager("contosoresources", "contosomedia", "exampleTransform", &armmediaservices.JobsClientListOptions{Filter: to.Ptr("properties/state eq Microsoft.Media.JobState'Processing'"), Orderby: nil, }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.JobCollection = armmediaservices.JobCollection{ + // Value: []*armmediaservices.Job{ + // { + // Name: to.Ptr("job2"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job2"), + // Properties: &armmediaservices.JobProperties{ + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job2-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](50), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:32.8284289Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateProcessing), + // AssetName: to.Ptr("job2-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityLow), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:32.8284289Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateProcessing), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }, + // { + // Name: to.Ptr("job3"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job3"), + // Properties: &armmediaservices.JobProperties{ + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job3-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](50), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:32.8284289Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateProcessing), + // AssetName: to.Ptr("job3-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityLow), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:32.8284289Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateProcessing), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-list-all-filter-by-state-ne.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-list-all-filter-by-state-ne.json func ExampleJobsClient_NewListPager_listsJobsForTheTransformFilterByStateNotEqual() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewJobsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contosoresources", "contosomedia", "exampleTransform", &armmediaservices.JobsClientListOptions{Filter: to.Ptr("properties/state ne Microsoft.Media.JobState'processing'"), + pager := clientFactory.NewJobsClient().NewListPager("contosoresources", "contosomedia", "exampleTransform", &armmediaservices.JobsClientListOptions{Filter: to.Ptr("properties/state ne Microsoft.Media.JobState'processing'"), Orderby: nil, }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.JobCollection = armmediaservices.JobCollection{ + // Value: []*armmediaservices.Job{ + // { + // Name: to.Ptr("job1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job1"), + // Properties: &armmediaservices.JobProperties{ + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job1-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](0), + // State: to.Ptr(armmediaservices.JobStateQueued), + // AssetName: to.Ptr("job1-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityLow), + // State: to.Ptr(armmediaservices.JobStateQueued), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }, + // { + // Name: to.Ptr("job4"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job4"), + // Properties: &armmediaservices.JobProperties{ + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:33.0097637Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job4-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:33.0097637Z"); return t}()), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](100), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:33.0097637Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateFinished), + // AssetName: to.Ptr("job4-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityLow), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:33.0097637Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateFinished), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-list-all.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-list-all.json func ExampleJobsClient_NewListPager_listsAllOfTheJobsForTheTransform() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewJobsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contosoresources", "contosomedia", "exampleTransform", &armmediaservices.JobsClientListOptions{Filter: nil, + pager := clientFactory.NewJobsClient().NewListPager("contosoresources", "contosomedia", "exampleTransform", &armmediaservices.JobsClientListOptions{Filter: nil, Orderby: nil, }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.JobCollection = armmediaservices.JobCollection{ + // Value: []*armmediaservices.Job{ + // { + // Name: to.Ptr("job1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job1"), + // Properties: &armmediaservices.JobProperties{ + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job1-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](0), + // State: to.Ptr(armmediaservices.JobStateQueued), + // AssetName: to.Ptr("job1-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityLow), + // State: to.Ptr(armmediaservices.JobStateQueued), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }, + // { + // Name: to.Ptr("job2"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job2"), + // Properties: &armmediaservices.JobProperties{ + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job2-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](50), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:32.2462651Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateProcessing), + // AssetName: to.Ptr("job2-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityLow), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:32.2462651Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateProcessing), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }, + // { + // Name: to.Ptr("job3"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job3"), + // Properties: &armmediaservices.JobProperties{ + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:32.2462651Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job3-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:32.2462651Z"); return t}()), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](100), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:32.2462651Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateFinished), + // AssetName: to.Ptr("job3-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityLow), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:04:32.2462651Z"); return t}()), + // State: to.Ptr(armmediaservices.JobStateFinished), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-get-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-get-by-name.json func ExampleJobsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewJobsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contosoresources", "contosomedia", "exampleTransform", "job1", nil) + res, err := clientFactory.NewJobsClient().Get(ctx, "contosoresources", "contosomedia", "exampleTransform", "job1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Job = armmediaservices.Job{ + // Name: to.Ptr("job1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job1"), + // Properties: &armmediaservices.JobProperties{ + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job1-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](0), + // State: to.Ptr(armmediaservices.JobStateQueued), + // AssetName: to.Ptr("job1-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityLow), + // State: to.Ptr(armmediaservices.JobStateQueued), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-create.json func ExampleJobsClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewJobsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Create(ctx, "contosoresources", "contosomedia", "exampleTransform", "job1", armmediaservices.Job{ + _, err = clientFactory.NewJobsClient().Create(ctx, "contosoresources", "contosomedia", "exampleTransform", "job1", armmediaservices.Job{ Properties: &armmediaservices.JobProperties{ CorrelationData: map[string]*string{ "Key 2": to.Ptr("Value 2"), @@ -251,35 +928,35 @@ func ExampleJobsClient_Create() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-delete.json func ExampleJobsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewJobsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "contosoresources", "contosomedia", "exampleTransform", "jobToDelete", nil) + _, err = clientFactory.NewJobsClient().Delete(ctx, "contosoresources", "contosomedia", "exampleTransform", "jobToDelete", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-update.json func ExampleJobsClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewJobsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "contosoresources", "contosomedia", "exampleTransform", "job1", armmediaservices.Job{ + res, err := clientFactory.NewJobsClient().Update(ctx, "contosoresources", "contosomedia", "exampleTransform", "job1", armmediaservices.Job{ Properties: &armmediaservices.JobProperties{ Description: to.Ptr("Example job to illustrate update."), Input: &armmediaservices.JobInputAsset{ @@ -297,22 +974,65 @@ func ExampleJobsClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Job = armmediaservices.Job{ + // Name: to.Ptr("job1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/exampleTransform/jobs/job1"), + // Properties: &armmediaservices.JobProperties{ + // Description: to.Ptr("Example job to illustrate update."), + // CorrelationData: map[string]*string{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // Input: &armmediaservices.JobInputs{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputs"), + // Inputs: []armmediaservices.JobInputClassification{ + // &armmediaservices.JobInputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobInputAsset"), + // Files: []*string{ + // }, + // InputDefinitions: []armmediaservices.InputDefinitionClassification{ + // }, + // AssetName: to.Ptr("job1-InputAsset"), + // }}, + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:33.9584586Z"); return t}()), + // Outputs: []armmediaservices.JobOutputClassification{ + // &armmediaservices.JobOutputAsset{ + // ODataType: to.Ptr("#Microsoft.Media.JobOutputAsset"), + // Label: to.Ptr("example-custom-label"), + // Progress: to.Ptr[int32](0), + // State: to.Ptr(armmediaservices.JobStateQueued), + // AssetName: to.Ptr("job1-OutputAsset"), + // }}, + // Priority: to.Ptr(armmediaservices.PriorityHigh), + // State: to.Ptr(armmediaservices.JobStateQueued), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:00Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:33.9584586Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-cancel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-cancel.json func ExampleJobsClient_CancelJob() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewJobsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.CancelJob(ctx, "contosoresources", "contosomedia", "exampleTransform", "job1", nil) + _, err = clientFactory.NewJobsClient().CancelJob(ctx, "contosoresources", "contosomedia", "exampleTransform", "job1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/liveevents_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/liveevents_client.go index 8cded9e37c31..e8ae043887a6 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/liveevents_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/liveevents_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,64 +25,57 @@ import ( // LiveEventsClient contains the methods for the LiveEvents group. // Don't use this type directly, use NewLiveEventsClient() instead. type LiveEventsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewLiveEventsClient creates a new instance of LiveEventsClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewLiveEventsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LiveEventsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".LiveEventsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LiveEventsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginAllocate - A live event is in StandBy state after allocation completes, and is ready to start. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// liveEventName - The name of the live event, maximum length is 32. -// options - LiveEventsClientBeginAllocateOptions contains the optional parameters for the LiveEventsClient.BeginAllocate -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - liveEventName - The name of the live event, maximum length is 32. +// - options - LiveEventsClientBeginAllocateOptions contains the optional parameters for the LiveEventsClient.BeginAllocate +// method. func (client *LiveEventsClient) BeginAllocate(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, options *LiveEventsClientBeginAllocateOptions) (*runtime.Poller[LiveEventsClientAllocateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.allocate(ctx, resourceGroupName, accountName, liveEventName, options) if err != nil { return nil, err } - return runtime.NewPoller[LiveEventsClientAllocateResponse](resp, client.pl, nil) + return runtime.NewPoller[LiveEventsClientAllocateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LiveEventsClientAllocateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LiveEventsClientAllocateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Allocate - A live event is in StandBy state after allocation completes, and is ready to start. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *LiveEventsClient) allocate(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, options *LiveEventsClientBeginAllocateOptions) (*http.Response, error) { req, err := client.allocateCreateRequest(ctx, resourceGroupName, accountName, liveEventName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -113,7 +104,7 @@ func (client *LiveEventsClient) allocateCreateRequest(ctx context.Context, resou return nil, errors.New("parameter liveEventName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{liveEventName}", url.PathEscape(liveEventName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -126,18 +117,19 @@ func (client *LiveEventsClient) allocateCreateRequest(ctx context.Context, resou // AsyncOperation - Get a live event operation status. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// operationID - The ID of an ongoing async operation. -// options - LiveEventsClientAsyncOperationOptions contains the optional parameters for the LiveEventsClient.AsyncOperation -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - operationID - The ID of an ongoing async operation. +// - options - LiveEventsClientAsyncOperationOptions contains the optional parameters for the LiveEventsClient.AsyncOperation +// method. func (client *LiveEventsClient) AsyncOperation(ctx context.Context, resourceGroupName string, accountName string, operationID string, options *LiveEventsClientAsyncOperationOptions) (LiveEventsClientAsyncOperationResponse, error) { req, err := client.asyncOperationCreateRequest(ctx, resourceGroupName, accountName, operationID, options) if err != nil { return LiveEventsClientAsyncOperationResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LiveEventsClientAsyncOperationResponse{}, err } @@ -166,7 +158,7 @@ func (client *LiveEventsClient) asyncOperationCreateRequest(ctx context.Context, return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -188,33 +180,35 @@ func (client *LiveEventsClient) asyncOperationHandleResponse(resp *http.Response // BeginCreate - Creates a new live event. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// liveEventName - The name of the live event, maximum length is 32. -// parameters - Live event properties needed for creation. -// options - LiveEventsClientBeginCreateOptions contains the optional parameters for the LiveEventsClient.BeginCreate method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - liveEventName - The name of the live event, maximum length is 32. +// - parameters - Live event properties needed for creation. +// - options - LiveEventsClientBeginCreateOptions contains the optional parameters for the LiveEventsClient.BeginCreate method. func (client *LiveEventsClient) BeginCreate(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, parameters LiveEvent, options *LiveEventsClientBeginCreateOptions) (*runtime.Poller[LiveEventsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, accountName, liveEventName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[LiveEventsClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[LiveEventsClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LiveEventsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LiveEventsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Creates a new live event. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *LiveEventsClient) create(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, parameters LiveEvent, options *LiveEventsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, liveEventName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -243,7 +237,7 @@ func (client *LiveEventsClient) createCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter liveEventName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{liveEventName}", url.PathEscape(liveEventName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -259,32 +253,34 @@ func (client *LiveEventsClient) createCreateRequest(ctx context.Context, resourc // BeginDelete - Deletes a live event. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// liveEventName - The name of the live event, maximum length is 32. -// options - LiveEventsClientBeginDeleteOptions contains the optional parameters for the LiveEventsClient.BeginDelete method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - liveEventName - The name of the live event, maximum length is 32. +// - options - LiveEventsClientBeginDeleteOptions contains the optional parameters for the LiveEventsClient.BeginDelete method. func (client *LiveEventsClient) BeginDelete(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, options *LiveEventsClientBeginDeleteOptions) (*runtime.Poller[LiveEventsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, accountName, liveEventName, options) if err != nil { return nil, err } - return runtime.NewPoller[LiveEventsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[LiveEventsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LiveEventsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LiveEventsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a live event. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *LiveEventsClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, options *LiveEventsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, liveEventName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -313,7 +309,7 @@ func (client *LiveEventsClient) deleteCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter liveEventName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{liveEventName}", url.PathEscape(liveEventName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -326,17 +322,18 @@ func (client *LiveEventsClient) deleteCreateRequest(ctx context.Context, resourc // Get - Gets properties of a live event. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// liveEventName - The name of the live event, maximum length is 32. -// options - LiveEventsClientGetOptions contains the optional parameters for the LiveEventsClient.Get method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - liveEventName - The name of the live event, maximum length is 32. +// - options - LiveEventsClientGetOptions contains the optional parameters for the LiveEventsClient.Get method. func (client *LiveEventsClient) Get(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, options *LiveEventsClientGetOptions) (LiveEventsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, liveEventName, options) if err != nil { return LiveEventsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LiveEventsClientGetResponse{}, err } @@ -365,7 +362,7 @@ func (client *LiveEventsClient) getCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter liveEventName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{liveEventName}", url.PathEscape(liveEventName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -386,10 +383,11 @@ func (client *LiveEventsClient) getHandleResponse(resp *http.Response) (LiveEven } // NewListPager - Lists all the live events in the account. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// options - LiveEventsClientListOptions contains the optional parameters for the LiveEventsClient.List method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - options - LiveEventsClientListOptions contains the optional parameters for the LiveEventsClient.NewListPager method. func (client *LiveEventsClient) NewListPager(resourceGroupName string, accountName string, options *LiveEventsClientListOptions) *runtime.Pager[LiveEventsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[LiveEventsClientListResponse]{ More: func(page LiveEventsClientListResponse) bool { @@ -406,7 +404,7 @@ func (client *LiveEventsClient) NewListPager(resourceGroupName string, accountNa if err != nil { return LiveEventsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LiveEventsClientListResponse{}, err } @@ -433,7 +431,7 @@ func (client *LiveEventsClient) listCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -455,19 +453,20 @@ func (client *LiveEventsClient) listHandleResponse(resp *http.Response) (LiveEve // OperationLocation - Get a live event operation status. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// liveEventName - The name of the live event, maximum length is 32. -// operationID - The ID of an ongoing async operation. -// options - LiveEventsClientOperationLocationOptions contains the optional parameters for the LiveEventsClient.OperationLocation -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - liveEventName - The name of the live event, maximum length is 32. +// - operationID - The ID of an ongoing async operation. +// - options - LiveEventsClientOperationLocationOptions contains the optional parameters for the LiveEventsClient.OperationLocation +// method. func (client *LiveEventsClient) OperationLocation(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, operationID string, options *LiveEventsClientOperationLocationOptions) (LiveEventsClientOperationLocationResponse, error) { req, err := client.operationLocationCreateRequest(ctx, resourceGroupName, accountName, liveEventName, operationID, options) if err != nil { return LiveEventsClientOperationLocationResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LiveEventsClientOperationLocationResponse{}, err } @@ -500,7 +499,7 @@ func (client *LiveEventsClient) operationLocationCreateRequest(ctx context.Conte return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -524,20 +523,21 @@ func (client *LiveEventsClient) operationLocationHandleResponse(resp *http.Respo // and will be started again. All assets used by the live outputs and streaming locators // created on these assets are unaffected. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// liveEventName - The name of the live event, maximum length is 32. -// options - LiveEventsClientBeginResetOptions contains the optional parameters for the LiveEventsClient.BeginReset method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - liveEventName - The name of the live event, maximum length is 32. +// - options - LiveEventsClientBeginResetOptions contains the optional parameters for the LiveEventsClient.BeginReset method. func (client *LiveEventsClient) BeginReset(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, options *LiveEventsClientBeginResetOptions) (*runtime.Poller[LiveEventsClientResetResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.reset(ctx, resourceGroupName, accountName, liveEventName, options) if err != nil { return nil, err } - return runtime.NewPoller[LiveEventsClientResetResponse](resp, client.pl, nil) + return runtime.NewPoller[LiveEventsClientResetResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LiveEventsClientResetResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LiveEventsClientResetResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -545,13 +545,14 @@ func (client *LiveEventsClient) BeginReset(ctx context.Context, resourceGroupNam // will be started again. All assets used by the live outputs and streaming locators // created on these assets are unaffected. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *LiveEventsClient) reset(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, options *LiveEventsClientBeginResetOptions) (*http.Response, error) { req, err := client.resetCreateRequest(ctx, resourceGroupName, accountName, liveEventName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -580,7 +581,7 @@ func (client *LiveEventsClient) resetCreateRequest(ctx context.Context, resource return nil, errors.New("parameter liveEventName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{liveEventName}", url.PathEscape(liveEventName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -593,32 +594,34 @@ func (client *LiveEventsClient) resetCreateRequest(ctx context.Context, resource // BeginStart - A live event in Stopped or StandBy state will be in Running state after the start operation completes. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// liveEventName - The name of the live event, maximum length is 32. -// options - LiveEventsClientBeginStartOptions contains the optional parameters for the LiveEventsClient.BeginStart method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - liveEventName - The name of the live event, maximum length is 32. +// - options - LiveEventsClientBeginStartOptions contains the optional parameters for the LiveEventsClient.BeginStart method. func (client *LiveEventsClient) BeginStart(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, options *LiveEventsClientBeginStartOptions) (*runtime.Poller[LiveEventsClientStartResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.start(ctx, resourceGroupName, accountName, liveEventName, options) if err != nil { return nil, err } - return runtime.NewPoller[LiveEventsClientStartResponse](resp, client.pl, nil) + return runtime.NewPoller[LiveEventsClientStartResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LiveEventsClientStartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LiveEventsClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Start - A live event in Stopped or StandBy state will be in Running state after the start operation completes. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *LiveEventsClient) start(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, options *LiveEventsClientBeginStartOptions) (*http.Response, error) { req, err := client.startCreateRequest(ctx, resourceGroupName, accountName, liveEventName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -647,7 +650,7 @@ func (client *LiveEventsClient) startCreateRequest(ctx context.Context, resource return nil, errors.New("parameter liveEventName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{liveEventName}", url.PathEscape(liveEventName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -660,33 +663,35 @@ func (client *LiveEventsClient) startCreateRequest(ctx context.Context, resource // BeginStop - Stops a running live event. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// liveEventName - The name of the live event, maximum length is 32. -// parameters - LiveEvent stop parameters -// options - LiveEventsClientBeginStopOptions contains the optional parameters for the LiveEventsClient.BeginStop method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - liveEventName - The name of the live event, maximum length is 32. +// - parameters - LiveEvent stop parameters +// - options - LiveEventsClientBeginStopOptions contains the optional parameters for the LiveEventsClient.BeginStop method. func (client *LiveEventsClient) BeginStop(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, parameters LiveEventActionInput, options *LiveEventsClientBeginStopOptions) (*runtime.Poller[LiveEventsClientStopResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.stop(ctx, resourceGroupName, accountName, liveEventName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[LiveEventsClientStopResponse](resp, client.pl, nil) + return runtime.NewPoller[LiveEventsClientStopResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LiveEventsClientStopResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LiveEventsClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Stop - Stops a running live event. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *LiveEventsClient) stop(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, parameters LiveEventActionInput, options *LiveEventsClientBeginStopOptions) (*http.Response, error) { req, err := client.stopCreateRequest(ctx, resourceGroupName, accountName, liveEventName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -715,7 +720,7 @@ func (client *LiveEventsClient) stopCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter liveEventName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{liveEventName}", url.PathEscape(liveEventName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -728,33 +733,35 @@ func (client *LiveEventsClient) stopCreateRequest(ctx context.Context, resourceG // BeginUpdate - Updates settings on an existing live event. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// liveEventName - The name of the live event, maximum length is 32. -// parameters - Live event properties needed for patch. -// options - LiveEventsClientBeginUpdateOptions contains the optional parameters for the LiveEventsClient.BeginUpdate method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - liveEventName - The name of the live event, maximum length is 32. +// - parameters - Live event properties needed for patch. +// - options - LiveEventsClientBeginUpdateOptions contains the optional parameters for the LiveEventsClient.BeginUpdate method. func (client *LiveEventsClient) BeginUpdate(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, parameters LiveEvent, options *LiveEventsClientBeginUpdateOptions) (*runtime.Poller[LiveEventsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, accountName, liveEventName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[LiveEventsClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[LiveEventsClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LiveEventsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LiveEventsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates settings on an existing live event. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *LiveEventsClient) update(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, parameters LiveEvent, options *LiveEventsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, liveEventName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -783,7 +790,7 @@ func (client *LiveEventsClient) updateCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter liveEventName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{liveEventName}", url.PathEscape(liveEventName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/liveevents_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/liveevents_client_example_test.go index 1f5474643f7a..72497ad21e21 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/liveevents_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/liveevents_client_example_test.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 armmediaservices_test @@ -17,61 +18,171 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-list-all.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-list-all.json func ExampleLiveEventsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveEventsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("mediaresources", "slitestmedia10", nil) + pager := clientFactory.NewLiveEventsClient().NewListPager("mediaresources", "slitestmedia10", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.LiveEventListResult = armmediaservices.LiveEventListResult{ + // Value: []*armmediaservices.LiveEvent{ + // { + // Name: to.Ptr("myLiveEvent1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/liveevents"), + // ID: to.Ptr("/subscriptions/0a6ec948-5a62-437d-b9df-934dc7c1b722/resourceGroups/mediaresources/providers/Microsoft.Media/mediaservices/slitestmedia10/liveevents/myLiveEvent1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armmediaservices.LiveEventProperties{ + // Description: to.Ptr("test event 1"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:08.5564064Z"); return t}()), + // CrossSiteAccessPolicies: &armmediaservices.CrossSiteAccessPolicies{ + // }, + // Encoding: &armmediaservices.LiveEventEncoding{ + // EncodingType: to.Ptr(armmediaservices.LiveEventEncodingTypeNone), + // }, + // Input: &armmediaservices.LiveEventInput{ + // AccessToken: to.Ptr(""), + // Endpoints: []*armmediaservices.LiveEventEndpoint{ + // { + // URL: to.Ptr("http://clouddeployment.media-test.net/de153bb0814542d9b7e2339ce9430dc4/ingest.isml"), + // Protocol: to.Ptr("FragmentedMP4"), + // }}, + // KeyFrameIntervalDuration: to.Ptr("PT6S"), + // StreamingProtocol: to.Ptr(armmediaservices.LiveEventInputProtocolFragmentedMP4), + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:08.5564064Z"); return t}()), + // Preview: &armmediaservices.LiveEventPreview{ + // AccessControl: &armmediaservices.LiveEventPreviewAccessControl{ + // IP: &armmediaservices.IPAccessControl{ + // Allow: []*armmediaservices.IPRange{ + // { + // Name: to.Ptr("AllowAll"), + // Address: to.Ptr("0.0.0.0"), + // SubnetPrefixLength: to.Ptr[int32](0), + // }}, + // }, + // }, + // Endpoints: []*armmediaservices.LiveEventEndpoint{ + // { + // URL: to.Ptr("https://myliveevent1-slitestmedia10.preview-usso.channel.mediaservices.windows.net/a220e223-faf8-4e03-b9a9-2c2432f48025/preview.ism/manifest"), + // Protocol: to.Ptr("FragmentedMP4"), + // }}, + // PreviewLocator: to.Ptr("a220e223-faf8-4e03-b9a9-2c2432f48025"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armmediaservices.LiveEventResourceStateStopped), + // StreamOptions: []*armmediaservices.StreamOptionsFlag{ + // }, + // UseStaticHostname: to.Ptr(false), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-list-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-list-by-name.json func ExampleLiveEventsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveEventsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", nil) + res, err := clientFactory.NewLiveEventsClient().Get(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.LiveEvent = armmediaservices.LiveEvent{ + // Name: to.Ptr("myLiveEvent1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/liveevents"), + // ID: to.Ptr("/subscriptions/0a6ec948-5a62-437d-b9df-934dc7c1b722/resourceGroups/mediaresources/providers/Microsoft.Media/mediaservices/slitestmedia10/liveevents/myLiveEvent1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Properties: &armmediaservices.LiveEventProperties{ + // Description: to.Ptr(""), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:08.3474032Z"); return t}()), + // CrossSiteAccessPolicies: &armmediaservices.CrossSiteAccessPolicies{ + // ClientAccessPolicy: to.Ptr(""), + // CrossDomainPolicy: to.Ptr(""), + // }, + // Encoding: &armmediaservices.LiveEventEncoding{ + // EncodingType: to.Ptr(armmediaservices.LiveEventEncodingTypeNone), + // }, + // Input: &armmediaservices.LiveEventInput{ + // Endpoints: []*armmediaservices.LiveEventEndpoint{ + // { + // URL: to.Ptr("http://clouddeployment.media-test.net/ingest.isml"), + // Protocol: to.Ptr("FragmentedMP4"), + // }}, + // KeyFrameIntervalDuration: to.Ptr("PT6S"), + // StreamingProtocol: to.Ptr(armmediaservices.LiveEventInputProtocolFragmentedMP4), + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:08.3474032Z"); return t}()), + // Preview: &armmediaservices.LiveEventPreview{ + // AccessControl: &armmediaservices.LiveEventPreviewAccessControl{ + // IP: &armmediaservices.IPAccessControl{ + // Allow: []*armmediaservices.IPRange{ + // { + // Name: to.Ptr("AllowAll"), + // Address: to.Ptr("0.0.0.0"), + // SubnetPrefixLength: to.Ptr[int32](0), + // }}, + // }, + // }, + // Endpoints: []*armmediaservices.LiveEventEndpoint{ + // { + // URL: to.Ptr("https://testeventopito4idh2r-weibzmedia05.preview-ts051.channel.media-test.windows-int.net/763f3ea4-d94f-441c-a634-c833f61a4e04/preview.ism/manifest"), + // Protocol: to.Ptr("FragmentedMP4"), + // }}, + // PreviewLocator: to.Ptr("763f3ea4-d94f-441c-a634-c833f61a4e04"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armmediaservices.LiveEventResourceStateStopped), + // StreamOptions: []*armmediaservices.StreamOptionsFlag{ + // to.Ptr(armmediaservices.StreamOptionsFlagDefault)}, + // UseStaticHostname: to.Ptr(false), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-create.json func ExampleLiveEventsClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveEventsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", armmediaservices.LiveEvent{ + poller, err := clientFactory.NewLiveEventsClient().BeginCreate(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", armmediaservices.LiveEvent{ Location: to.Ptr("West US"), Tags: map[string]*string{ "tag1": to.Ptr("value1"), @@ -114,22 +225,80 @@ func ExampleLiveEventsClient_BeginCreate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.LiveEvent = armmediaservices.LiveEvent{ + // Name: to.Ptr("myLiveEvent1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/liveevents"), + // ID: to.Ptr("/subscriptions/0a6ec948-5a62-437d-b9df-934dc7c1b722/resourceGroups/mediaresources/providers/Microsoft.Media/mediaservices/slitestmedia10/liveevents/myLiveEvent1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armmediaservices.LiveEventProperties{ + // Description: to.Ptr("test event 1"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:06.0982751Z"); return t}()), + // CrossSiteAccessPolicies: &armmediaservices.CrossSiteAccessPolicies{ + // }, + // Encoding: &armmediaservices.LiveEventEncoding{ + // EncodingType: to.Ptr(armmediaservices.LiveEventEncodingTypeNone), + // }, + // Input: &armmediaservices.LiveEventInput{ + // AccessControl: &armmediaservices.LiveEventInputAccessControl{ + // IP: &armmediaservices.IPAccessControl{ + // Allow: []*armmediaservices.IPRange{ + // { + // Name: to.Ptr("AllowAll"), + // Address: to.Ptr("0.0.0.0"), + // SubnetPrefixLength: to.Ptr[int32](0), + // }}, + // }, + // }, + // AccessToken: to.Ptr(""), + // Endpoints: []*armmediaservices.LiveEventEndpoint{ + // }, + // KeyFrameIntervalDuration: to.Ptr("PT6S"), + // StreamingProtocol: to.Ptr(armmediaservices.LiveEventInputProtocolFragmentedMP4), + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:06.0982751Z"); return t}()), + // Preview: &armmediaservices.LiveEventPreview{ + // AccessControl: &armmediaservices.LiveEventPreviewAccessControl{ + // IP: &armmediaservices.IPAccessControl{ + // Allow: []*armmediaservices.IPRange{ + // { + // Name: to.Ptr("AllowAll"), + // Address: to.Ptr("0.0.0.0"), + // SubnetPrefixLength: to.Ptr[int32](0), + // }}, + // }, + // }, + // Endpoints: []*armmediaservices.LiveEventEndpoint{ + // }, + // PreviewLocator: to.Ptr("c91726b4-880c-4090-94aa-e6ddb1384b37"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armmediaservices.LiveEventResourceStateStopped), + // StreamOptions: []*armmediaservices.StreamOptionsFlag{ + // }, + // UseStaticHostname: to.Ptr(false), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-update.json func ExampleLiveEventsClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveEventsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", armmediaservices.LiveEvent{ + poller, err := clientFactory.NewLiveEventsClient().BeginUpdate(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", armmediaservices.LiveEvent{ Location: to.Ptr("West US"), Tags: map[string]*string{ "tag1": to.Ptr("value1"), @@ -171,22 +340,77 @@ func ExampleLiveEventsClient_BeginUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.LiveEvent = armmediaservices.LiveEvent{ + // Name: to.Ptr("myLiveEvent1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/liveevents"), + // ID: to.Ptr("/subscriptions/0a6ec948-5a62-437d-b9df-934dc7c1b722/resourceGroups/mediaresources/providers/Microsoft.Media/mediaservices/slitestmedia10/liveevents/myLiveEvent1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // "tag3": to.Ptr("value3"), + // }, + // Properties: &armmediaservices.LiveEventProperties{ + // Description: to.Ptr("test event updated"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00Z"); return t}()), + // Encoding: &armmediaservices.LiveEventEncoding{ + // EncodingType: to.Ptr(armmediaservices.LiveEventEncodingTypeNone), + // }, + // Input: &armmediaservices.LiveEventInput{ + // AccessControl: &armmediaservices.LiveEventInputAccessControl{ + // IP: &armmediaservices.IPAccessControl{ + // Allow: []*armmediaservices.IPRange{ + // { + // Name: to.Ptr("AllowOne"), + // Address: to.Ptr("192.1.1.0"), + // }}, + // }, + // }, + // AccessToken: to.Ptr(""), + // Endpoints: []*armmediaservices.LiveEventEndpoint{ + // }, + // KeyFrameIntervalDuration: to.Ptr("PT6S"), + // StreamingProtocol: to.Ptr(armmediaservices.LiveEventInputProtocolFragmentedMP4), + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00Z"); return t}()), + // Preview: &armmediaservices.LiveEventPreview{ + // AccessControl: &armmediaservices.LiveEventPreviewAccessControl{ + // IP: &armmediaservices.IPAccessControl{ + // Allow: []*armmediaservices.IPRange{ + // { + // Name: to.Ptr("AllowOne"), + // Address: to.Ptr("192.1.1.0"), + // }}, + // }, + // }, + // Endpoints: []*armmediaservices.LiveEventEndpoint{ + // }, + // PreviewLocator: to.Ptr("c10ea3fc-587f-4daf-b2b2-fa8f647a9ed2"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armmediaservices.LiveEventResourceStateRunning), + // StreamOptions: []*armmediaservices.StreamOptionsFlag{ + // }, + // UseStaticHostname: to.Ptr(false), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-delete.json func ExampleLiveEventsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveEventsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", nil) + poller, err := clientFactory.NewLiveEventsClient().BeginDelete(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -196,18 +420,18 @@ func ExampleLiveEventsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-allocate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-allocate.json func ExampleLiveEventsClient_BeginAllocate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveEventsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginAllocate(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", nil) + poller, err := clientFactory.NewLiveEventsClient().BeginAllocate(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -217,18 +441,18 @@ func ExampleLiveEventsClient_BeginAllocate() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-start.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-start.json func ExampleLiveEventsClient_BeginStart() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveEventsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginStart(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", nil) + poller, err := clientFactory.NewLiveEventsClient().BeginStart(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -238,18 +462,18 @@ func ExampleLiveEventsClient_BeginStart() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-stop.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-stop.json func ExampleLiveEventsClient_BeginStop() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveEventsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginStop(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", armmediaservices.LiveEventActionInput{ + poller, err := clientFactory.NewLiveEventsClient().BeginStop(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", armmediaservices.LiveEventActionInput{ RemoveOutputsOnStop: to.Ptr(false), }, nil) if err != nil { @@ -261,18 +485,18 @@ func ExampleLiveEventsClient_BeginStop() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-reset.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-reset.json func ExampleLiveEventsClient_BeginReset() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveEventsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginReset(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", nil) + poller, err := clientFactory.NewLiveEventsClient().BeginReset(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -282,40 +506,110 @@ func ExampleLiveEventsClient_BeginReset() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/async-operation-result.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/async-operation-result.json func ExampleLiveEventsClient_AsyncOperation() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveEventsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.AsyncOperation(ctx, "mediaresources", "slitestmedia10", "62e4d893-d233-4005-988e-a428d9f77076", nil) + res, err := clientFactory.NewLiveEventsClient().AsyncOperation(ctx, "mediaresources", "slitestmedia10", "62e4d893-d233-4005-988e-a428d9f77076", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AsyncOperationResult = armmediaservices.AsyncOperationResult{ + // Name: to.Ptr("62e4d893-d233-4005-988e-a428d9f77076"), + // Error: &armmediaservices.ErrorDetail{ + // Code: to.Ptr("None"), + // Target: to.Ptr("d7aea790-8acb-40b9-8f9f-21cc37c9e519"), + // }, + // Status: to.Ptr(armmediaservices.AsyncOperationStatusInProgress), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-operation-location.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-operation-location.json func ExampleLiveEventsClient_OperationLocation() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveEventsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.OperationLocation(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", "62e4d893-d233-4005-988e-a428d9f77076", nil) + res, err := clientFactory.NewLiveEventsClient().OperationLocation(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", "62e4d893-d233-4005-988e-a428d9f77076", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.LiveEvent = armmediaservices.LiveEvent{ + // Name: to.Ptr("myLiveEvent1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/liveevents"), + // ID: to.Ptr("/subscriptions/0a6ec948-5a62-437d-b9df-934dc7c1b722/resourceGroups/mediaresources/providers/Microsoft.Media/mediaservices/slitestmedia10/liveevents/myLiveEvent1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Properties: &armmediaservices.LiveEventProperties{ + // Description: to.Ptr(""), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:08.3474032Z"); return t}()), + // CrossSiteAccessPolicies: &armmediaservices.CrossSiteAccessPolicies{ + // ClientAccessPolicy: to.Ptr(""), + // CrossDomainPolicy: to.Ptr(""), + // }, + // Encoding: &armmediaservices.LiveEventEncoding{ + // EncodingType: to.Ptr(armmediaservices.LiveEventEncodingTypeNone), + // }, + // Input: &armmediaservices.LiveEventInput{ + // Endpoints: []*armmediaservices.LiveEventEndpoint{ + // { + // URL: to.Ptr("http://clouddeployment.media-test.net/ingest.isml"), + // Protocol: to.Ptr("FragmentedMP4"), + // }}, + // KeyFrameIntervalDuration: to.Ptr("PT6S"), + // StreamingProtocol: to.Ptr(armmediaservices.LiveEventInputProtocolFragmentedMP4), + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:08.3474032Z"); return t}()), + // Preview: &armmediaservices.LiveEventPreview{ + // AccessControl: &armmediaservices.LiveEventPreviewAccessControl{ + // IP: &armmediaservices.IPAccessControl{ + // Allow: []*armmediaservices.IPRange{ + // { + // Name: to.Ptr("AllowAll"), + // Address: to.Ptr("0.0.0.0"), + // SubnetPrefixLength: to.Ptr[int32](0), + // }}, + // }, + // }, + // Endpoints: []*armmediaservices.LiveEventEndpoint{ + // { + // URL: to.Ptr("https://testeventopito4idh2r-weibzmedia05.preview-ts051.channel.media-test.windows-int.net/763f3ea4-d94f-441c-a634-c833f61a4e04/preview.ism/manifest"), + // Protocol: to.Ptr("FragmentedMP4"), + // }}, + // PreviewLocator: to.Ptr("763f3ea4-d94f-441c-a634-c833f61a4e04"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armmediaservices.LiveEventResourceStateStopped), + // StreamOptions: []*armmediaservices.StreamOptionsFlag{ + // to.Ptr(armmediaservices.StreamOptionsFlagDefault)}, + // UseStaticHostname: to.Ptr(false), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:08.3474032Z"); return t}()), + // CreatedBy: to.Ptr("example@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:08.3474032Z"); return t}()), + // LastModifiedBy: to.Ptr("example@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/liveoutputs_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/liveoutputs_client.go index 62051711e29a..f96ec16f97e5 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/liveoutputs_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/liveoutputs_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,49 +24,41 @@ import ( // LiveOutputsClient contains the methods for the LiveOutputs group. // Don't use this type directly, use NewLiveOutputsClient() instead. type LiveOutputsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewLiveOutputsClient creates a new instance of LiveOutputsClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewLiveOutputsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LiveOutputsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".LiveOutputsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LiveOutputsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // AsyncOperation - Get a Live Output operation status. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// operationID - The ID of an ongoing async operation. -// options - LiveOutputsClientAsyncOperationOptions contains the optional parameters for the LiveOutputsClient.AsyncOperation -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - operationID - The ID of an ongoing async operation. +// - options - LiveOutputsClientAsyncOperationOptions contains the optional parameters for the LiveOutputsClient.AsyncOperation +// method. func (client *LiveOutputsClient) AsyncOperation(ctx context.Context, resourceGroupName string, accountName string, operationID string, options *LiveOutputsClientAsyncOperationOptions) (LiveOutputsClientAsyncOperationResponse, error) { req, err := client.asyncOperationCreateRequest(ctx, resourceGroupName, accountName, operationID, options) if err != nil { return LiveOutputsClientAsyncOperationResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LiveOutputsClientAsyncOperationResponse{}, err } @@ -97,7 +87,7 @@ func (client *LiveOutputsClient) asyncOperationCreateRequest(ctx context.Context return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -119,34 +109,36 @@ func (client *LiveOutputsClient) asyncOperationHandleResponse(resp *http.Respons // BeginCreate - Creates a new live output. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// liveEventName - The name of the live event, maximum length is 32. -// liveOutputName - The name of the live output. -// parameters - Live Output properties needed for creation. -// options - LiveOutputsClientBeginCreateOptions contains the optional parameters for the LiveOutputsClient.BeginCreate method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - liveEventName - The name of the live event, maximum length is 32. +// - liveOutputName - The name of the live output. +// - parameters - Live Output properties needed for creation. +// - options - LiveOutputsClientBeginCreateOptions contains the optional parameters for the LiveOutputsClient.BeginCreate method. func (client *LiveOutputsClient) BeginCreate(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, liveOutputName string, parameters LiveOutput, options *LiveOutputsClientBeginCreateOptions) (*runtime.Poller[LiveOutputsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, accountName, liveEventName, liveOutputName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[LiveOutputsClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[LiveOutputsClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LiveOutputsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LiveOutputsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Creates a new live output. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *LiveOutputsClient) create(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, liveOutputName string, parameters LiveOutput, options *LiveOutputsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, liveEventName, liveOutputName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -179,7 +171,7 @@ func (client *LiveOutputsClient) createCreateRequest(ctx context.Context, resour return nil, errors.New("parameter liveOutputName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{liveOutputName}", url.PathEscape(liveOutputName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -192,33 +184,35 @@ func (client *LiveOutputsClient) createCreateRequest(ctx context.Context, resour // BeginDelete - Deletes a live output. Deleting a live output does not delete the asset the live output is writing to. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// liveEventName - The name of the live event, maximum length is 32. -// liveOutputName - The name of the live output. -// options - LiveOutputsClientBeginDeleteOptions contains the optional parameters for the LiveOutputsClient.BeginDelete method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - liveEventName - The name of the live event, maximum length is 32. +// - liveOutputName - The name of the live output. +// - options - LiveOutputsClientBeginDeleteOptions contains the optional parameters for the LiveOutputsClient.BeginDelete method. func (client *LiveOutputsClient) BeginDelete(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, liveOutputName string, options *LiveOutputsClientBeginDeleteOptions) (*runtime.Poller[LiveOutputsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, accountName, liveEventName, liveOutputName, options) if err != nil { return nil, err } - return runtime.NewPoller[LiveOutputsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[LiveOutputsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LiveOutputsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LiveOutputsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a live output. Deleting a live output does not delete the asset the live output is writing to. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *LiveOutputsClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, liveOutputName string, options *LiveOutputsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, liveEventName, liveOutputName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -251,7 +245,7 @@ func (client *LiveOutputsClient) deleteCreateRequest(ctx context.Context, resour return nil, errors.New("parameter liveOutputName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{liveOutputName}", url.PathEscape(liveOutputName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -264,18 +258,19 @@ func (client *LiveOutputsClient) deleteCreateRequest(ctx context.Context, resour // Get - Gets a live output. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// liveEventName - The name of the live event, maximum length is 32. -// liveOutputName - The name of the live output. -// options - LiveOutputsClientGetOptions contains the optional parameters for the LiveOutputsClient.Get method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - liveEventName - The name of the live event, maximum length is 32. +// - liveOutputName - The name of the live output. +// - options - LiveOutputsClientGetOptions contains the optional parameters for the LiveOutputsClient.Get method. func (client *LiveOutputsClient) Get(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, liveOutputName string, options *LiveOutputsClientGetOptions) (LiveOutputsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, liveEventName, liveOutputName, options) if err != nil { return LiveOutputsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LiveOutputsClientGetResponse{}, err } @@ -308,7 +303,7 @@ func (client *LiveOutputsClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter liveOutputName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{liveOutputName}", url.PathEscape(liveOutputName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -329,11 +324,12 @@ func (client *LiveOutputsClient) getHandleResponse(resp *http.Response) (LiveOut } // NewListPager - Lists the live outputs of a live event. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// liveEventName - The name of the live event, maximum length is 32. -// options - LiveOutputsClientListOptions contains the optional parameters for the LiveOutputsClient.List method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - liveEventName - The name of the live event, maximum length is 32. +// - options - LiveOutputsClientListOptions contains the optional parameters for the LiveOutputsClient.NewListPager method. func (client *LiveOutputsClient) NewListPager(resourceGroupName string, accountName string, liveEventName string, options *LiveOutputsClientListOptions) *runtime.Pager[LiveOutputsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[LiveOutputsClientListResponse]{ More: func(page LiveOutputsClientListResponse) bool { @@ -350,7 +346,7 @@ func (client *LiveOutputsClient) NewListPager(resourceGroupName string, accountN if err != nil { return LiveOutputsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LiveOutputsClientListResponse{}, err } @@ -381,7 +377,7 @@ func (client *LiveOutputsClient) listCreateRequest(ctx context.Context, resource return nil, errors.New("parameter liveEventName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{liveEventName}", url.PathEscape(liveEventName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -403,20 +399,21 @@ func (client *LiveOutputsClient) listHandleResponse(resp *http.Response) (LiveOu // OperationLocation - Get a Live Output operation status. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// liveEventName - The name of the live event, maximum length is 32. -// liveOutputName - The name of the live output. -// operationID - The ID of an ongoing async operation. -// options - LiveOutputsClientOperationLocationOptions contains the optional parameters for the LiveOutputsClient.OperationLocation -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - liveEventName - The name of the live event, maximum length is 32. +// - liveOutputName - The name of the live output. +// - operationID - The ID of an ongoing async operation. +// - options - LiveOutputsClientOperationLocationOptions contains the optional parameters for the LiveOutputsClient.OperationLocation +// method. func (client *LiveOutputsClient) OperationLocation(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, liveOutputName string, operationID string, options *LiveOutputsClientOperationLocationOptions) (LiveOutputsClientOperationLocationResponse, error) { req, err := client.operationLocationCreateRequest(ctx, resourceGroupName, accountName, liveEventName, liveOutputName, operationID, options) if err != nil { return LiveOutputsClientOperationLocationResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LiveOutputsClientOperationLocationResponse{}, err } @@ -453,7 +450,7 @@ func (client *LiveOutputsClient) operationLocationCreateRequest(ctx context.Cont return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/liveoutputs_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/liveoutputs_client_example_test.go index 752dcffdfc95..3002d7ea88e8 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/liveoutputs_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/liveoutputs_client_example_test.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 armmediaservices_test @@ -17,61 +18,120 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-list-all.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-list-all.json func ExampleLiveOutputsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveOutputsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("mediaresources", "slitestmedia10", "myLiveEvent1", nil) + pager := clientFactory.NewLiveOutputsClient().NewListPager("mediaresources", "slitestmedia10", "myLiveEvent1", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.LiveOutputListResult = armmediaservices.LiveOutputListResult{ + // Value: []*armmediaservices.LiveOutput{ + // { + // Name: to.Ptr("liveoutput1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/liveevents/liveoutputs"), + // ID: to.Ptr("/subscriptions/0a6ec948-5a62-437d-b9df-934dc7c1b722/resourceGroups/mediaresources/providers/Microsoft.Media/mediaservices/slitestmedia10/liveevents/myLiveEvent1/liveoutputs/"), + // Properties: &armmediaservices.LiveOutputProperties{ + // ArchiveWindowLength: to.Ptr("PT5M"), + // AssetName: to.Ptr("95dafce4-5320-464c-8597-909373854119"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00-08:00"); return t}()), + // Hls: &armmediaservices.Hls{ + // FragmentsPerTsSegment: to.Ptr[int32](5), + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00-08:00"); return t}()), + // ManifestName: to.Ptr("c3a23d4b-02a6-4937-a1ad-6416f463fdca"), + // OutputSnapTime: to.Ptr[int64](0), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armmediaservices.LiveOutputResourceStateRunning), + // RewindWindowLength: to.Ptr("PT4M"), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00-08:00"); return t}()), + // CreatedBy: to.Ptr("example@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00-08:00"); return t}()), + // LastModifiedBy: to.Ptr("example@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-list-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-list-by-name.json func ExampleLiveOutputsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveOutputsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", "myLiveOutput1", nil) + res, err := clientFactory.NewLiveOutputsClient().Get(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", "myLiveOutput1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.LiveOutput = armmediaservices.LiveOutput{ + // Name: to.Ptr("myLiveOutput1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/liveevents/liveoutputs"), + // ID: to.Ptr("/subscriptions/0a6ec948-5a62-437d-b9df-934dc7c1b722/resourceGroups/mediaresources/providers/Microsoft.Media/mediaservices/slitestmedia10/liveevents/myLiveEvent1/liveoutputs/myLiveOutput1"), + // Properties: &armmediaservices.LiveOutputProperties{ + // ArchiveWindowLength: to.Ptr("PT5M"), + // AssetName: to.Ptr("cb2ae0bc-677a-4830-9c8e-06ce4c4cb607"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00-08:00"); return t}()), + // Hls: &armmediaservices.Hls{ + // FragmentsPerTsSegment: to.Ptr[int32](5), + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00-08:00"); return t}()), + // ManifestName: to.Ptr("fc7096f5-c488-4b86-8302-f3bfde53fc27"), + // OutputSnapTime: to.Ptr[int64](0), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armmediaservices.LiveOutputResourceStateRunning), + // RewindWindowLength: to.Ptr("PT4M"), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00-08:00"); return t}()), + // CreatedBy: to.Ptr("example@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00-08:00"); return t}()), + // LastModifiedBy: to.Ptr("example@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-create.json func ExampleLiveOutputsClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveOutputsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", "myLiveOutput1", armmediaservices.LiveOutput{ + poller, err := clientFactory.NewLiveOutputsClient().BeginCreate(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", "myLiveOutput1", armmediaservices.LiveOutput{ Properties: &armmediaservices.LiveOutputProperties{ Description: to.Ptr("test live output 1"), ArchiveWindowLength: to.Ptr("PT5M"), @@ -90,22 +150,51 @@ func ExampleLiveOutputsClient_BeginCreate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.LiveOutput = armmediaservices.LiveOutput{ + // Name: to.Ptr("myLiveOutput1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/liveevents/liveoutputs"), + // ID: to.Ptr("/subscriptions/0a6ec948-5a62-437d-b9df-934dc7c1b722/resourceGroups/mediaresources/providers/Microsoft.Media/mediaservices/slitestmedia10/liveevents/myLiveEvent1/liveoutputs/myLiveOutput1"), + // Properties: &armmediaservices.LiveOutputProperties{ + // Description: to.Ptr("test live output 1"), + // ArchiveWindowLength: to.Ptr("PT5M"), + // AssetName: to.Ptr("6f3264f5-a189-48b4-a29a-a40f22575212"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.9431835Z"); return t}()), + // Hls: &armmediaservices.Hls{ + // FragmentsPerTsSegment: to.Ptr[int32](5), + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.9431835Z"); return t}()), + // ManifestName: to.Ptr("testmanifest"), + // OutputSnapTime: to.Ptr[int64](0), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armmediaservices.LiveOutputResourceState("Stopped")), + // RewindWindowLength: to.Ptr("PT4M"), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.9431835Z"); return t}()), + // CreatedBy: to.Ptr("example@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.9431835Z"); return t}()), + // LastModifiedBy: to.Ptr("example@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-delete.json func ExampleLiveOutputsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveOutputsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", "myLiveOutput1", nil) + poller, err := clientFactory.NewLiveOutputsClient().BeginDelete(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", "myLiveOutput1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -115,40 +204,77 @@ func ExampleLiveOutputsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/async-operation-result.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/async-operation-result.json func ExampleLiveOutputsClient_AsyncOperation() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveOutputsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.AsyncOperation(ctx, "mediaresources", "slitestmedia10", "62e4d893-d233-4005-988e-a428d9f77076", nil) + res, err := clientFactory.NewLiveOutputsClient().AsyncOperation(ctx, "mediaresources", "slitestmedia10", "62e4d893-d233-4005-988e-a428d9f77076", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AsyncOperationResult = armmediaservices.AsyncOperationResult{ + // Name: to.Ptr("62e4d893-d233-4005-988e-a428d9f77076"), + // Error: &armmediaservices.ErrorDetail{ + // Code: to.Ptr("None"), + // Target: to.Ptr("d7aea790-8acb-40b9-8f9f-21cc37c9e519"), + // }, + // Status: to.Ptr(armmediaservices.AsyncOperationStatusInProgress), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-operation-location.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-operation-location.json func ExampleLiveOutputsClient_OperationLocation() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLiveOutputsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.OperationLocation(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", "myLiveOutput1", "62e4d893-d233-4005-988e-a428d9f77076", nil) + res, err := clientFactory.NewLiveOutputsClient().OperationLocation(ctx, "mediaresources", "slitestmedia10", "myLiveEvent1", "myLiveOutput1", "62e4d893-d233-4005-988e-a428d9f77076", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.LiveOutput = armmediaservices.LiveOutput{ + // Name: to.Ptr("myLiveOutput1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/liveevents/liveoutputs"), + // ID: to.Ptr("/subscriptions/0a6ec948-5a62-437d-b9df-934dc7c1b722/resourceGroups/mediaresources/providers/Microsoft.Media/mediaservices/slitestmedia10/liveevents/myLiveEvent1/liveoutputs/myLiveOutput1"), + // Properties: &armmediaservices.LiveOutputProperties{ + // ArchiveWindowLength: to.Ptr("PT5M"), + // AssetName: to.Ptr("cb2ae0bc-677a-4830-9c8e-06ce4c4cb607"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00-08:00"); return t}()), + // Hls: &armmediaservices.Hls{ + // FragmentsPerTsSegment: to.Ptr[int32](5), + // }, + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00-08:00"); return t}()), + // ManifestName: to.Ptr("fc7096f5-c488-4b86-8302-f3bfde53fc27"), + // OutputSnapTime: to.Ptr[int64](0), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armmediaservices.LiveOutputResourceStateRunning), + // RewindWindowLength: to.Ptr("PT5M"), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00-08:00"); return t}()), + // CreatedBy: to.Ptr("example@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00-08:00"); return t}()), + // LastModifiedBy: to.Ptr("example@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/locations_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/locations_client.go index 01c0240c09fc..5f6429036af0 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/locations_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/locations_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // LocationsClient contains the methods for the Locations group. // Don't use this type directly, use NewLocationsClient() instead. type LocationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewLocationsClient creates a new instance of LocationsClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewLocationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LocationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".LocationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LocationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CheckNameAvailability - Checks whether the Media Service resource name is available. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// locationName - Location name. -// parameters - The request parameters -// options - LocationsClientCheckNameAvailabilityOptions contains the optional parameters for the LocationsClient.CheckNameAvailability -// method. +// - locationName - Location name. +// - parameters - The request parameters +// - options - LocationsClientCheckNameAvailabilityOptions contains the optional parameters for the LocationsClient.CheckNameAvailability +// method. func (client *LocationsClient) CheckNameAvailability(ctx context.Context, locationName string, parameters CheckNameAvailabilityInput, options *LocationsClientCheckNameAvailabilityOptions) (LocationsClientCheckNameAvailabilityResponse, error) { req, err := client.checkNameAvailabilityCreateRequest(ctx, locationName, parameters, options) if err != nil { return LocationsClientCheckNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LocationsClientCheckNameAvailabilityResponse{}, err } @@ -88,7 +78,7 @@ func (client *LocationsClient) checkNameAvailabilityCreateRequest(ctx context.Co return nil, errors.New("parameter locationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/locations_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/locations_client_example_test.go index eabf3acd5e40..0d858ec9e93f 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/locations_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/locations_client_example_test.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 armmediaservices_test @@ -17,24 +18,30 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/accounts-check-name-availability.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/accounts-check-name-availability.json func ExampleLocationsClient_CheckNameAvailability() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewLocationsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckNameAvailability(ctx, "japanwest", armmediaservices.CheckNameAvailabilityInput{ + res, err := clientFactory.NewLocationsClient().CheckNameAvailability(ctx, "japanwest", armmediaservices.CheckNameAvailabilityInput{ Name: to.Ptr("contosotv"), Type: to.Ptr("videoAnalyzers"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.EntityNameAvailabilityCheckOutput = armmediaservices.EntityNameAvailabilityCheckOutput{ + // Message: to.Ptr(""), + // NameAvailable: to.Ptr(true), + // Reason: to.Ptr("None"), + // } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/models.go b/sdk/resourcemanager/mediaservices/armmediaservices/models.go index 0de1eb1f7514..350c9feab9d8 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/models.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/models.go @@ -135,7 +135,7 @@ type AccountFiltersClientGetOptions struct { // placeholder for future optional parameters } -// AccountFiltersClientListOptions contains the optional parameters for the AccountFiltersClient.List method. +// AccountFiltersClientListOptions contains the optional parameters for the AccountFiltersClient.NewListPager method. type AccountFiltersClientListOptions struct { // placeholder for future optional parameters } @@ -289,7 +289,7 @@ type AssetFiltersClientGetOptions struct { // placeholder for future optional parameters } -// AssetFiltersClientListOptions contains the optional parameters for the AssetFiltersClient.List method. +// AssetFiltersClientListOptions contains the optional parameters for the AssetFiltersClient.NewListPager method. type AssetFiltersClientListOptions struct { // placeholder for future optional parameters } @@ -441,7 +441,7 @@ type AssetsClientListContainerSasOptions struct { // placeholder for future optional parameters } -// AssetsClientListOptions contains the optional parameters for the AssetsClient.List method. +// AssetsClientListOptions contains the optional parameters for the AssetsClient.NewListPager method. type AssetsClientListOptions struct { // Restricts the set of items returned. Filter *string @@ -752,7 +752,7 @@ type ClientGetOptions struct { // placeholder for future optional parameters } -// ClientListBySubscriptionOptions contains the optional parameters for the Client.ListBySubscription method. +// ClientListBySubscriptionOptions contains the optional parameters for the Client.NewListBySubscriptionPager method. type ClientListBySubscriptionOptions struct { // placeholder for future optional parameters } @@ -762,7 +762,7 @@ type ClientListEdgePoliciesOptions struct { // placeholder for future optional parameters } -// ClientListOptions contains the optional parameters for the Client.List method. +// ClientListOptions contains the optional parameters for the Client.NewListPager method. type ClientListOptions struct { // placeholder for future optional parameters } @@ -869,7 +869,7 @@ type ContentKeyPoliciesClientGetPolicyPropertiesWithSecretsOptions struct { // placeholder for future optional parameters } -// ContentKeyPoliciesClientListOptions contains the optional parameters for the ContentKeyPoliciesClient.List method. +// ContentKeyPoliciesClientListOptions contains the optional parameters for the ContentKeyPoliciesClient.NewListPager method. type ContentKeyPoliciesClientListOptions struct { // Restricts the set of items returned. Filter *string @@ -1565,7 +1565,7 @@ type EnvelopeEncryption struct { // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty" azure:"ro"` + Info any `json:"info,omitempty" azure:"ro"` // READ-ONLY; The additional info type. Type *string `json:"type,omitempty" azure:"ro"` @@ -2650,7 +2650,7 @@ type JobsClientGetOptions struct { // placeholder for future optional parameters } -// JobsClientListOptions contains the optional parameters for the JobsClient.List method. +// JobsClientListOptions contains the optional parameters for the JobsClient.NewListPager method. type JobsClientListOptions struct { // Restricts the set of items returned. Filter *string @@ -3147,7 +3147,7 @@ type LiveEventsClientGetOptions struct { // placeholder for future optional parameters } -// LiveEventsClientListOptions contains the optional parameters for the LiveEventsClient.List method. +// LiveEventsClientListOptions contains the optional parameters for the LiveEventsClient.NewListPager method. type LiveEventsClientListOptions struct { // placeholder for future optional parameters } @@ -3251,7 +3251,7 @@ type LiveOutputsClientGetOptions struct { // placeholder for future optional parameters } -// LiveOutputsClientListOptions contains the optional parameters for the LiveOutputsClient.List method. +// LiveOutputsClientListOptions contains the optional parameters for the LiveOutputsClient.NewListPager method. type LiveOutputsClientListOptions struct { // placeholder for future optional parameters } @@ -4372,7 +4372,7 @@ type StreamingEndpointsClientGetOptions struct { // placeholder for future optional parameters } -// StreamingEndpointsClientListOptions contains the optional parameters for the StreamingEndpointsClient.List method. +// StreamingEndpointsClientListOptions contains the optional parameters for the StreamingEndpointsClient.NewListPager method. type StreamingEndpointsClientListOptions struct { // placeholder for future optional parameters } @@ -4500,7 +4500,7 @@ type StreamingLocatorsClientListContentKeysOptions struct { // placeholder for future optional parameters } -// StreamingLocatorsClientListOptions contains the optional parameters for the StreamingLocatorsClient.List method. +// StreamingLocatorsClientListOptions contains the optional parameters for the StreamingLocatorsClient.NewListPager method. type StreamingLocatorsClientListOptions struct { // Restricts the set of items returned. Filter *string @@ -4543,7 +4543,7 @@ type StreamingPoliciesClientGetOptions struct { // placeholder for future optional parameters } -// StreamingPoliciesClientListOptions contains the optional parameters for the StreamingPoliciesClient.List method. +// StreamingPoliciesClientListOptions contains the optional parameters for the StreamingPoliciesClient.NewListPager method. type StreamingPoliciesClientListOptions struct { // Restricts the set of items returned. Filter *string @@ -4824,7 +4824,7 @@ type TracksClientGetOptions struct { // placeholder for future optional parameters } -// TracksClientListOptions contains the optional parameters for the TracksClient.List method. +// TracksClientListOptions contains the optional parameters for the TracksClient.NewListPager method. type TracksClientListOptions struct { // placeholder for future optional parameters } @@ -4905,7 +4905,7 @@ type TransformsClientGetOptions struct { // placeholder for future optional parameters } -// TransformsClientListOptions contains the optional parameters for the TransformsClient.List method. +// TransformsClientListOptions contains the optional parameters for the TransformsClient.NewListPager method. type TransformsClientListOptions struct { // Restricts the set of items returned. Filter *string diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/models_serde.go b/sdk/resourcemanager/mediaservices/armmediaservices/models_serde.go index d91e1a7520da..76cda9a36262 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/models_serde.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/models_serde.go @@ -19,7 +19,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type AacAudio. func (a AacAudio) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "bitrate", a.Bitrate) populate(objectMap, "channels", a.Channels) populate(objectMap, "label", a.Label) @@ -66,7 +66,7 @@ func (a *AacAudio) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AbsoluteClipTime. func (a AbsoluteClipTime) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = "#Microsoft.Media.AbsoluteClipTime" populate(objectMap, "time", a.Time) return json.Marshal(objectMap) @@ -97,7 +97,7 @@ func (a *AbsoluteClipTime) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AccessControl. func (a AccessControl) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "defaultAction", a.DefaultAction) populate(objectMap, "ipAllowList", a.IPAllowList) return json.Marshal(objectMap) @@ -128,7 +128,7 @@ func (a *AccessControl) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AccountEncryption. func (a AccountEncryption) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "identity", a.Identity) populate(objectMap, "keyVaultProperties", a.KeyVaultProperties) populate(objectMap, "status", a.Status) @@ -167,7 +167,7 @@ func (a *AccountEncryption) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AccountFilter. func (a AccountFilter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -210,7 +210,7 @@ func (a *AccountFilter) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AccountFilterCollection. func (a AccountFilterCollection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "@odata.nextLink", a.ODataNextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -241,7 +241,7 @@ func (a *AccountFilterCollection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AkamaiAccessControl. func (a AkamaiAccessControl) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "akamaiSignatureHeaderAuthenticationKeyList", a.AkamaiSignatureHeaderAuthenticationKeyList) return json.Marshal(objectMap) } @@ -268,7 +268,7 @@ func (a *AkamaiAccessControl) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AkamaiSignatureHeaderAuthenticationKey. func (a AkamaiSignatureHeaderAuthenticationKey) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "base64Key", a.Base64Key) populateTimeRFC3339(objectMap, "expiration", a.Expiration) populate(objectMap, "identifier", a.Identifier) @@ -303,7 +303,7 @@ func (a *AkamaiSignatureHeaderAuthenticationKey) UnmarshalJSON(data []byte) erro // MarshalJSON implements the json.Marshaller interface for type ArmStreamingEndpointCapacity. func (a ArmStreamingEndpointCapacity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "default", a.Default) populate(objectMap, "maximum", a.Maximum) populate(objectMap, "minimum", a.Minimum) @@ -342,7 +342,7 @@ func (a *ArmStreamingEndpointCapacity) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ArmStreamingEndpointCurrentSKU. func (a ArmStreamingEndpointCurrentSKU) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "capacity", a.Capacity) populate(objectMap, "name", a.Name) return json.Marshal(objectMap) @@ -373,7 +373,7 @@ func (a *ArmStreamingEndpointCurrentSKU) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ArmStreamingEndpointSKU. func (a ArmStreamingEndpointSKU) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", a.Name) return json.Marshal(objectMap) } @@ -400,7 +400,7 @@ func (a *ArmStreamingEndpointSKU) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ArmStreamingEndpointSKUInfo. func (a ArmStreamingEndpointSKUInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "capacity", a.Capacity) populate(objectMap, "resourceType", a.ResourceType) populate(objectMap, "sku", a.SKU) @@ -435,7 +435,7 @@ func (a *ArmStreamingEndpointSKUInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Asset. func (a Asset) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -478,7 +478,7 @@ func (a *Asset) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssetCollection. func (a AssetCollection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "@odata.nextLink", a.ODataNextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -509,7 +509,7 @@ func (a *AssetCollection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssetContainerSas. func (a AssetContainerSas) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "assetContainerSasUrls", a.AssetContainerSasUrls) return json.Marshal(objectMap) } @@ -536,7 +536,7 @@ func (a *AssetContainerSas) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssetFileEncryptionMetadata. func (a AssetFileEncryptionMetadata) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "assetFileId", a.AssetFileID) populate(objectMap, "assetFileName", a.AssetFileName) populate(objectMap, "initializationVector", a.InitializationVector) @@ -571,7 +571,7 @@ func (a *AssetFileEncryptionMetadata) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssetFilter. func (a AssetFilter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -614,7 +614,7 @@ func (a *AssetFilter) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssetFilterCollection. func (a AssetFilterCollection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "@odata.nextLink", a.ODataNextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -645,7 +645,7 @@ func (a *AssetFilterCollection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssetProperties. func (a AssetProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "alternateId", a.AlternateID) populate(objectMap, "assetId", a.AssetID) populate(objectMap, "container", a.Container) @@ -700,7 +700,7 @@ func (a *AssetProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssetStreamingLocator. func (a AssetStreamingLocator) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "assetName", a.AssetName) populateTimeRFC3339(objectMap, "created", a.Created) populate(objectMap, "defaultContentKeyPolicyName", a.DefaultContentKeyPolicyName) @@ -755,7 +755,7 @@ func (a *AssetStreamingLocator) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssetTrack. func (a AssetTrack) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -794,7 +794,7 @@ func (a *AssetTrack) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssetTrackCollection. func (a AssetTrackCollection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) } @@ -821,7 +821,7 @@ func (a *AssetTrackCollection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssetTrackOperationStatus. func (a AssetTrackOperationStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "endTime", a.EndTime) populate(objectMap, "error", a.Error) populate(objectMap, "id", a.ID) @@ -868,7 +868,7 @@ func (a *AssetTrackOperationStatus) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssetTrackProperties. func (a AssetTrackProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "provisioningState", a.ProvisioningState) populate(objectMap, "track", a.Track) return json.Marshal(objectMap) @@ -899,7 +899,7 @@ func (a *AssetTrackProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AsyncOperationResult. func (a AsyncOperationResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "error", a.Error) populate(objectMap, "name", a.Name) populate(objectMap, "status", a.Status) @@ -934,7 +934,7 @@ func (a *AsyncOperationResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Audio. func (a Audio) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "bitrate", a.Bitrate) populate(objectMap, "channels", a.Channels) populate(objectMap, "label", a.Label) @@ -977,7 +977,7 @@ func (a *Audio) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AudioAnalyzerPreset. func (a AudioAnalyzerPreset) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "audioLanguage", a.AudioLanguage) populate(objectMap, "experimentalOptions", a.ExperimentalOptions) populate(objectMap, "mode", a.Mode) @@ -1016,7 +1016,7 @@ func (a *AudioAnalyzerPreset) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AudioOverlay. func (a AudioOverlay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "audioGainLevel", a.AudioGainLevel) populate(objectMap, "end", a.End) populate(objectMap, "fadeInDuration", a.FadeInDuration) @@ -1067,7 +1067,7 @@ func (a *AudioOverlay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AudioTrack. func (a AudioTrack) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "bitRate", a.BitRate) populate(objectMap, "dashSettings", a.DashSettings) populate(objectMap, "displayName", a.DisplayName) @@ -1122,7 +1122,7 @@ func (a *AudioTrack) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AudioTrackDescriptor. func (a AudioTrackDescriptor) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "channelMapping", a.ChannelMapping) objectMap["@odata.type"] = "#Microsoft.Media.AudioTrackDescriptor" return json.Marshal(objectMap) @@ -1153,7 +1153,7 @@ func (a *AudioTrackDescriptor) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type BuiltInStandardEncoderPreset. func (b BuiltInStandardEncoderPreset) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "configurations", b.Configurations) objectMap["@odata.type"] = "#Microsoft.Media.BuiltInStandardEncoderPreset" populate(objectMap, "presetName", b.PresetName) @@ -1188,7 +1188,7 @@ func (b *BuiltInStandardEncoderPreset) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CbcsDrmConfiguration. func (c CbcsDrmConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "fairPlay", c.FairPlay) populate(objectMap, "playReady", c.PlayReady) populate(objectMap, "widevine", c.Widevine) @@ -1223,7 +1223,7 @@ func (c *CbcsDrmConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CencDrmConfiguration. func (c CencDrmConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "playReady", c.PlayReady) populate(objectMap, "widevine", c.Widevine) return json.Marshal(objectMap) @@ -1254,7 +1254,7 @@ func (c *CencDrmConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityInput. func (c CheckNameAvailabilityInput) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", c.Name) populate(objectMap, "type", c.Type) return json.Marshal(objectMap) @@ -1285,7 +1285,7 @@ func (c *CheckNameAvailabilityInput) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ClearKeyEncryptionConfiguration. func (c ClearKeyEncryptionConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "customKeysAcquisitionUrlTemplate", c.CustomKeysAcquisitionURLTemplate) return json.Marshal(objectMap) } @@ -1312,7 +1312,7 @@ func (c *ClearKeyEncryptionConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ClipTime. func (c ClipTime) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = c.ODataType return json.Marshal(objectMap) } @@ -1339,7 +1339,7 @@ func (c *ClipTime) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Codec. func (c Codec) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "label", c.Label) objectMap["@odata.type"] = c.ODataType return json.Marshal(objectMap) @@ -1370,7 +1370,7 @@ func (c *Codec) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CommonEncryptionCbcs. func (c CommonEncryptionCbcs) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "clearKeyEncryptionConfiguration", c.ClearKeyEncryptionConfiguration) populate(objectMap, "clearTracks", c.ClearTracks) populate(objectMap, "contentKeys", c.ContentKeys) @@ -1413,7 +1413,7 @@ func (c *CommonEncryptionCbcs) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CommonEncryptionCenc. func (c CommonEncryptionCenc) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "clearKeyEncryptionConfiguration", c.ClearKeyEncryptionConfiguration) populate(objectMap, "clearTracks", c.ClearTracks) populate(objectMap, "contentKeys", c.ContentKeys) @@ -1456,7 +1456,7 @@ func (c *CommonEncryptionCenc) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicy. func (c ContentKeyPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) @@ -1499,7 +1499,7 @@ func (c *ContentKeyPolicy) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyClearKeyConfiguration. func (c ContentKeyPolicyClearKeyConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = "#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration" return json.Marshal(objectMap) } @@ -1526,7 +1526,7 @@ func (c *ContentKeyPolicyClearKeyConfiguration) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyCollection. func (c ContentKeyPolicyCollection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "@odata.nextLink", c.ODataNextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -1557,7 +1557,7 @@ func (c *ContentKeyPolicyCollection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyConfiguration. func (c ContentKeyPolicyConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = c.ODataType return json.Marshal(objectMap) } @@ -1584,7 +1584,7 @@ func (c *ContentKeyPolicyConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyFairPlayConfiguration. func (c ContentKeyPolicyFairPlayConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateByteArray(objectMap, "ask", c.Ask, runtime.Base64StdFormat) populate(objectMap, "fairPlayPfx", c.FairPlayPfx) populate(objectMap, "fairPlayPfxPassword", c.FairPlayPfxPassword) @@ -1635,7 +1635,7 @@ func (c *ContentKeyPolicyFairPlayConfiguration) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyFairPlayOfflineRentalConfiguration. func (c ContentKeyPolicyFairPlayOfflineRentalConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "playbackDurationSeconds", c.PlaybackDurationSeconds) populate(objectMap, "storageDurationSeconds", c.StorageDurationSeconds) return json.Marshal(objectMap) @@ -1666,7 +1666,7 @@ func (c *ContentKeyPolicyFairPlayOfflineRentalConfiguration) UnmarshalJSON(data // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyOpenRestriction. func (c ContentKeyPolicyOpenRestriction) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = "#Microsoft.Media.ContentKeyPolicyOpenRestriction" return json.Marshal(objectMap) } @@ -1693,7 +1693,7 @@ func (c *ContentKeyPolicyOpenRestriction) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyOption. func (c ContentKeyPolicyOption) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "configuration", c.Configuration) populate(objectMap, "name", c.Name) populate(objectMap, "policyOptionId", c.PolicyOptionID) @@ -1732,7 +1732,7 @@ func (c *ContentKeyPolicyOption) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyPlayReadyConfiguration. func (c ContentKeyPolicyPlayReadyConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "licenses", c.Licenses) objectMap["@odata.type"] = "#Microsoft.Media.ContentKeyPolicyPlayReadyConfiguration" populate(objectMap, "responseCustomData", c.ResponseCustomData) @@ -1767,7 +1767,7 @@ func (c *ContentKeyPolicyPlayReadyConfiguration) UnmarshalJSON(data []byte) erro // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader. func (c ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = "#Microsoft.Media.ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader" return json.Marshal(objectMap) } @@ -1794,7 +1794,7 @@ func (c *ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader) UnmarshalJSON( // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier. func (c ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "keyId", c.KeyID) objectMap["@odata.type"] = "#Microsoft.Media.ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier" return json.Marshal(objectMap) @@ -1825,7 +1825,7 @@ func (c *ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier) Unmarsh // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyPlayReadyContentKeyLocation. func (c ContentKeyPolicyPlayReadyContentKeyLocation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = c.ODataType return json.Marshal(objectMap) } @@ -1852,7 +1852,7 @@ func (c *ContentKeyPolicyPlayReadyContentKeyLocation) UnmarshalJSON(data []byte) // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyPlayReadyExplicitAnalogTelevisionRestriction. func (c ContentKeyPolicyPlayReadyExplicitAnalogTelevisionRestriction) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "bestEffort", c.BestEffort) populate(objectMap, "configurationData", c.ConfigurationData) return json.Marshal(objectMap) @@ -1883,7 +1883,7 @@ func (c *ContentKeyPolicyPlayReadyExplicitAnalogTelevisionRestriction) Unmarshal // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyPlayReadyLicense. func (c ContentKeyPolicyPlayReadyLicense) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allowTestDevices", c.AllowTestDevices) populateTimeRFC3339(objectMap, "beginDate", c.BeginDate) populate(objectMap, "contentKeyLocation", c.ContentKeyLocation) @@ -1950,7 +1950,7 @@ func (c *ContentKeyPolicyPlayReadyLicense) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyPlayReadyPlayRight. func (c ContentKeyPolicyPlayReadyPlayRight) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "agcAndColorStripeRestriction", c.AgcAndColorStripeRestriction) populate(objectMap, "allowPassingVideoContentToUnknownOutput", c.AllowPassingVideoContentToUnknownOutput) populate(objectMap, "analogVideoOpl", c.AnalogVideoOpl) @@ -2025,7 +2025,7 @@ func (c *ContentKeyPolicyPlayReadyPlayRight) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyProperties. func (c ContentKeyPolicyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "created", c.Created) populate(objectMap, "description", c.Description) populateTimeRFC3339(objectMap, "lastModified", c.LastModified) @@ -2068,7 +2068,7 @@ func (c *ContentKeyPolicyProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyRestriction. func (c ContentKeyPolicyRestriction) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = c.ODataType return json.Marshal(objectMap) } @@ -2095,7 +2095,7 @@ func (c *ContentKeyPolicyRestriction) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyRestrictionTokenKey. func (c ContentKeyPolicyRestrictionTokenKey) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = c.ODataType return json.Marshal(objectMap) } @@ -2122,7 +2122,7 @@ func (c *ContentKeyPolicyRestrictionTokenKey) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyRsaTokenKey. func (c ContentKeyPolicyRsaTokenKey) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateByteArray(objectMap, "exponent", c.Exponent, runtime.Base64StdFormat) populateByteArray(objectMap, "modulus", c.Modulus, runtime.Base64StdFormat) objectMap["@odata.type"] = "#Microsoft.Media.ContentKeyPolicyRsaTokenKey" @@ -2157,7 +2157,7 @@ func (c *ContentKeyPolicyRsaTokenKey) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicySymmetricTokenKey. func (c ContentKeyPolicySymmetricTokenKey) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateByteArray(objectMap, "keyValue", c.KeyValue, runtime.Base64StdFormat) objectMap["@odata.type"] = "#Microsoft.Media.ContentKeyPolicySymmetricTokenKey" return json.Marshal(objectMap) @@ -2188,7 +2188,7 @@ func (c *ContentKeyPolicySymmetricTokenKey) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyTokenClaim. func (c ContentKeyPolicyTokenClaim) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "claimType", c.ClaimType) populate(objectMap, "claimValue", c.ClaimValue) return json.Marshal(objectMap) @@ -2219,7 +2219,7 @@ func (c *ContentKeyPolicyTokenClaim) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyTokenRestriction. func (c ContentKeyPolicyTokenRestriction) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "alternateVerificationKeys", c.AlternateVerificationKeys) populate(objectMap, "audience", c.Audience) populate(objectMap, "issuer", c.Issuer) @@ -2274,7 +2274,7 @@ func (c *ContentKeyPolicyTokenRestriction) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyUnknownConfiguration. func (c ContentKeyPolicyUnknownConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = "#Microsoft.Media.ContentKeyPolicyUnknownConfiguration" return json.Marshal(objectMap) } @@ -2301,7 +2301,7 @@ func (c *ContentKeyPolicyUnknownConfiguration) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyUnknownRestriction. func (c ContentKeyPolicyUnknownRestriction) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = "#Microsoft.Media.ContentKeyPolicyUnknownRestriction" return json.Marshal(objectMap) } @@ -2328,7 +2328,7 @@ func (c *ContentKeyPolicyUnknownRestriction) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyWidevineConfiguration. func (c ContentKeyPolicyWidevineConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = "#Microsoft.Media.ContentKeyPolicyWidevineConfiguration" populate(objectMap, "widevineTemplate", c.WidevineTemplate) return json.Marshal(objectMap) @@ -2359,7 +2359,7 @@ func (c *ContentKeyPolicyWidevineConfiguration) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type ContentKeyPolicyX509CertificateTokenKey. func (c ContentKeyPolicyX509CertificateTokenKey) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = "#Microsoft.Media.ContentKeyPolicyX509CertificateTokenKey" populateByteArray(objectMap, "rawBody", c.RawBody, runtime.Base64StdFormat) return json.Marshal(objectMap) @@ -2390,7 +2390,7 @@ func (c *ContentKeyPolicyX509CertificateTokenKey) UnmarshalJSON(data []byte) err // MarshalJSON implements the json.Marshaller interface for type CopyAudio. func (c CopyAudio) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "label", c.Label) objectMap["@odata.type"] = "#Microsoft.Media.CopyAudio" return json.Marshal(objectMap) @@ -2421,7 +2421,7 @@ func (c *CopyAudio) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CopyVideo. func (c CopyVideo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "label", c.Label) objectMap["@odata.type"] = "#Microsoft.Media.CopyVideo" return json.Marshal(objectMap) @@ -2452,7 +2452,7 @@ func (c *CopyVideo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CrossSiteAccessPolicies. func (c CrossSiteAccessPolicies) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "clientAccessPolicy", c.ClientAccessPolicy) populate(objectMap, "crossDomainPolicy", c.CrossDomainPolicy) return json.Marshal(objectMap) @@ -2483,7 +2483,7 @@ func (c *CrossSiteAccessPolicies) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DDAudio. func (d DDAudio) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "bitrate", d.Bitrate) populate(objectMap, "channels", d.Channels) populate(objectMap, "label", d.Label) @@ -2526,7 +2526,7 @@ func (d *DDAudio) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DashSettings. func (d DashSettings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "role", d.Role) return json.Marshal(objectMap) } @@ -2553,7 +2553,7 @@ func (d *DashSettings) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DefaultKey. func (d DefaultKey) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "label", d.Label) populate(objectMap, "policyName", d.PolicyName) return json.Marshal(objectMap) @@ -2584,7 +2584,7 @@ func (d *DefaultKey) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Deinterlace. func (d Deinterlace) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "mode", d.Mode) populate(objectMap, "parity", d.Parity) return json.Marshal(objectMap) @@ -2615,7 +2615,7 @@ func (d *Deinterlace) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EdgePolicies. func (e EdgePolicies) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "usageDataCollectionPolicy", e.UsageDataCollectionPolicy) return json.Marshal(objectMap) } @@ -2642,7 +2642,7 @@ func (e *EdgePolicies) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EdgeUsageDataCollectionPolicy. func (e EdgeUsageDataCollectionPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "dataCollectionFrequency", e.DataCollectionFrequency) populate(objectMap, "dataReportingFrequency", e.DataReportingFrequency) populate(objectMap, "eventHubDetails", e.EventHubDetails) @@ -2681,7 +2681,7 @@ func (e *EdgeUsageDataCollectionPolicy) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EdgeUsageDataEventHub. func (e EdgeUsageDataEventHub) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", e.Name) populate(objectMap, "namespace", e.Namespace) populate(objectMap, "token", e.Token) @@ -2716,7 +2716,7 @@ func (e *EdgeUsageDataEventHub) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EnabledProtocols. func (e EnabledProtocols) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "dash", e.Dash) populate(objectMap, "download", e.Download) populate(objectMap, "hls", e.Hls) @@ -2755,7 +2755,7 @@ func (e *EnabledProtocols) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EntityNameAvailabilityCheckOutput. func (e EntityNameAvailabilityCheckOutput) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "message", e.Message) populate(objectMap, "nameAvailable", e.NameAvailable) populate(objectMap, "reason", e.Reason) @@ -2790,7 +2790,7 @@ func (e *EntityNameAvailabilityCheckOutput) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EnvelopeEncryption. func (e EnvelopeEncryption) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "clearTracks", e.ClearTracks) populate(objectMap, "contentKeys", e.ContentKeys) populate(objectMap, "customKeyAcquisitionUrlTemplate", e.CustomKeyAcquisitionURLTemplate) @@ -2829,7 +2829,7 @@ func (e *EnvelopeEncryption) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "info", &e.Info) populate(objectMap, "type", e.Type) return json.Marshal(objectMap) @@ -2860,7 +2860,7 @@ func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorDetail. func (e ErrorDetail) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "additionalInfo", e.AdditionalInfo) populate(objectMap, "code", e.Code) populate(objectMap, "details", e.Details) @@ -2903,7 +2903,7 @@ func (e *ErrorDetail) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorResponse. func (e ErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "error", e.Error) return json.Marshal(objectMap) } @@ -2930,7 +2930,7 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FaceDetectorPreset. func (f FaceDetectorPreset) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "blurType", f.BlurType) populate(objectMap, "experimentalOptions", f.ExperimentalOptions) populate(objectMap, "mode", f.Mode) @@ -2973,7 +2973,7 @@ func (f *FaceDetectorPreset) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Fade. func (f Fade) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "duration", f.Duration) populate(objectMap, "fadeColor", f.FadeColor) populate(objectMap, "start", f.Start) @@ -3008,7 +3008,7 @@ func (f *Fade) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FilterTrackPropertyCondition. func (f FilterTrackPropertyCondition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "operation", f.Operation) populate(objectMap, "property", f.Property) populate(objectMap, "value", f.Value) @@ -3043,7 +3043,7 @@ func (f *FilterTrackPropertyCondition) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FilterTrackSelection. func (f FilterTrackSelection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "trackSelections", f.TrackSelections) return json.Marshal(objectMap) } @@ -3070,7 +3070,7 @@ func (f *FilterTrackSelection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Filters. func (f Filters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "crop", f.Crop) populate(objectMap, "deinterlace", f.Deinterlace) populate(objectMap, "fadeIn", f.FadeIn) @@ -3117,7 +3117,7 @@ func (f *Filters) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FirstQuality. func (f FirstQuality) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "bitrate", f.Bitrate) return json.Marshal(objectMap) } @@ -3144,7 +3144,7 @@ func (f *FirstQuality) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Format. func (f Format) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "filenamePattern", f.FilenamePattern) objectMap["@odata.type"] = f.ODataType return json.Marshal(objectMap) @@ -3175,7 +3175,7 @@ func (f *Format) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FromAllInputFile. func (f FromAllInputFile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "includedTracks", f.IncludedTracks) objectMap["@odata.type"] = "#Microsoft.Media.FromAllInputFile" return json.Marshal(objectMap) @@ -3206,7 +3206,7 @@ func (f *FromAllInputFile) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FromEachInputFile. func (f FromEachInputFile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "includedTracks", f.IncludedTracks) objectMap["@odata.type"] = "#Microsoft.Media.FromEachInputFile" return json.Marshal(objectMap) @@ -3237,7 +3237,7 @@ func (f *FromEachInputFile) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type H264Layer. func (h H264Layer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "adaptiveBFrame", h.AdaptiveBFrame) populate(objectMap, "bFrames", h.BFrames) populate(objectMap, "bitrate", h.Bitrate) @@ -3320,7 +3320,7 @@ func (h *H264Layer) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type H264Video. func (h H264Video) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "complexity", h.Complexity) populate(objectMap, "keyFrameInterval", h.KeyFrameInterval) populate(objectMap, "label", h.Label) @@ -3379,7 +3379,7 @@ func (h *H264Video) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type H265Layer. func (h H265Layer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "adaptiveBFrame", h.AdaptiveBFrame) populate(objectMap, "bFrames", h.BFrames) populate(objectMap, "bitrate", h.Bitrate) @@ -3458,7 +3458,7 @@ func (h *H265Layer) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type H265Video. func (h H265Video) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "complexity", h.Complexity) populate(objectMap, "keyFrameInterval", h.KeyFrameInterval) populate(objectMap, "label", h.Label) @@ -3513,7 +3513,7 @@ func (h *H265Video) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type H265VideoLayer. func (h H265VideoLayer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "adaptiveBFrame", h.AdaptiveBFrame) populate(objectMap, "bFrames", h.BFrames) populate(objectMap, "bitrate", h.Bitrate) @@ -3572,7 +3572,7 @@ func (h *H265VideoLayer) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Hls. func (h Hls) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "fragmentsPerTsSegment", h.FragmentsPerTsSegment) return json.Marshal(objectMap) } @@ -3599,7 +3599,7 @@ func (h *Hls) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HlsSettings. func (h HlsSettings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "characteristics", h.Characteristics) populate(objectMap, "default", h.Default) populate(objectMap, "forced", h.Forced) @@ -3634,7 +3634,7 @@ func (h *HlsSettings) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IPAccessControl. func (i IPAccessControl) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allow", i.Allow) return json.Marshal(objectMap) } @@ -3661,7 +3661,7 @@ func (i *IPAccessControl) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IPRange. func (i IPRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "address", i.Address) populate(objectMap, "name", i.Name) populate(objectMap, "subnetPrefixLength", i.SubnetPrefixLength) @@ -3696,7 +3696,7 @@ func (i *IPRange) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Image. func (i Image) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "keyFrameInterval", i.KeyFrameInterval) populate(objectMap, "label", i.Label) objectMap["@odata.type"] = "#Microsoft.Media.Image" @@ -3751,7 +3751,7 @@ func (i *Image) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ImageFormat. func (i ImageFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "filenamePattern", i.FilenamePattern) objectMap["@odata.type"] = "#Microsoft.Media.ImageFormat" return json.Marshal(objectMap) @@ -3782,7 +3782,7 @@ func (i *ImageFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InputDefinition. func (i InputDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "includedTracks", i.IncludedTracks) objectMap["@odata.type"] = i.ODataType return json.Marshal(objectMap) @@ -3813,7 +3813,7 @@ func (i *InputDefinition) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InputFile. func (i InputFile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "filename", i.Filename) populate(objectMap, "includedTracks", i.IncludedTracks) objectMap["@odata.type"] = "#Microsoft.Media.InputFile" @@ -3848,7 +3848,7 @@ func (i *InputFile) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Job. func (j Job) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", j.ID) populate(objectMap, "name", j.Name) populate(objectMap, "properties", j.Properties) @@ -3891,7 +3891,7 @@ func (j *Job) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JobCollection. func (j JobCollection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "@odata.nextLink", j.ODataNextLink) populate(objectMap, "value", j.Value) return json.Marshal(objectMap) @@ -3922,7 +3922,7 @@ func (j *JobCollection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JobError. func (j JobError) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "category", j.Category) populate(objectMap, "code", j.Code) populate(objectMap, "details", j.Details) @@ -3965,7 +3965,7 @@ func (j *JobError) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JobErrorDetail. func (j JobErrorDetail) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "code", j.Code) populate(objectMap, "message", j.Message) return json.Marshal(objectMap) @@ -3996,7 +3996,7 @@ func (j *JobErrorDetail) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JobInput. func (j JobInput) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = j.ODataType return json.Marshal(objectMap) } @@ -4023,7 +4023,7 @@ func (j *JobInput) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JobInputAsset. func (j JobInputAsset) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "assetName", j.AssetName) populate(objectMap, "end", j.End) populate(objectMap, "files", j.Files) @@ -4074,7 +4074,7 @@ func (j *JobInputAsset) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JobInputClip. func (j JobInputClip) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "end", j.End) populate(objectMap, "files", j.Files) populate(objectMap, "inputDefinitions", j.InputDefinitions) @@ -4121,7 +4121,7 @@ func (j *JobInputClip) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JobInputHTTP. func (j JobInputHTTP) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "baseUri", j.BaseURI) populate(objectMap, "end", j.End) populate(objectMap, "files", j.Files) @@ -4172,7 +4172,7 @@ func (j *JobInputHTTP) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JobInputSequence. func (j JobInputSequence) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "inputs", j.Inputs) objectMap["@odata.type"] = "#Microsoft.Media.JobInputSequence" return json.Marshal(objectMap) @@ -4203,7 +4203,7 @@ func (j *JobInputSequence) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JobInputs. func (j JobInputs) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "inputs", j.Inputs) objectMap["@odata.type"] = "#Microsoft.Media.JobInputs" return json.Marshal(objectMap) @@ -4234,7 +4234,7 @@ func (j *JobInputs) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JobOutput. func (j JobOutput) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "endTime", j.EndTime) populate(objectMap, "error", j.Error) populate(objectMap, "label", j.Label) @@ -4289,7 +4289,7 @@ func (j *JobOutput) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JobOutputAsset. func (j JobOutputAsset) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "assetName", j.AssetName) populateTimeRFC3339(objectMap, "endTime", j.EndTime) populate(objectMap, "error", j.Error) @@ -4348,7 +4348,7 @@ func (j *JobOutputAsset) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JobProperties. func (j JobProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "correlationData", j.CorrelationData) populateTimeRFC3339(objectMap, "created", j.Created) populate(objectMap, "description", j.Description) @@ -4411,7 +4411,7 @@ func (j *JobProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JpgFormat. func (j JpgFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "filenamePattern", j.FilenamePattern) objectMap["@odata.type"] = "#Microsoft.Media.JpgFormat" return json.Marshal(objectMap) @@ -4442,7 +4442,7 @@ func (j *JpgFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JpgImage. func (j JpgImage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "keyFrameInterval", j.KeyFrameInterval) populate(objectMap, "label", j.Label) populate(objectMap, "layers", j.Layers) @@ -4505,7 +4505,7 @@ func (j *JpgImage) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JpgLayer. func (j JpgLayer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "height", j.Height) populate(objectMap, "label", j.Label) populate(objectMap, "quality", j.Quality) @@ -4544,7 +4544,7 @@ func (j *JpgLayer) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type KeyDelivery. func (k KeyDelivery) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "accessControl", k.AccessControl) return json.Marshal(objectMap) } @@ -4571,7 +4571,7 @@ func (k *KeyDelivery) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type KeyVaultProperties. func (k KeyVaultProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "currentKeyIdentifier", k.CurrentKeyIdentifier) populate(objectMap, "keyIdentifier", k.KeyIdentifier) return json.Marshal(objectMap) @@ -4602,7 +4602,7 @@ func (k *KeyVaultProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Layer. func (l Layer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "height", l.Height) populate(objectMap, "label", l.Label) populate(objectMap, "width", l.Width) @@ -4637,7 +4637,7 @@ func (l *Layer) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ListContainerSasInput. func (l ListContainerSasInput) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "expiryTime", l.ExpiryTime) populate(objectMap, "permissions", l.Permissions) return json.Marshal(objectMap) @@ -4668,7 +4668,7 @@ func (l *ListContainerSasInput) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ListContentKeysResponse. func (l ListContentKeysResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "contentKeys", l.ContentKeys) return json.Marshal(objectMap) } @@ -4695,7 +4695,7 @@ func (l *ListContentKeysResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ListEdgePoliciesInput. func (l ListEdgePoliciesInput) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "deviceId", l.DeviceID) return json.Marshal(objectMap) } @@ -4722,7 +4722,7 @@ func (l *ListEdgePoliciesInput) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ListPathsResponse. func (l ListPathsResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "downloadPaths", l.DownloadPaths) populate(objectMap, "streamingPaths", l.StreamingPaths) return json.Marshal(objectMap) @@ -4753,7 +4753,7 @@ func (l *ListPathsResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ListStreamingLocatorsResponse. func (l ListStreamingLocatorsResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "streamingLocators", l.StreamingLocators) return json.Marshal(objectMap) } @@ -4780,7 +4780,7 @@ func (l *ListStreamingLocatorsResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveEvent. func (l LiveEvent) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", l.ID) populate(objectMap, "location", l.Location) populate(objectMap, "name", l.Name) @@ -4831,7 +4831,7 @@ func (l *LiveEvent) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveEventActionInput. func (l LiveEventActionInput) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "removeOutputsOnStop", l.RemoveOutputsOnStop) return json.Marshal(objectMap) } @@ -4858,7 +4858,7 @@ func (l *LiveEventActionInput) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveEventEncoding. func (l LiveEventEncoding) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "encodingType", l.EncodingType) populate(objectMap, "keyFrameInterval", l.KeyFrameInterval) populate(objectMap, "presetName", l.PresetName) @@ -4897,7 +4897,7 @@ func (l *LiveEventEncoding) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveEventEndpoint. func (l LiveEventEndpoint) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "protocol", l.Protocol) populate(objectMap, "url", l.URL) return json.Marshal(objectMap) @@ -4928,7 +4928,7 @@ func (l *LiveEventEndpoint) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveEventInput. func (l LiveEventInput) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "accessControl", l.AccessControl) populate(objectMap, "accessToken", l.AccessToken) populate(objectMap, "endpoints", l.Endpoints) @@ -4971,7 +4971,7 @@ func (l *LiveEventInput) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveEventInputAccessControl. func (l LiveEventInputAccessControl) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "ip", l.IP) return json.Marshal(objectMap) } @@ -4998,7 +4998,7 @@ func (l *LiveEventInputAccessControl) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveEventInputTrackSelection. func (l LiveEventInputTrackSelection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "operation", l.Operation) populate(objectMap, "property", l.Property) populate(objectMap, "value", l.Value) @@ -5033,7 +5033,7 @@ func (l *LiveEventInputTrackSelection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveEventListResult. func (l LiveEventListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "@odata.count", l.ODataCount) populate(objectMap, "@odata.nextLink", l.ODataNextLink) populate(objectMap, "value", l.Value) @@ -5068,7 +5068,7 @@ func (l *LiveEventListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveEventOutputTranscriptionTrack. func (l LiveEventOutputTranscriptionTrack) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "trackName", l.TrackName) return json.Marshal(objectMap) } @@ -5095,7 +5095,7 @@ func (l *LiveEventOutputTranscriptionTrack) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveEventPreview. func (l LiveEventPreview) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "accessControl", l.AccessControl) populate(objectMap, "alternativeMediaId", l.AlternativeMediaID) populate(objectMap, "endpoints", l.Endpoints) @@ -5138,7 +5138,7 @@ func (l *LiveEventPreview) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveEventPreviewAccessControl. func (l LiveEventPreviewAccessControl) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "ip", l.IP) return json.Marshal(objectMap) } @@ -5165,7 +5165,7 @@ func (l *LiveEventPreviewAccessControl) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveEventProperties. func (l LiveEventProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "created", l.Created) populate(objectMap, "crossSiteAccessPolicies", l.CrossSiteAccessPolicies) populate(objectMap, "description", l.Description) @@ -5240,7 +5240,7 @@ func (l *LiveEventProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveEventTranscription. func (l LiveEventTranscription) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "inputTrackSelection", l.InputTrackSelection) populate(objectMap, "language", l.Language) populate(objectMap, "outputTranscriptionTrack", l.OutputTranscriptionTrack) @@ -5275,7 +5275,7 @@ func (l *LiveEventTranscription) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveOutput. func (l LiveOutput) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", l.ID) populate(objectMap, "name", l.Name) populate(objectMap, "properties", l.Properties) @@ -5318,7 +5318,7 @@ func (l *LiveOutput) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveOutputListResult. func (l LiveOutputListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "@odata.count", l.ODataCount) populate(objectMap, "@odata.nextLink", l.ODataNextLink) populate(objectMap, "value", l.Value) @@ -5353,7 +5353,7 @@ func (l *LiveOutputListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LiveOutputProperties. func (l LiveOutputProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "archiveWindowLength", l.ArchiveWindowLength) populate(objectMap, "assetName", l.AssetName) populateTimeRFC3339(objectMap, "created", l.Created) @@ -5420,7 +5420,7 @@ func (l *LiveOutputProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LogSpecification. func (l LogSpecification) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "blobDuration", l.BlobDuration) populate(objectMap, "displayName", l.DisplayName) populate(objectMap, "name", l.Name) @@ -5455,7 +5455,7 @@ func (l *LogSpecification) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MediaFilterProperties. func (m MediaFilterProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "firstQuality", m.FirstQuality) populate(objectMap, "presentationTimeRange", m.PresentationTimeRange) populate(objectMap, "tracks", m.Tracks) @@ -5490,7 +5490,7 @@ func (m *MediaFilterProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MediaService. func (m MediaService) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", m.ID) populate(objectMap, "identity", m.Identity) populate(objectMap, "location", m.Location) @@ -5545,7 +5545,7 @@ func (m *MediaService) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MediaServiceCollection. func (m MediaServiceCollection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "@odata.nextLink", m.ODataNextLink) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) @@ -5576,7 +5576,7 @@ func (m *MediaServiceCollection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MediaServiceIdentity. func (m MediaServiceIdentity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "principalId", m.PrincipalID) populate(objectMap, "tenantId", m.TenantID) populate(objectMap, "type", m.Type) @@ -5615,7 +5615,7 @@ func (m *MediaServiceIdentity) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MediaServiceOperationStatus. func (m MediaServiceOperationStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "endTime", m.EndTime) populate(objectMap, "error", m.Error) populate(objectMap, "id", m.ID) @@ -5662,7 +5662,7 @@ func (m *MediaServiceOperationStatus) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MediaServiceProperties. func (m MediaServiceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "encryption", m.Encryption) populate(objectMap, "keyDelivery", m.KeyDelivery) populate(objectMap, "mediaServiceId", m.MediaServiceID) @@ -5717,7 +5717,7 @@ func (m *MediaServiceProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MediaServiceUpdate. func (m MediaServiceUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "identity", m.Identity) populate(objectMap, "properties", m.Properties) populate(objectMap, "tags", m.Tags) @@ -5752,7 +5752,7 @@ func (m *MediaServiceUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MetricDimension. func (m MetricDimension) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "displayName", m.DisplayName) populate(objectMap, "name", m.Name) populate(objectMap, "toBeExportedForShoebox", m.ToBeExportedForShoebox) @@ -5787,7 +5787,7 @@ func (m *MetricDimension) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MetricSpecification. func (m MetricSpecification) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "aggregationType", m.AggregationType) populate(objectMap, "dimensions", m.Dimensions) populate(objectMap, "displayDescription", m.DisplayDescription) @@ -5858,7 +5858,7 @@ func (m *MetricSpecification) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Mp4Format. func (m Mp4Format) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "filenamePattern", m.FilenamePattern) objectMap["@odata.type"] = "#Microsoft.Media.Mp4Format" populate(objectMap, "outputFiles", m.OutputFiles) @@ -5893,7 +5893,7 @@ func (m *Mp4Format) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MultiBitrateFormat. func (m MultiBitrateFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "filenamePattern", m.FilenamePattern) objectMap["@odata.type"] = "#Microsoft.Media.MultiBitrateFormat" populate(objectMap, "outputFiles", m.OutputFiles) @@ -5928,7 +5928,7 @@ func (m *MultiBitrateFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type NoEncryption. func (n NoEncryption) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "enabledProtocols", n.EnabledProtocols) return json.Marshal(objectMap) } @@ -5955,7 +5955,7 @@ func (n *NoEncryption) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "actionType", o.ActionType) populate(objectMap, "display", o.Display) populate(objectMap, "isDataAction", o.IsDataAction) @@ -6002,7 +6002,7 @@ func (o *Operation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationCollection. func (o OperationCollection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) } @@ -6029,7 +6029,7 @@ func (o *OperationCollection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -6068,7 +6068,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OutputFile. func (o OutputFile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "labels", o.Labels) return json.Marshal(objectMap) } @@ -6095,7 +6095,7 @@ func (o *OutputFile) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Overlay. func (o Overlay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "audioGainLevel", o.AudioGainLevel) populate(objectMap, "end", o.End) populate(objectMap, "fadeInDuration", o.FadeInDuration) @@ -6146,7 +6146,7 @@ func (o *Overlay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PNGFormat. func (p PNGFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "filenamePattern", p.FilenamePattern) objectMap["@odata.type"] = "#Microsoft.Media.PngFormat" return json.Marshal(objectMap) @@ -6177,7 +6177,7 @@ func (p *PNGFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PNGImage. func (p PNGImage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "keyFrameInterval", p.KeyFrameInterval) populate(objectMap, "label", p.Label) populate(objectMap, "layers", p.Layers) @@ -6236,7 +6236,7 @@ func (p *PNGImage) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PNGLayer. func (p PNGLayer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "height", p.Height) populate(objectMap, "label", p.Label) populate(objectMap, "width", p.Width) @@ -6271,7 +6271,7 @@ func (p *PNGLayer) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PresentationTimeRange. func (p PresentationTimeRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "endTimestamp", p.EndTimestamp) populate(objectMap, "forceEndTimestamp", p.ForceEndTimestamp) populate(objectMap, "liveBackoffDuration", p.LiveBackoffDuration) @@ -6318,7 +6318,7 @@ func (p *PresentationTimeRange) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Preset. func (p Preset) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = p.ODataType return json.Marshal(objectMap) } @@ -6345,7 +6345,7 @@ func (p *Preset) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PresetConfigurations. func (p PresetConfigurations) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "complexity", p.Complexity) populate(objectMap, "interleaveOutput", p.InterleaveOutput) populate(objectMap, "keyFrameIntervalInSeconds", p.KeyFrameIntervalInSeconds) @@ -6400,7 +6400,7 @@ func (p *PresetConfigurations) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateEndpoint. func (p PrivateEndpoint) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) return json.Marshal(objectMap) } @@ -6427,7 +6427,7 @@ func (p *PrivateEndpoint) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnection. func (p PrivateEndpointConnection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) populate(objectMap, "properties", p.Properties) @@ -6466,7 +6466,7 @@ func (p *PrivateEndpointConnection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionListResult. func (p PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) } @@ -6493,7 +6493,7 @@ func (p *PrivateEndpointConnectionListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionProperties. func (p PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "privateEndpoint", p.PrivateEndpoint) populate(objectMap, "privateLinkServiceConnectionState", p.PrivateLinkServiceConnectionState) populate(objectMap, "provisioningState", p.ProvisioningState) @@ -6528,7 +6528,7 @@ func (p *PrivateEndpointConnectionProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateLinkResource. func (p PrivateLinkResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) populate(objectMap, "properties", p.Properties) @@ -6567,7 +6567,7 @@ func (p *PrivateLinkResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceListResult. func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) } @@ -6594,7 +6594,7 @@ func (p *PrivateLinkResourceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "groupId", p.GroupID) populate(objectMap, "requiredMembers", p.RequiredMembers) populate(objectMap, "requiredZoneNames", p.RequiredZoneNames) @@ -6629,7 +6629,7 @@ func (p *PrivateLinkResourceProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateLinkServiceConnectionState. func (p PrivateLinkServiceConnectionState) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "actionsRequired", p.ActionsRequired) populate(objectMap, "description", p.Description) populate(objectMap, "status", p.Status) @@ -6664,7 +6664,7 @@ func (p *PrivateLinkServiceConnectionState) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Properties. func (p Properties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "serviceSpecification", p.ServiceSpecification) return json.Marshal(objectMap) } @@ -6691,7 +6691,7 @@ func (p *Properties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ProxyResource. func (p ProxyResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) populate(objectMap, "type", p.Type) @@ -6726,7 +6726,7 @@ func (p *ProxyResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Rectangle. func (r Rectangle) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "height", r.Height) populate(objectMap, "left", r.Left) populate(objectMap, "top", r.Top) @@ -6765,7 +6765,7 @@ func (r *Rectangle) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "type", r.Type) @@ -6800,7 +6800,7 @@ func (r *Resource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceIdentity. func (r ResourceIdentity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "useSystemAssignedIdentity", r.UseSystemAssignedIdentity) populate(objectMap, "userAssignedIdentity", r.UserAssignedIdentity) return json.Marshal(objectMap) @@ -6831,7 +6831,7 @@ func (r *ResourceIdentity) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SelectAudioTrackByAttribute. func (s SelectAudioTrackByAttribute) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "attribute", s.Attribute) populate(objectMap, "channelMapping", s.ChannelMapping) populate(objectMap, "filter", s.Filter) @@ -6874,7 +6874,7 @@ func (s *SelectAudioTrackByAttribute) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SelectAudioTrackByID. func (s SelectAudioTrackByID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "channelMapping", s.ChannelMapping) objectMap["@odata.type"] = "#Microsoft.Media.SelectAudioTrackById" populate(objectMap, "trackId", s.TrackID) @@ -6909,7 +6909,7 @@ func (s *SelectAudioTrackByID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SelectVideoTrackByAttribute. func (s SelectVideoTrackByAttribute) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "attribute", s.Attribute) populate(objectMap, "filter", s.Filter) populate(objectMap, "filterValue", s.FilterValue) @@ -6948,7 +6948,7 @@ func (s *SelectVideoTrackByAttribute) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SelectVideoTrackByID. func (s SelectVideoTrackByID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = "#Microsoft.Media.SelectVideoTrackById" populate(objectMap, "trackId", s.TrackID) return json.Marshal(objectMap) @@ -6979,7 +6979,7 @@ func (s *SelectVideoTrackByID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServiceSpecification. func (s ServiceSpecification) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "logSpecifications", s.LogSpecifications) populate(objectMap, "metricSpecifications", s.MetricSpecifications) return json.Marshal(objectMap) @@ -7010,7 +7010,7 @@ func (s *ServiceSpecification) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StandardEncoderPreset. func (s StandardEncoderPreset) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "codecs", s.Codecs) populate(objectMap, "experimentalOptions", s.ExperimentalOptions) populate(objectMap, "filters", s.Filters) @@ -7053,7 +7053,7 @@ func (s *StandardEncoderPreset) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StorageAccount. func (s StorageAccount) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "identity", s.Identity) populate(objectMap, "status", s.Status) @@ -7092,7 +7092,7 @@ func (s *StorageAccount) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StorageEncryptedAssetDecryptionData. func (s StorageEncryptedAssetDecryptionData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "assetFileEncryptionMetadata", s.AssetFileEncryptionMetadata) populateByteArray(objectMap, "key", s.Key, runtime.Base64StdFormat) return json.Marshal(objectMap) @@ -7123,7 +7123,7 @@ func (s *StorageEncryptedAssetDecryptionData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingEndpoint. func (s StreamingEndpoint) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "location", s.Location) populate(objectMap, "name", s.Name) @@ -7178,7 +7178,7 @@ func (s *StreamingEndpoint) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingEndpointAccessControl. func (s StreamingEndpointAccessControl) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "akamai", s.Akamai) populate(objectMap, "ip", s.IP) return json.Marshal(objectMap) @@ -7209,7 +7209,7 @@ func (s *StreamingEndpointAccessControl) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingEndpointListResult. func (s StreamingEndpointListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "@odata.count", s.ODataCount) populate(objectMap, "@odata.nextLink", s.ODataNextLink) populate(objectMap, "value", s.Value) @@ -7244,7 +7244,7 @@ func (s *StreamingEndpointListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingEndpointProperties. func (s StreamingEndpointProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "accessControl", s.AccessControl) populate(objectMap, "availabilitySetName", s.AvailabilitySetName) populate(objectMap, "cdnEnabled", s.CdnEnabled) @@ -7331,7 +7331,7 @@ func (s *StreamingEndpointProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingEndpointSKUInfoListResult. func (s StreamingEndpointSKUInfoListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) } @@ -7358,7 +7358,7 @@ func (s *StreamingEndpointSKUInfoListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingEntityScaleUnit. func (s StreamingEntityScaleUnit) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "scaleUnit", s.ScaleUnit) return json.Marshal(objectMap) } @@ -7385,7 +7385,7 @@ func (s *StreamingEntityScaleUnit) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingLocator. func (s StreamingLocator) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -7428,7 +7428,7 @@ func (s *StreamingLocator) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingLocatorCollection. func (s StreamingLocatorCollection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "@odata.nextLink", s.ODataNextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -7459,7 +7459,7 @@ func (s *StreamingLocatorCollection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingLocatorContentKey. func (s StreamingLocatorContentKey) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "labelReferenceInStreamingPolicy", s.LabelReferenceInStreamingPolicy) populate(objectMap, "policyName", s.PolicyName) @@ -7506,7 +7506,7 @@ func (s *StreamingLocatorContentKey) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingLocatorProperties. func (s StreamingLocatorProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "alternativeMediaId", s.AlternativeMediaID) populate(objectMap, "assetName", s.AssetName) populate(objectMap, "contentKeys", s.ContentKeys) @@ -7569,7 +7569,7 @@ func (s *StreamingLocatorProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingPath. func (s StreamingPath) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "encryptionScheme", s.EncryptionScheme) populate(objectMap, "paths", s.Paths) populate(objectMap, "streamingProtocol", s.StreamingProtocol) @@ -7604,7 +7604,7 @@ func (s *StreamingPath) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingPolicy. func (s StreamingPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -7647,7 +7647,7 @@ func (s *StreamingPolicy) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingPolicyCollection. func (s StreamingPolicyCollection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "@odata.nextLink", s.ODataNextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -7678,7 +7678,7 @@ func (s *StreamingPolicyCollection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingPolicyContentKey. func (s StreamingPolicyContentKey) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "label", s.Label) populate(objectMap, "policyName", s.PolicyName) populate(objectMap, "tracks", s.Tracks) @@ -7713,7 +7713,7 @@ func (s *StreamingPolicyContentKey) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingPolicyContentKeys. func (s StreamingPolicyContentKeys) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "defaultKey", s.DefaultKey) populate(objectMap, "keyToTrackMappings", s.KeyToTrackMappings) return json.Marshal(objectMap) @@ -7744,7 +7744,7 @@ func (s *StreamingPolicyContentKeys) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingPolicyFairPlayConfiguration. func (s StreamingPolicyFairPlayConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allowPersistentLicense", s.AllowPersistentLicense) populate(objectMap, "customLicenseAcquisitionUrlTemplate", s.CustomLicenseAcquisitionURLTemplate) return json.Marshal(objectMap) @@ -7775,7 +7775,7 @@ func (s *StreamingPolicyFairPlayConfiguration) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type StreamingPolicyPlayReadyConfiguration. func (s StreamingPolicyPlayReadyConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "customLicenseAcquisitionUrlTemplate", s.CustomLicenseAcquisitionURLTemplate) populate(objectMap, "playReadyCustomAttributes", s.PlayReadyCustomAttributes) return json.Marshal(objectMap) @@ -7806,7 +7806,7 @@ func (s *StreamingPolicyPlayReadyConfiguration) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type StreamingPolicyProperties. func (s StreamingPolicyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "commonEncryptionCbcs", s.CommonEncryptionCbcs) populate(objectMap, "commonEncryptionCenc", s.CommonEncryptionCenc) populateTimeRFC3339(objectMap, "created", s.Created) @@ -7853,7 +7853,7 @@ func (s *StreamingPolicyProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StreamingPolicyWidevineConfiguration. func (s StreamingPolicyWidevineConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "customLicenseAcquisitionUrlTemplate", s.CustomLicenseAcquisitionURLTemplate) return json.Marshal(objectMap) } @@ -7880,7 +7880,7 @@ func (s *StreamingPolicyWidevineConfiguration) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type SyncStorageKeysInput. func (s SyncStorageKeysInput) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) return json.Marshal(objectMap) } @@ -7907,7 +7907,7 @@ func (s *SyncStorageKeysInput) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -7954,7 +7954,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TextTrack. func (t TextTrack) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "displayName", t.DisplayName) populate(objectMap, "fileName", t.FileName) populate(objectMap, "hlsSettings", t.HlsSettings) @@ -8001,7 +8001,7 @@ func (t *TextTrack) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrackBase. func (t TrackBase) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = t.ODataType return json.Marshal(objectMap) } @@ -8028,7 +8028,7 @@ func (t *TrackBase) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrackDescriptor. func (t TrackDescriptor) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = t.ODataType return json.Marshal(objectMap) } @@ -8055,7 +8055,7 @@ func (t *TrackDescriptor) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrackPropertyCondition. func (t TrackPropertyCondition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "operation", t.Operation) populate(objectMap, "property", t.Property) populate(objectMap, "value", t.Value) @@ -8090,7 +8090,7 @@ func (t *TrackPropertyCondition) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrackSelection. func (t TrackSelection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "trackSelections", t.TrackSelections) return json.Marshal(objectMap) } @@ -8117,7 +8117,7 @@ func (t *TrackSelection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrackedResource. func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "location", t.Location) populate(objectMap, "name", t.Name) @@ -8160,7 +8160,7 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Transform. func (t Transform) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "name", t.Name) populate(objectMap, "properties", t.Properties) @@ -8203,7 +8203,7 @@ func (t *Transform) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TransformCollection. func (t TransformCollection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "@odata.nextLink", t.ODataNextLink) populate(objectMap, "value", t.Value) return json.Marshal(objectMap) @@ -8234,7 +8234,7 @@ func (t *TransformCollection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TransformOutput. func (t TransformOutput) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "onError", t.OnError) populate(objectMap, "preset", t.Preset) populate(objectMap, "relativePriority", t.RelativePriority) @@ -8269,7 +8269,7 @@ func (t *TransformOutput) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TransformProperties. func (t TransformProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "created", t.Created) populate(objectMap, "description", t.Description) populateTimeRFC3339(objectMap, "lastModified", t.LastModified) @@ -8308,7 +8308,7 @@ func (t *TransformProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TransportStreamFormat. func (t TransportStreamFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "filenamePattern", t.FilenamePattern) objectMap["@odata.type"] = "#Microsoft.Media.TransportStreamFormat" populate(objectMap, "outputFiles", t.OutputFiles) @@ -8343,7 +8343,7 @@ func (t *TransportStreamFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UTCClipTime. func (u UTCClipTime) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = "#Microsoft.Media.UtcClipTime" populateTimeRFC3339(objectMap, "time", u.Time) return json.Marshal(objectMap) @@ -8374,7 +8374,7 @@ func (u *UTCClipTime) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UserAssignedManagedIdentity. func (u UserAssignedManagedIdentity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "clientId", u.ClientID) populate(objectMap, "principalId", u.PrincipalID) return json.Marshal(objectMap) @@ -8405,7 +8405,7 @@ func (u *UserAssignedManagedIdentity) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Video. func (v Video) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "keyFrameInterval", v.KeyFrameInterval) populate(objectMap, "label", v.Label) objectMap["@odata.type"] = "#Microsoft.Media.Video" @@ -8448,7 +8448,7 @@ func (v *Video) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VideoAnalyzerPreset. func (v VideoAnalyzerPreset) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "audioLanguage", v.AudioLanguage) populate(objectMap, "experimentalOptions", v.ExperimentalOptions) populate(objectMap, "insightsToExtract", v.InsightsToExtract) @@ -8491,7 +8491,7 @@ func (v *VideoAnalyzerPreset) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VideoLayer. func (v VideoLayer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "adaptiveBFrame", v.AdaptiveBFrame) populate(objectMap, "bFrames", v.BFrames) populate(objectMap, "bitrate", v.Bitrate) @@ -8550,7 +8550,7 @@ func (v *VideoLayer) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VideoOverlay. func (v VideoOverlay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "audioGainLevel", v.AudioGainLevel) populate(objectMap, "cropRectangle", v.CropRectangle) populate(objectMap, "end", v.End) @@ -8613,7 +8613,7 @@ func (v *VideoOverlay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VideoTrack. func (v VideoTrack) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = "#Microsoft.Media.VideoTrack" return json.Marshal(objectMap) } @@ -8640,7 +8640,7 @@ func (v *VideoTrack) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VideoTrackDescriptor. func (v VideoTrackDescriptor) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["@odata.type"] = "#Microsoft.Media.VideoTrackDescriptor" return json.Marshal(objectMap) } @@ -8665,7 +8665,7 @@ func (v *VideoTrackDescriptor) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -8675,7 +8675,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func populateByteArray(m map[string]interface{}, k string, b []byte, f runtime.Base64Encoding) { +func populateByteArray(m map[string]any, k string, b []byte, f runtime.Base64Encoding) { if azcore.IsNullValue(b) { m[k] = nil } else if len(b) == 0 { @@ -8685,7 +8685,7 @@ func populateByteArray(m map[string]interface{}, k string, b []byte, f runtime.B } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/operationresults_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/operationresults_client.go index 1043f7a43456..e64698a33fd3 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/operationresults_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/operationresults_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,47 +25,39 @@ import ( // OperationResultsClient contains the methods for the MediaServicesOperationResults group. // Don't use this type directly, use NewOperationResultsClient() instead. type OperationResultsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewOperationResultsClient creates a new instance of OperationResultsClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationResultsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationResultsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationResultsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get media service operation result. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// locationName - Location name. -// operationID - Operation Id. -// options - OperationResultsClientGetOptions contains the optional parameters for the OperationResultsClient.Get method. +// - locationName - Location name. +// - operationID - Operation Id. +// - options - OperationResultsClientGetOptions contains the optional parameters for the OperationResultsClient.Get method. func (client *OperationResultsClient) Get(ctx context.Context, locationName string, operationID string, options *OperationResultsClientGetOptions) (OperationResultsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, locationName, operationID, options) if err != nil { return OperationResultsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationResultsClientGetResponse{}, err } @@ -92,7 +82,7 @@ func (client *OperationResultsClient) getCreateRequest(ctx context.Context, loca return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/operationresults_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/operationresults_client_example_test.go index 8ab00c234519..bf0e9de62d3e 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/operationresults_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/operationresults_client_example_test.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 armmediaservices_test @@ -16,21 +17,106 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/media-service-operation-result-by-id.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/media-service-operation-result-by-id.json func ExampleOperationResultsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewOperationResultsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "westus", "6FBA62C4-99B5-4FF8-9826-FC4744A8864F", nil) + res, err := clientFactory.NewOperationResultsClient().Get(ctx, "westus", "6FBA62C4-99B5-4FF8-9826-FC4744A8864F", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.MediaService = armmediaservices.MediaService{ + // Name: to.Ptr("contosomovies"), + // Type: to.Ptr("Microsoft.Media/mediaServices"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaServices/contosomovies"), + // Location: to.Ptr("South Central US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Identity: &armmediaservices.MediaServiceIdentity{ + // Type: to.Ptr("UserAssigned"), + // UserAssignedIdentities: map[string]*armmediaservices.UserAssignedManagedIdentity{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armmediaservices.UserAssignedManagedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2": &armmediaservices.UserAssignedManagedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armmediaservices.MediaServiceProperties{ + // Encryption: &armmediaservices.AccountEncryption{ + // Type: to.Ptr(armmediaservices.AccountEncryptionKeyTypeCustomerKey), + // Identity: &armmediaservices.ResourceIdentity{ + // UseSystemAssignedIdentity: to.Ptr(false), + // UserAssignedIdentity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), + // }, + // KeyVaultProperties: &armmediaservices.KeyVaultProperties{ + // CurrentKeyIdentifier: to.Ptr("https://keyvault.vault.azure.net/keys/key1/ver1"), + // KeyIdentifier: to.Ptr("https://keyvault.vault.azure.net/keys/key1"), + // }, + // }, + // KeyDelivery: &armmediaservices.KeyDelivery{ + // AccessControl: &armmediaservices.AccessControl{ + // DefaultAction: to.Ptr(armmediaservices.DefaultActionAllow), + // }, + // }, + // PrivateEndpointConnections: []*armmediaservices.PrivateEndpointConnection{ + // { + // Name: to.Ptr("00000000-0000-0000-0000-000000000001"), + // Type: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosotv/privateEndpointConnections/00000000-0000-0000-0000-000000000001"), + // Properties: &armmediaservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmediaservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/reosuceGroup1/providers/Microsoft.Network/privateEndpoints/pe1"), + // }, + // PrivateLinkServiceConnectionState: &armmediaservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("test description"), + // Status: to.Ptr(armmediaservices.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armmediaservices.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }, + // { + // Name: to.Ptr("00000000-0000-0000-0000-000000000002"), + // Type: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosotv/privateEndpointConnections/00000000-0000-0000-0000-000000000002"), + // Properties: &armmediaservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmediaservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/22222222-2222-2222-2222-222222222222/resourceGroups/reosuceGroup2/providers/Microsoft.Network/privateEndpoints/pe2"), + // }, + // PrivateLinkServiceConnectionState: &armmediaservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("test description"), + // Status: to.Ptr(armmediaservices.PrivateEndpointServiceConnectionStatusPending), + // }, + // ProvisioningState: to.Ptr(armmediaservices.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }}, + // ProvisioningState: to.Ptr(armmediaservices.ProvisioningStateSucceeded), + // PublicNetworkAccess: to.Ptr(armmediaservices.PublicNetworkAccessEnabled), + // StorageAccounts: []*armmediaservices.StorageAccount{ + // { + // Type: to.Ptr(armmediaservices.StorageAccountTypePrimary), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Storage/storageAccounts/contososportsstore"), + // Identity: &armmediaservices.ResourceIdentity{ + // UseSystemAssignedIdentity: to.Ptr(false), + // UserAssignedIdentity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), + // }, + // }}, + // StorageAuthentication: to.Ptr(armmediaservices.StorageAuthenticationManagedIdentity), + // }, + // } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/operations_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/operations_client.go index cf671eab811e..ecb9b745cace 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/operations_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/operations_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,42 +21,34 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // List - Lists all the Media Services operations. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. func (client *OperationsClient) List(ctx context.Context, options *OperationsClientListOptions) (OperationsClientListResponse, error) { req, err := client.listCreateRequest(ctx, options) if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -71,7 +61,7 @@ func (client *OperationsClient) List(ctx context.Context, options *OperationsCli // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Media/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/operations_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/operations_client_example_test.go index 2c50a656f256..20472b46d170 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/operations_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/operations_client_example_test.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 armmediaservices_test @@ -16,21 +17,1509 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/operations-list-all.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/operations-list-all.json func ExampleOperationsClient_List() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewOperationsClient(cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.List(ctx, nil) + res, err := clientFactory.NewOperationsClient().List(ctx, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.OperationCollection = armmediaservices.OperationCollection{ + // Value: []*armmediaservices.Operation{ + // { + // Name: to.Ptr("Microsoft.Media/register/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Registers the subscription for the Media Services resource provider and enables the creation of Media Services accounts"), + // Operation: to.Ptr("Registers the Media Services Resource Provider"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Microsoft Media Services"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/unregister/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Unregisters the subscription for the Media Services resource provider"), + // Operation: to.Ptr("Unregisters the Media Services Resource Provider"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Microsoft Media Services"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/checknameavailability/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Checks if a Media Services account name is available"), + // Operation: to.Ptr("Check Name Availability"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Microsoft Media Services"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/operations/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Get Available Operations"), + // Operation: to.Ptr("Get Available Operations"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Available Operations"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Media Services Account"), + // Operation: to.Ptr("Read Media Services Account"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Media Services Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Media Services Account"), + // Operation: to.Ptr("Create or Update Media Services Account"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Media Services Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Media Services Account"), + // Operation: to.Ptr("Delete Media Services Account"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Media Services Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/regenerateKey/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Regenerate a Media Services ACS key"), + // Operation: to.Ptr("Regenerate Key"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Media Services Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/listKeys/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("List the ACS keys for the Media Services account"), + // Operation: to.Ptr("List Keys"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Media Services Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/syncStorageKeys/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Synchronize the Storage Keys for an attached Azure Storage account"), + // Operation: to.Ptr("Synchronize Storage Keys"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Media Services Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/listEdgePolicies/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("List policies for an edge device."), + // Operation: to.Ptr("List policies for an edge device."), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Media Services Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/PrivateEndpointConnectionsApproval/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Approve Private Endpoint Connections"), + // Operation: to.Ptr("Approve Private Endpoint Connections"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Media Services Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/eventGridFilters/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Event Grid Filter"), + // Operation: to.Ptr("Read Event Grid Filter"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Event Grid Filter"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/eventGridFilters/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Event Grid Filter"), + // Operation: to.Ptr("Create or Update Event Grid Filter"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Event Grid Filter"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/eventGridFilters/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Event Grid Filter"), + // Operation: to.Ptr("Delete Event Grid Filter"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Event Grid Filter"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/accountfilters/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Account Filter"), + // Operation: to.Ptr("Read Account Filter"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Account Filter"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/accountfilters/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Account Filter"), + // Operation: to.Ptr("Create or Update Account Filter"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Account Filter"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/accountfilters/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Account Filter"), + // Operation: to.Ptr("Delete Account Filter"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Account Filter"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/assets/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Asset"), + // Operation: to.Ptr("Read Asset"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Asset"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/assets/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Asset"), + // Operation: to.Ptr("Create or Update Asset"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Asset"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/assets/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Asset"), + // Operation: to.Ptr("Delete Asset"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Asset"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/assets/listContainerSas/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("List Asset Container SAS URLs"), + // Operation: to.Ptr("List Asset Container SAS URLs"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Asset"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/assets/getEncryptionKey/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Get Asset Encryption Key"), + // Operation: to.Ptr("Get Asset Encryption Key"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Asset"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/assets/listStreamingLocators/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("List Streaming Locators for Asset"), + // Operation: to.Ptr("List Streaming Locators for Asset"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Asset"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/assets/assetfilters/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Asset Filter"), + // Operation: to.Ptr("Read Asset Filter"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Asset Filter"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/assets/assetfilters/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Asset Filter"), + // Operation: to.Ptr("Create or Update Asset Filter"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Asset Filter"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/assets/assetfilters/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Asset Filter"), + // Operation: to.Ptr("Delete Asset Filter"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Asset Filter"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingPolicies/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Streaming Policy"), + // Operation: to.Ptr("Read Streaming Policy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Policy"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingPolicies/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Streaming Policy"), + // Operation: to.Ptr("Create or Update Streaming Policy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Policy"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingPolicies/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Streaming Policy"), + // Operation: to.Ptr("Delete Streaming Policy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Policy"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingLocators/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Streaming Locator"), + // Operation: to.Ptr("Read Streaming Locator"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Locator"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingLocators/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Streaming Locator"), + // Operation: to.Ptr("Create or Update Streaming Locator"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Locator"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingLocators/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Streaming Locator"), + // Operation: to.Ptr("Delete Streaming Locator"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Locator"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingLocators/listContentKeys/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("List Content Keys"), + // Operation: to.Ptr("List Content Keys"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Locator"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingLocators/listPaths/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("List Paths"), + // Operation: to.Ptr("List Paths"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Locator"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Content Key Policy"), + // Operation: to.Ptr("Read Content Key Policy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Content Key Policy"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Content Key Policy"), + // Operation: to.Ptr("Create or Update Content Key Policy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Content Key Policy"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Content Key Policy"), + // Operation: to.Ptr("Delete Content Key Policy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Content Key Policy"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/contentKeyPolicies/getPolicyPropertiesWithSecrets/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Get Policy Properties With Secrets"), + // Operation: to.Ptr("Get Policy Properties With Secrets"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Content Key Policy"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/transforms/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Transform"), + // Operation: to.Ptr("Read Transform"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Transform"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/transforms/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Transform"), + // Operation: to.Ptr("Create or Update Transform"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Transform"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/transforms/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Transform"), + // Operation: to.Ptr("Delete Transform"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Transform"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Job"), + // Operation: to.Ptr("Read Job"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Job"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Job"), + // Operation: to.Ptr("Create or Update Job"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Job"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Job"), + // Operation: to.Ptr("Delete Job"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Job"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/transforms/jobs/cancelJob/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Cancel Job"), + // Operation: to.Ptr("Cancel Job"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Job"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/privateLinkResources/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Private Link Resource"), + // Operation: to.Ptr("Read Private Link Resource"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateLinkResource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnectionProxies/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Private Endpoint Connection Proxy"), + // Operation: to.Ptr("Read Private Endpoint Connection Proxy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateEndpointConnectionProxy"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnectionProxies/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create Private Endpoint Connection Proxy"), + // Operation: to.Ptr("Create Private Endpoint Connection Proxy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateEndpointConnectionProxy"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnectionProxies/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete Private Endpoint Connection Proxy"), + // Operation: to.Ptr("Delete Private Endpoint Connection Proxy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateEndpointConnectionProxy"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnectionProxies/validate/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Validate Private Endpoint Connection Proxy"), + // Operation: to.Ptr("Validate Private Endpoint Connection Proxy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateEndpointConnectionProxy"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnections/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Private Endpoint Connection"), + // Operation: to.Ptr("Read Private Endpoint Connection"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateEndpointConnection"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnections/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create Private Endpoint Connection"), + // Operation: to.Ptr("Create Private Endpoint Connection"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateEndpointConnection"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnections/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete Private Endpoint Connection"), + // Operation: to.Ptr("Delete Private Endpoint Connection"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateEndpointConnection"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnectionOperations/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Private Endpoint Connection Operation"), + // Operation: to.Ptr("Read Private Endpoint Connection Operation"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Private Endpoint Connection Operation"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Streaming Endpoint"), + // Operation: to.Ptr("Read Streaming Endpoint"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Endpoint"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Streaming Endpoint"), + // Operation: to.Ptr("Create or Update Streaming Endpoint"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Endpoint"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Streaming Endpoint"), + // Operation: to.Ptr("Delete Streaming Endpoint"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Endpoint"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints/start/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Start any Streaming Endpoint Operation"), + // Operation: to.Ptr("Start Streaming Endpoint Operation"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Endpoint"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints/stop/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Stop any Streaming Endpoint Operation"), + // Operation: to.Ptr("Stop Streaming Endpoint Operation"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Endpoint"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints/scale/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Scale any Streaming Endpoint Operation"), + // Operation: to.Ptr("Scale Streaming Endpoint Operation"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Endpoint"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints/providers/Microsoft.Insights/diagnosticSettings/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Gets the diagnostic setting for the resource."), + // Operation: to.Ptr("Read diagnostic setting"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Endpoints"), + // }, + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints/providers/Microsoft.Insights/diagnosticSettings/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Creates or updates the diagnostic setting for the resource."), + // Operation: to.Ptr("Write diagnostic setting"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Endpoints"), + // }, + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints/providers/Microsoft.Insights/metricDefinitions/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Get list of Media Services Streaming Endpoint Metrics definitions."), + // Operation: to.Ptr("Get list of Media Services Streaming Endpoint Metrics definitions."), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Endpoints"), + // }, + // Origin: to.Ptr("system"), + // Properties: &armmediaservices.Properties{ + // ServiceSpecification: &armmediaservices.ServiceSpecification{ + // MetricSpecifications: []*armmediaservices.MetricSpecification{ + // { + // Name: to.Ptr("Egress"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeTotal), + // Dimensions: []*armmediaservices.MetricDimension{ + // { + // Name: to.Ptr("OutputFormat"), + // DisplayName: to.Ptr("Output Format"), + // ToBeExportedForShoebox: to.Ptr(true), + // }}, + // DisplayDescription: to.Ptr("The amount of Egress data, in bytes."), + // DisplayName: to.Ptr("Egress"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Total")}, + // Unit: to.Ptr(armmediaservices.MetricUnitBytes), + // }, + // { + // Name: to.Ptr("SuccessE2ELatency"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // Dimensions: []*armmediaservices.MetricDimension{ + // { + // Name: to.Ptr("OutputFormat"), + // DisplayName: to.Ptr("Output Format"), + // ToBeExportedForShoebox: to.Ptr(true), + // }}, + // DisplayDescription: to.Ptr("The average latency for successful requests in milliseconds."), + // DisplayName: to.Ptr("Success end to end Latency"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average"), + // to.Ptr("Minimum"), + // to.Ptr("Maximum")}, + // Unit: to.Ptr(armmediaservices.MetricUnitMilliseconds), + // }, + // { + // Name: to.Ptr("Requests"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeTotal), + // Dimensions: []*armmediaservices.MetricDimension{ + // { + // Name: to.Ptr("OutputFormat"), + // DisplayName: to.Ptr("Output Format"), + // ToBeExportedForShoebox: to.Ptr(true), + // }, + // { + // Name: to.Ptr("HttpStatusCode"), + // DisplayName: to.Ptr("HTTP Status Code"), + // ToBeExportedForShoebox: to.Ptr(true), + // }, + // { + // Name: to.Ptr("ErrorCode"), + // DisplayName: to.Ptr("Error Code"), + // ToBeExportedForShoebox: to.Ptr(false), + // }}, + // DisplayDescription: to.Ptr("Requests to a Streaming Endpoint."), + // DisplayName: to.Ptr("Requests"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Total")}, + // Unit: to.Ptr(armmediaservices.MetricUnitCount), + // }, + // { + // Name: to.Ptr("EgressBandwidth"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // Dimensions: []*armmediaservices.MetricDimension{ + // }, + // DisplayDescription: to.Ptr("Egress bandwidth in bits per second."), + // DisplayName: to.Ptr("Egress bandwidth"), + // LockAggregationType: to.Ptr(armmediaservices.MetricAggregationTypeTotal), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average"), + // to.Ptr("Minimum"), + // to.Ptr("Maximum")}, + // Unit: to.Ptr(armmediaservices.MetricUnit("BitsPerSecond")), + // }, + // { + // Name: to.Ptr("CPU"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // Dimensions: []*armmediaservices.MetricDimension{ + // }, + // DisplayDescription: to.Ptr("CPU usage for premium streaming endpoints. This data is not available for standard streaming endpoints."), + // DisplayName: to.Ptr("CPU usage"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average"), + // to.Ptr("Minimum"), + // to.Ptr("Maximum")}, + // Unit: to.Ptr(armmediaservices.MetricUnit("Percent")), + // }}, + // }, + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/liveEvents/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Live Event"), + // Operation: to.Ptr("Read Live Event"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Event"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/liveEvents/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Live Event"), + // Operation: to.Ptr("Create or Update Live Event"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Event"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/liveEvents/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Live Event"), + // Operation: to.Ptr("Delete Live Event"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Event"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/liveEvents/start/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Start any Live Event Operation"), + // Operation: to.Ptr("Start Live Event Operation"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Event"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/liveEvents/stop/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Stop any Live Event Operation"), + // Operation: to.Ptr("Stop Live Event Operation"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Event"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/liveEvents/reset/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Reset any Live Event Operation"), + // Operation: to.Ptr("Reset Live Event Operation"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Event"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/liveEvents/providers/Microsoft.Insights/diagnosticSettings/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Gets the diagnostic setting for the resource."), + // Operation: to.Ptr("Read diagnostic setting"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Event"), + // }, + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/liveEvents/providers/Microsoft.Insights/diagnosticSettings/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Creates or updates the diagnostic setting for the resource."), + // Operation: to.Ptr("Write diagnostic setting"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Event"), + // }, + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/liveEvents/providers/Microsoft.Insights/metricDefinitions/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Get a list of Media Services Live Event Metrics definitions."), + // Operation: to.Ptr("Get a list of Media Services Live Event Metrics definitions."), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Event"), + // }, + // Origin: to.Ptr("system"), + // Properties: &armmediaservices.Properties{ + // ServiceSpecification: &armmediaservices.ServiceSpecification{ + // MetricSpecifications: []*armmediaservices.MetricSpecification{ + // { + // Name: to.Ptr("IngestBitrate"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // Dimensions: []*armmediaservices.MetricDimension{ + // { + // Name: to.Ptr("TrackName"), + // DisplayName: to.Ptr("Track name"), + // ToBeExportedForShoebox: to.Ptr(true), + // }}, + // DisplayDescription: to.Ptr("The incoming bitrate ingested for a live event, in bits per second."), + // DisplayName: to.Ptr("Live Event ingest bitrate"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("MicrosoftMediaLiveEvent"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average"), + // to.Ptr("Minimum"), + // to.Ptr("Maximum")}, + // Unit: to.Ptr(armmediaservices.MetricUnit("BitsPerSecond")), + // }, + // { + // Name: to.Ptr("IngestLastTimestamp"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationType("Maximum")), + // Dimensions: []*armmediaservices.MetricDimension{ + // { + // Name: to.Ptr("TrackName"), + // DisplayName: to.Ptr("Track name"), + // ToBeExportedForShoebox: to.Ptr(true), + // }}, + // DisplayDescription: to.Ptr("Last timestamp ingested for a live event."), + // DisplayName: to.Ptr("Live Event ingest last timestamp"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("MicrosoftMediaLiveEvent"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Maximum")}, + // Unit: to.Ptr(armmediaservices.MetricUnitMilliseconds), + // }, + // { + // Name: to.Ptr("IngestDriftValue"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationType("Maximum")), + // Dimensions: []*armmediaservices.MetricDimension{ + // { + // Name: to.Ptr("TrackName"), + // DisplayName: to.Ptr("Track name"), + // ToBeExportedForShoebox: to.Ptr(true), + // }}, + // DisplayDescription: to.Ptr("Drift between the timestamp of the ingested content and the system clock, measured in seconds per minute. A non zero value indicates that the ingested content is arriving slower than system clock time."), + // DisplayName: to.Ptr("Live Event ingest drift value"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("MicrosoftMediaLiveEvent"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Maximum")}, + // Unit: to.Ptr(armmediaservices.MetricUnit("Seconds")), + // }, + // { + // Name: to.Ptr("LiveOutputLastTimestamp"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationType("Maximum")), + // Dimensions: []*armmediaservices.MetricDimension{ + // { + // Name: to.Ptr("TrackName"), + // DisplayName: to.Ptr("Track name"), + // ToBeExportedForShoebox: to.Ptr(true), + // }}, + // DisplayDescription: to.Ptr("Timestamp of the last fragment uploaded to storage for a live event output."), + // DisplayName: to.Ptr("Last output timestamp"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("MicrosoftMediaLiveEvent"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Maximum")}, + // Unit: to.Ptr(armmediaservices.MetricUnitMilliseconds), + // }}, + // }, + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/liveEvents/liveOutputs/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Live Output"), + // Operation: to.Ptr("Read Live Output"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Output"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/liveEvents/liveOutputs/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Live Output"), + // Operation: to.Ptr("Create or Update Live Output"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Output"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/liveEvents/liveOutputs/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Live Output"), + // Operation: to.Ptr("Delete Live Output"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Output"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/streamingEndpointOperations/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Streaming Endpoint Operation"), + // Operation: to.Ptr("Read Streaming Endpoint Operation"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Streaming Endpoint Operation"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/liveEventOperations/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Live Event Operation"), + // Operation: to.Ptr("Read Live Event Operation"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Event Operation"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/liveOutputOperations/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Live Output Operation"), + // Operation: to.Ptr("Read Live Output Operation"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Output Operation"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/providers/Microsoft.Insights/diagnosticSettings/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Gets the diagnostic setting for the resource."), + // Operation: to.Ptr("Read diagnostic setting"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Media Services Account"), + // }, + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/providers/Microsoft.Insights/diagnosticSettings/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Creates or updates the diagnostic setting for the resource."), + // Operation: to.Ptr("Write diagnostic setting"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Media Services Account"), + // }, + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/providers/Microsoft.Insights/logDefinitions/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Gets the available logs for a Media Services Account"), + // Operation: to.Ptr("Read mediaservices log definitions"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("The log definition of mediaservices"), + // }, + // Origin: to.Ptr("system"), + // Properties: &armmediaservices.Properties{ + // ServiceSpecification: &armmediaservices.ServiceSpecification{ + // LogSpecifications: []*armmediaservices.LogSpecification{ + // { + // Name: to.Ptr("KeyDeliveryRequests"), + // BlobDuration: to.Ptr("PT1H"), + // DisplayName: to.Ptr("Key Delivery Requests"), + // }}, + // }, + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/mediaservices/providers/Microsoft.Insights/metricDefinitions/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Get list of Media Services Metric definitions."), + // Operation: to.Ptr("Get list of Media Services Metric definitions."), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Media Service"), + // }, + // Origin: to.Ptr("system"), + // Properties: &armmediaservices.Properties{ + // ServiceSpecification: &armmediaservices.ServiceSpecification{ + // MetricSpecifications: []*armmediaservices.MetricSpecification{ + // { + // Name: to.Ptr("AssetQuota"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // DisplayDescription: to.Ptr("How many assets are allowed for current media service account"), + // DisplayName: to.Ptr("Asset quota"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("MediaServiceQuotaAndUsage"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average")}, + // SupportedTimeGrainTypes: []*string{ + // to.Ptr("PT1H"), + // to.Ptr("PT6H"), + // to.Ptr("PT12H"), + // to.Ptr("P1D")}, + // Unit: to.Ptr(armmediaservices.MetricUnitCount), + // }, + // { + // Name: to.Ptr("AssetCount"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // DisplayDescription: to.Ptr("How many assets are already created in current media service account"), + // DisplayName: to.Ptr("Asset count"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("MediaServiceQuotaAndUsage"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average")}, + // SupportedTimeGrainTypes: []*string{ + // to.Ptr("PT1H"), + // to.Ptr("PT6H"), + // to.Ptr("PT12H"), + // to.Ptr("P1D")}, + // Unit: to.Ptr(armmediaservices.MetricUnitCount), + // }, + // { + // Name: to.Ptr("AssetQuotaUsedPercentage"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // DisplayDescription: to.Ptr("Asset used percentage in current media service account"), + // DisplayName: to.Ptr("Asset quota used percentage"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("MediaServiceQuotaAndUsage"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average")}, + // SupportedTimeGrainTypes: []*string{ + // to.Ptr("PT1H"), + // to.Ptr("PT6H"), + // to.Ptr("PT12H"), + // to.Ptr("P1D")}, + // Unit: to.Ptr(armmediaservices.MetricUnit("Percent")), + // }, + // { + // Name: to.Ptr("ContentKeyPolicyQuota"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // DisplayDescription: to.Ptr("How many content key polices are allowed for current media service account"), + // DisplayName: to.Ptr("Content Key Policy quota"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("MediaServiceQuotaAndUsage"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average")}, + // SupportedTimeGrainTypes: []*string{ + // to.Ptr("PT1H"), + // to.Ptr("PT6H"), + // to.Ptr("PT12H"), + // to.Ptr("P1D")}, + // Unit: to.Ptr(armmediaservices.MetricUnitCount), + // }, + // { + // Name: to.Ptr("ContentKeyPolicyCount"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // DisplayDescription: to.Ptr("How many content key policies are already created in current media service account"), + // DisplayName: to.Ptr("Content Key Policy count"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("MediaServiceQuotaAndUsage"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average")}, + // SupportedTimeGrainTypes: []*string{ + // to.Ptr("PT1H"), + // to.Ptr("PT6H"), + // to.Ptr("PT12H"), + // to.Ptr("P1D")}, + // Unit: to.Ptr(armmediaservices.MetricUnitCount), + // }, + // { + // Name: to.Ptr("ContentKeyPolicyQuotaUsedPercentage"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // DisplayDescription: to.Ptr("Content Key Policy used percentage in current media service account"), + // DisplayName: to.Ptr("Content Key Policy quota used percentage"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("MediaServiceQuotaAndUsage"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average")}, + // SupportedTimeGrainTypes: []*string{ + // to.Ptr("PT1H"), + // to.Ptr("PT6H"), + // to.Ptr("PT12H"), + // to.Ptr("P1D")}, + // Unit: to.Ptr(armmediaservices.MetricUnit("Percent")), + // }, + // { + // Name: to.Ptr("StreamingPolicyQuota"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // DisplayDescription: to.Ptr("How many streaming policies are allowed for current media service account"), + // DisplayName: to.Ptr("Streaming Policy quota"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("MediaServiceQuotaAndUsage"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average")}, + // SupportedTimeGrainTypes: []*string{ + // to.Ptr("PT1H"), + // to.Ptr("PT6H"), + // to.Ptr("PT12H"), + // to.Ptr("P1D")}, + // Unit: to.Ptr(armmediaservices.MetricUnitCount), + // }, + // { + // Name: to.Ptr("StreamingPolicyCount"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // DisplayDescription: to.Ptr("How many streaming policies are already created in current media service account"), + // DisplayName: to.Ptr("Streaming Policy count"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("MediaServiceQuotaAndUsage"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average")}, + // SupportedTimeGrainTypes: []*string{ + // to.Ptr("PT1H"), + // to.Ptr("PT6H"), + // to.Ptr("PT12H"), + // to.Ptr("P1D")}, + // Unit: to.Ptr(armmediaservices.MetricUnitCount), + // }, + // { + // Name: to.Ptr("StreamingPolicyQuotaUsedPercentage"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // DisplayDescription: to.Ptr("Streaming Policy used percentage in current media service account"), + // DisplayName: to.Ptr("Streaming Policy quota used percentage"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("MediaServiceQuotaAndUsage"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average")}, + // SupportedTimeGrainTypes: []*string{ + // to.Ptr("PT1H"), + // to.Ptr("PT6H"), + // to.Ptr("PT12H"), + // to.Ptr("P1D")}, + // Unit: to.Ptr(armmediaservices.MetricUnit("Percent")), + // }, + // { + // Name: to.Ptr("ChannelsAndLiveEventsCount"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // DisplayDescription: to.Ptr("The total number of live events in the current media services account"), + // DisplayName: to.Ptr("Live event count"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("ClusterResource_ChannelsAndLiveEvents"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average")}, + // Unit: to.Ptr(armmediaservices.MetricUnitCount), + // }, + // { + // Name: to.Ptr("RunningChannelsAndLiveEventsCount"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // DisplayDescription: to.Ptr("The total number of running live events in the current media services account"), + // DisplayName: to.Ptr("Running live event count"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("ClusterResource_ChannelsAndLiveEvents"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average")}, + // Unit: to.Ptr(armmediaservices.MetricUnitCount), + // }, + // { + // Name: to.Ptr("MaxChannelsAndLiveEventsCount"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // DisplayDescription: to.Ptr("The maximum number of live events allowed in the current media services account"), + // DisplayName: to.Ptr("Max live event quota"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("ClusterResource_ChannelsAndLiveEvents"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average")}, + // Unit: to.Ptr(armmediaservices.MetricUnitCount), + // }, + // { + // Name: to.Ptr("MaxRunningChannelsAndLiveEventsCount"), + // AggregationType: to.Ptr(armmediaservices.MetricAggregationTypeAverage), + // DisplayDescription: to.Ptr("The maximum number of running live events allowed in the current media services account"), + // DisplayName: to.Ptr("Max running live event quota"), + // EnableRegionalMdmAccount: to.Ptr(true), + // SourceMdmNamespace: to.Ptr("ClusterResource_ChannelsAndLiveEvents"), + // SupportedAggregationTypes: []*string{ + // to.Ptr("Average")}, + // Unit: to.Ptr(armmediaservices.MetricUnitCount), + // }}, + // }, + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read a Video Analyzer Account"), + // Operation: to.Ptr("Read a Video Analyzer Account"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Video Analyzer Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update a Video Analyzer Account"), + // Operation: to.Ptr("Create or Update a Video Analyzer Account"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Video Analyzer Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete a Video Analyzer Account"), + // Operation: to.Ptr("Delete a Video Analyzer Account"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Video Analyzer Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/PrivateEndpointConnectionsApproval/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Approve Private Endpoint Connections"), + // Operation: to.Ptr("Approve Private Endpoint Connections"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Video Analyzer Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/videos/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Video"), + // Operation: to.Ptr("Read Video"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Video Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/videos/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Video"), + // Operation: to.Ptr("Create or Update Video"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Video Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/videos/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Video"), + // Operation: to.Ptr("Delete Video"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Video Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/videos/listStreamingToken/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Generates a streaming token which can be used for video playback"), + // Operation: to.Ptr("Generates a streaming token which can be used for video playback"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Video Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/videos/listContentToken/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Generates a content token which can be used for video playback"), + // Operation: to.Ptr("Generates a content token which can be used for video playback"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Video Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/accessPolicies/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Access Policy"), + // Operation: to.Ptr("Read Access Policy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Access Policy Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/accessPolicies/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Access Policy"), + // Operation: to.Ptr("Create or Update Access Policy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Access Policy Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/accessPolicies/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Access Policy"), + // Operation: to.Ptr("Delete Access Policy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Access Policy Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/edgeModules/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Edge Module"), + // Operation: to.Ptr("Read Edge Module"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Edge Module Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/edgeModules/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Edge Module"), + // Operation: to.Ptr("Create or Update Edge Module"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Edge Module Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/edgeModules/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Edge Module"), + // Operation: to.Ptr("Delete Edge Module"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Edge Module Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/edgeModules/listProvisioningToken/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Creates a new provisioning token. A provisioning token allows for a single instance of Azure Video analyzer IoT edge module to be initialized and authorized to the cloud account. The provisioning token itself is short lived and it is only used for the initial handshake between IoT edge module and the cloud. After the initial handshake, the IoT edge module will agree on a set of authentication keys which will be auto-rotated as long as the module is able to periodically connect to the cloud. A new provisioning token can be generated for the same IoT edge module in case the module state lost or reset"), + // Operation: to.Ptr("Creates a new provisioning token"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Edge Module Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/pipelineTopologies/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Pipeline Topology"), + // Operation: to.Ptr("Read Pipeline Topology"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Pipeline Topology Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/pipelineTopologies/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Pipeline Topology"), + // Operation: to.Ptr("Create or Update Pipeline Topology"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Pipeline Topology Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/pipelineTopologies/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Pipeline Topology"), + // Operation: to.Ptr("Delete Pipeline Topology"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Pipeline Topology Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/livePipelines/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Live Pipeline"), + // Operation: to.Ptr("Read Live Pipeline"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Pipeline Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/livePipelines/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Live Pipeline"), + // Operation: to.Ptr("Create or Update Live Pipeline"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Pipeline Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/livePipelines/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Live Pipeline"), + // Operation: to.Ptr("Delete Live Pipeline"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Pipeline Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/livePipelines/activate/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Activate any Live Pipeline"), + // Operation: to.Ptr("Activate Live Pipeline"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Pipeline Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/livePipelines/deactivate/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Deactivate any Live Pipeline"), + // Operation: to.Ptr("Deactivate Live Pipeline"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Pipeline Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/livePipelines/operationsStatus/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Live Pipeline operation status"), + // Operation: to.Ptr("Read Live Pipeline operation status"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Live Pipeline operation status Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/pipelineJobs/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Pipeline Job"), + // Operation: to.Ptr("Read Pipeline Job"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Pipeline Job Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/pipelineJobs/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create or Update any Pipeline Job"), + // Operation: to.Ptr("Create or Update Pipeline Job"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Pipeline Job Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/pipelineJobs/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete any Pipeline Job"), + // Operation: to.Ptr("Delete Pipeline Job"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Pipeline Job Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/pipelineJobs/cancel/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Cancel any Pipeline Job"), + // Operation: to.Ptr("Cancel Pipeline Job"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Pipeline Job Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/pipelineJobs/operationsStatus/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Pipeline Job operation status"), + // Operation: to.Ptr("Read Pipeline Job operation status"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Pipeline Job operation status Resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/privateLinkResources/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Private Link Resource"), + // Operation: to.Ptr("Read Private Link Resource"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateLinkResource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/privateEndpointConnectionProxies/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Private Endpoint Connection Proxy"), + // Operation: to.Ptr("Read Private Endpoint Connection Proxy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateEndpointConnectionProxy"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/privateEndpointConnectionProxies/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create Private Endpoint Connection Proxy"), + // Operation: to.Ptr("Create Private Endpoint Connection Proxy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateEndpointConnectionProxy"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/privateEndpointConnectionProxies/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete Private Endpoint Connection Proxy"), + // Operation: to.Ptr("Delete Private Endpoint Connection Proxy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateEndpointConnectionProxy"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/privateEndpointConnectionProxies/validate/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Validate Private Endpoint Connection Proxy"), + // Operation: to.Ptr("Validate Private Endpoint Connection Proxy"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateEndpointConnectionProxy"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/privateEndpointConnections/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Private Endpoint Connection"), + // Operation: to.Ptr("Read Private Endpoint Connection"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateEndpointConnection"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/privateEndpointConnections/write"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Create Private Endpoint Connection"), + // Operation: to.Ptr("Create Private Endpoint Connection"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateEndpointConnection"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/privateEndpointConnections/delete"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Delete Private Endpoint Connection"), + // Operation: to.Ptr("Delete Private Endpoint Connection"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("PrivateEndpointConnection"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/videoAnalyzers/privateEndpointConnectionOperations/read"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Read any Private Endpoint Connection Operation"), + // Operation: to.Ptr("Read Private Endpoint Connection Operation"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Private Endpoint Connection Operation"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Media/locations/checkNameAvailability/action"), + // Display: &armmediaservices.OperationDisplay{ + // Description: to.Ptr("Checks if a Media Services account name is available"), + // Operation: to.Ptr("Check Name Availability"), + // Provider: to.Ptr("Microsoft Media Services"), + // Resource: to.Ptr("Microsoft Media Services"), + // }, + // }}, + // } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/operationstatuses_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/operationstatuses_client.go index 6ca002166d82..564f6320db14 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/operationstatuses_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/operationstatuses_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,47 +24,39 @@ import ( // OperationStatusesClient contains the methods for the MediaServicesOperationStatuses group. // Don't use this type directly, use NewOperationStatusesClient() instead. type OperationStatusesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewOperationStatusesClient creates a new instance of OperationStatusesClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationStatusesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationStatusesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationStatusesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationStatusesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get media service operation status. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// locationName - Location name. -// operationID - Operation ID. -// options - OperationStatusesClientGetOptions contains the optional parameters for the OperationStatusesClient.Get method. +// - locationName - Location name. +// - operationID - Operation ID. +// - options - OperationStatusesClientGetOptions contains the optional parameters for the OperationStatusesClient.Get method. func (client *OperationStatusesClient) Get(ctx context.Context, locationName string, operationID string, options *OperationStatusesClientGetOptions) (OperationStatusesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, locationName, operationID, options) if err != nil { return OperationStatusesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationStatusesClientGetResponse{}, err } @@ -91,7 +81,7 @@ func (client *OperationStatusesClient) getCreateRequest(ctx context.Context, loc return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/operationstatuses_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/operationstatuses_client_example_test.go index 935c52436b0b..096bdf164083 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/operationstatuses_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/operationstatuses_client_example_test.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 armmediaservices_test @@ -16,59 +17,87 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/media-service-operation-status-by-id-non-terminal-state-failed.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/media-service-operation-status-by-id-non-terminal-state-failed.json func ExampleOperationStatusesClient_Get_getStatusOfAsynchronousOperationWhenItIsCompletedWithError() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewOperationStatusesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "westus", "D612C429-2526-49D5-961B-885AE11406FD", nil) + res, err := clientFactory.NewOperationStatusesClient().Get(ctx, "westus", "D612C429-2526-49D5-961B-885AE11406FD", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.MediaServiceOperationStatus = armmediaservices.MediaServiceOperationStatus{ + // Name: to.Ptr("D612C429-2526-49D5-961B-885AE11406FD"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-01T12:56:36.002812-08:00"); return t}()), + // Error: &armmediaservices.ErrorDetail{ + // Code: to.Ptr("BadRequest"), + // Message: to.Ptr("Storage account cannot be accessed."), + // }, + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/locations/westus/MediaServicesOperationStatuses/D612C429-2526-49D5-961B-885AE11406FD"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-01T12:56:36.002812-08:00"); return t}()), + // Status: to.Ptr("Failed"), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/media-service-operation-status-by-id-terminal-state.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/media-service-operation-status-by-id-terminal-state.json func ExampleOperationStatusesClient_Get_getStatusOfAsynchronousOperationWhenItIsCompleted() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewOperationStatusesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "westus", "D612C429-2526-49D5-961B-885AE11406FD", nil) + res, err := clientFactory.NewOperationStatusesClient().Get(ctx, "westus", "D612C429-2526-49D5-961B-885AE11406FD", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.MediaServiceOperationStatus = armmediaservices.MediaServiceOperationStatus{ + // Name: to.Ptr("D612C429-2526-49D5-961B-885AE11406FD"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-01T12:56:36.002812-08:00"); return t}()), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/locations/westus/MediaServicesOperationStatuses/D612C429-2526-49D5-961B-885AE11406FD"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-01T12:56:36.002812-08:00"); return t}()), + // Status: to.Ptr("Succeeded"), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/media-service-operation-status-by-id-non-terminal-state.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/media-service-operation-status-by-id-non-terminal-state.json func ExampleOperationStatusesClient_Get_getStatusOfAsynchronousOperationWhenItIsOngoing() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewOperationStatusesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "westus", "D612C429-2526-49D5-961B-885AE11406FD", nil) + res, err := clientFactory.NewOperationStatusesClient().Get(ctx, "westus", "D612C429-2526-49D5-961B-885AE11406FD", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.MediaServiceOperationStatus = armmediaservices.MediaServiceOperationStatus{ + // Name: to.Ptr("D612C429-2526-49D5-961B-885AE11406FD"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-01T12:56:36.002812-08:00"); return t}()), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/locations/westus/MediaServicesOperationStatuses/D612C429-2526-49D5-961B-885AE11406FD"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-01T12:56:36.002812-08:00"); return t}()), + // Status: to.Ptr("InProgress"), + // } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/polymorphic_helpers.go b/sdk/resourcemanager/mediaservices/armmediaservices/polymorphic_helpers.go index bcdcadcdf0ba..e3470ba0c25f 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/polymorphic_helpers.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/polymorphic_helpers.go @@ -15,7 +15,7 @@ func unmarshalClipTimeClassification(rawMsg json.RawMessage) (ClipTimeClassifica if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -35,7 +35,7 @@ func unmarshalCodecClassification(rawMsg json.RawMessage) (CodecClassification, if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -92,7 +92,7 @@ func unmarshalContentKeyPolicyConfigurationClassification(rawMsg json.RawMessage if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -118,7 +118,7 @@ func unmarshalContentKeyPolicyPlayReadyContentKeyLocationClassification(rawMsg j if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -138,7 +138,7 @@ func unmarshalContentKeyPolicyRestrictionClassification(rawMsg json.RawMessage) if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -160,7 +160,7 @@ func unmarshalContentKeyPolicyRestrictionTokenKeyClassification(rawMsg json.RawM if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -201,7 +201,7 @@ func unmarshalFormatClassification(rawMsg json.RawMessage) (FormatClassification if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -248,7 +248,7 @@ func unmarshalInputDefinitionClassification(rawMsg json.RawMessage) (InputDefini if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -289,7 +289,7 @@ func unmarshalJobInputClassification(rawMsg json.RawMessage) (JobInputClassifica if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -334,7 +334,7 @@ func unmarshalJobInputClipClassification(rawMsg json.RawMessage) (JobInputClipCl if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -373,7 +373,7 @@ func unmarshalJobOutputClassification(rawMsg json.RawMessage) (JobOutputClassifi if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -410,7 +410,7 @@ func unmarshalOverlayClassification(rawMsg json.RawMessage) (OverlayClassificati if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -449,7 +449,7 @@ func unmarshalPresetClassification(rawMsg json.RawMessage) (PresetClassification if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -475,7 +475,7 @@ func unmarshalTrackBaseClassification(rawMsg json.RawMessage) (TrackBaseClassifi if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -497,7 +497,7 @@ func unmarshalTrackDescriptorClassification(rawMsg json.RawMessage) (TrackDescri if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/privateendpointconnections_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/privateendpointconnections_client.go index ae9b799cf989..7da5fb57dc77 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/privateendpointconnections_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/privateendpointconnections_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,49 +24,41 @@ import ( // PrivateEndpointConnectionsClient contains the methods for the PrivateEndpointConnections group. // Don't use this type directly, use NewPrivateEndpointConnectionsClient() instead. type PrivateEndpointConnectionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PrivateEndpointConnectionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PrivateEndpointConnectionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Update an existing private endpoint connection. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// parameters - The request parameters -// options - PrivateEndpointConnectionsClientCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnectionsClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - parameters - The request parameters +// - options - PrivateEndpointConnectionsClientCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnectionsClient.CreateOrUpdate +// method. func (client *PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, name string, parameters PrivateEndpointConnection, options *PrivateEndpointConnectionsClientCreateOrUpdateOptions) (PrivateEndpointConnectionsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, name, parameters, options) if err != nil { return PrivateEndpointConnectionsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientCreateOrUpdateResponse{}, err } @@ -97,7 +87,7 @@ func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -119,17 +109,18 @@ func (client *PrivateEndpointConnectionsClient) createOrUpdateHandleResponse(res // Delete - Deletes a private endpoint connection. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// options - PrivateEndpointConnectionsClientDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Delete -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - options - PrivateEndpointConnectionsClientDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Delete +// method. func (client *PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, name string, options *PrivateEndpointConnectionsClientDeleteOptions) (PrivateEndpointConnectionsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, name, options) if err != nil { return PrivateEndpointConnectionsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientDeleteResponse{}, err } @@ -158,7 +149,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -171,17 +162,18 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // Get - Get the details of a private endpoint connection. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// options - PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - options - PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get +// method. func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, accountName string, name string, options *PrivateEndpointConnectionsClientGetOptions) (PrivateEndpointConnectionsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, name, options) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err } @@ -210,7 +202,7 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -232,17 +224,18 @@ func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Res // List - List all private endpoint connections. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// options - PrivateEndpointConnectionsClientListOptions contains the optional parameters for the PrivateEndpointConnectionsClient.List -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - options - PrivateEndpointConnectionsClientListOptions contains the optional parameters for the PrivateEndpointConnectionsClient.List +// method. func (client *PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, accountName string, options *PrivateEndpointConnectionsClientListOptions) (PrivateEndpointConnectionsClientListResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return PrivateEndpointConnectionsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientListResponse{}, err } @@ -267,7 +260,7 @@ func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Co return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/privateendpointconnections_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/privateendpointconnections_client_example_test.go index 9d381023b814..d3cb173b0e9f 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/privateendpointconnections_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/privateendpointconnections_client_example_test.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 armmediaservices_test @@ -17,56 +18,106 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/private-endpoint-connection-list.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/private-endpoint-connection-list.json func ExamplePrivateEndpointConnectionsClient_List() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewPrivateEndpointConnectionsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.List(ctx, "contoso", "contososports", nil) + res, err := clientFactory.NewPrivateEndpointConnectionsClient().List(ctx, "contoso", "contososports", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateEndpointConnectionListResult = armmediaservices.PrivateEndpointConnectionListResult{ + // Value: []*armmediaservices.PrivateEndpointConnection{ + // { + // Name: to.Ptr("cn1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fabrikam/providers/Microsoft.Media/mediaservices/contososports/privateEndpointConnections/cn1"), + // Properties: &armmediaservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmediaservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/reosuceGroup1/providers/Microsoft.Network/privateEndpoints/pe1"), + // }, + // PrivateLinkServiceConnectionState: &armmediaservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Test description"), + // Status: to.Ptr(armmediaservices.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armmediaservices.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }, + // { + // Name: to.Ptr("cn2"), + // Type: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fabrikam/providers/Microsoft.Media/mediaservices/contososports/privateEndpointConnections/cn2"), + // Properties: &armmediaservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmediaservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/22222222-2222-2222-2222-222222222222/resourceGroups/reosuceGroup2/providers/Microsoft.Network/privateEndpoints/pe2"), + // }, + // PrivateLinkServiceConnectionState: &armmediaservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Test description"), + // Status: to.Ptr(armmediaservices.PrivateEndpointServiceConnectionStatusPending), + // }, + // ProvisioningState: to.Ptr(armmediaservices.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }}, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/private-endpoint-connection-get-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/private-endpoint-connection-get-by-name.json func ExamplePrivateEndpointConnectionsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewPrivateEndpointConnectionsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contoso", "contososports", "connectionName1", nil) + res, err := clientFactory.NewPrivateEndpointConnectionsClient().Get(ctx, "contoso", "contososports", "connectionName1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateEndpointConnection = armmediaservices.PrivateEndpointConnection{ + // Name: to.Ptr("connectionName1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fabrikam/providers/Microsoft.Media/mediaservices/contososports/privateEndpointConnections/connectionName1"), + // Properties: &armmediaservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmediaservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/reosuceGroup1/providers/Microsoft.Network/privateEndpoints/privateEndpointName1"), + // }, + // PrivateLinkServiceConnectionState: &armmediaservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Test description."), + // Status: to.Ptr(armmediaservices.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armmediaservices.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/private-endpoint-connection-put.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/private-endpoint-connection-put.json func ExamplePrivateEndpointConnectionsClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewPrivateEndpointConnectionsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "contoso", "contososports", "connectionName1", armmediaservices.PrivateEndpointConnection{ + res, err := clientFactory.NewPrivateEndpointConnectionsClient().CreateOrUpdate(ctx, "contoso", "contososports", "connectionName1", armmediaservices.PrivateEndpointConnection{ Properties: &armmediaservices.PrivateEndpointConnectionProperties{ PrivateLinkServiceConnectionState: &armmediaservices.PrivateLinkServiceConnectionState{ Description: to.Ptr("Test description."), @@ -77,22 +128,38 @@ func ExamplePrivateEndpointConnectionsClient_CreateOrUpdate() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateEndpointConnection = armmediaservices.PrivateEndpointConnection{ + // Name: to.Ptr("connectionName1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fabrikam/providers/Microsoft.Media/mediaservices/contososports/privateEndpointConnections/connectionName1"), + // Properties: &armmediaservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmediaservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/reosuceGroup1/providers/Microsoft.Network/privateEndpoints/privateEndpointName1"), + // }, + // PrivateLinkServiceConnectionState: &armmediaservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Test description."), + // Status: to.Ptr(armmediaservices.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armmediaservices.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/private-endpoint-connection-delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/private-endpoint-connection-delete.json func ExamplePrivateEndpointConnectionsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewPrivateEndpointConnectionsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "contoso", "contososports", "connectionName1", nil) + _, err = clientFactory.NewPrivateEndpointConnectionsClient().Delete(ctx, "contoso", "contososports", "connectionName1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/privatelinkresources_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/privatelinkresources_client.go index e1d229b57a36..aa0cb83b8abb 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/privatelinkresources_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/privatelinkresources_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // PrivateLinkResourcesClient contains the methods for the PrivateLinkResources group. // Don't use this type directly, use NewPrivateLinkResourcesClient() instead. type PrivateLinkResourcesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkResourcesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PrivateLinkResourcesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PrivateLinkResourcesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get details of a group ID. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// options - PrivateLinkResourcesClientGetOptions contains the optional parameters for the PrivateLinkResourcesClient.Get -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - options - PrivateLinkResourcesClientGetOptions contains the optional parameters for the PrivateLinkResourcesClient.Get +// method. func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, accountName string, name string, options *PrivateLinkResourcesClientGetOptions) (PrivateLinkResourcesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, name, options) if err != nil { return PrivateLinkResourcesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkResourcesClientGetResponse{}, err } @@ -96,7 +86,7 @@ func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -118,17 +108,18 @@ func (client *PrivateLinkResourcesClient) getHandleResponse(resp *http.Response) // List - List supported group IDs. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// options - PrivateLinkResourcesClientListOptions contains the optional parameters for the PrivateLinkResourcesClient.List -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - options - PrivateLinkResourcesClientListOptions contains the optional parameters for the PrivateLinkResourcesClient.List +// method. func (client *PrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *PrivateLinkResourcesClientListOptions) (PrivateLinkResourcesClientListResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return PrivateLinkResourcesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkResourcesClientListResponse{}, err } @@ -153,7 +144,7 @@ func (client *PrivateLinkResourcesClient) listCreateRequest(ctx context.Context, return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/privatelinkresources_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/privatelinkresources_client_example_test.go index 32a45193f436..01f6e15fa78a 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/privatelinkresources_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/privatelinkresources_client_example_test.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 armmediaservices_test @@ -16,40 +17,65 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/private-link-resources-list.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/private-link-resources-list.json func ExamplePrivateLinkResourcesClient_List() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewPrivateLinkResourcesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.List(ctx, "contoso", "contososports", nil) + res, err := clientFactory.NewPrivateLinkResourcesClient().List(ctx, "contoso", "contososports", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateLinkResourceListResult = armmediaservices.PrivateLinkResourceListResult{ + // Value: []*armmediaservices.PrivateLinkResource{ + // { + // Name: to.Ptr("keydelivery"), + // Type: to.Ptr("Microsoft.Media/mediaservices/privateLinkResources"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fabrikam/providers/Microsoft.Media/mediaservices/contososports/privateLinkResources/keydelivery"), + // Properties: &armmediaservices.PrivateLinkResourceProperties{ + // GroupID: to.Ptr("keydelivery"), + // RequiredMembers: []*string{ + // to.Ptr("keydelivery")}, + // }, + // }}, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/private-link-resources-get-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2021-11-01/examples/private-link-resources-get-by-name.json func ExamplePrivateLinkResourcesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewPrivateLinkResourcesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contoso", "contososports", "keydelivery", nil) + res, err := clientFactory.NewPrivateLinkResourcesClient().Get(ctx, "contoso", "contososports", "keydelivery", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateLinkResource = armmediaservices.PrivateLinkResource{ + // Name: to.Ptr("keydelivery"), + // Type: to.Ptr("Microsoft.Media/mediaservices/privateLinkResources"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fabrikam/providers/Microsoft.Media/mediaservices/contososports/privateLinkResources/keydelivery"), + // Properties: &armmediaservices.PrivateLinkResourceProperties{ + // GroupID: to.Ptr("keydelivery"), + // RequiredMembers: []*string{ + // to.Ptr("keydelivery")}, + // }, + // } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/response_types.go b/sdk/resourcemanager/mediaservices/armmediaservices/response_types.go index 273d19f7ce2a..38562b825790 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/response_types.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/response_types.go @@ -24,7 +24,7 @@ type AccountFiltersClientGetResponse struct { AccountFilter } -// AccountFiltersClientListResponse contains the response from method AccountFiltersClient.List. +// AccountFiltersClientListResponse contains the response from method AccountFiltersClient.NewListPager. type AccountFiltersClientListResponse struct { AccountFilterCollection } @@ -49,7 +49,7 @@ type AssetFiltersClientGetResponse struct { AssetFilter } -// AssetFiltersClientListResponse contains the response from method AssetFiltersClient.List. +// AssetFiltersClientListResponse contains the response from method AssetFiltersClient.NewListPager. type AssetFiltersClientListResponse struct { AssetFilterCollection } @@ -102,7 +102,7 @@ type AssetsClientListContainerSasResponse struct { AssetContainerSas } -// AssetsClientListResponse contains the response from method AssetsClient.List. +// AssetsClientListResponse contains the response from method AssetsClient.NewListPager. type AssetsClientListResponse struct { AssetCollection } @@ -117,7 +117,7 @@ type AssetsClientUpdateResponse struct { Asset } -// ClientCreateOrUpdateResponse contains the response from method Client.CreateOrUpdate. +// ClientCreateOrUpdateResponse contains the response from method Client.BeginCreateOrUpdate. type ClientCreateOrUpdateResponse struct { MediaService } @@ -132,7 +132,7 @@ type ClientGetResponse struct { MediaService } -// ClientListBySubscriptionResponse contains the response from method Client.ListBySubscription. +// ClientListBySubscriptionResponse contains the response from method Client.NewListBySubscriptionPager. type ClientListBySubscriptionResponse struct { MediaServiceCollection } @@ -142,7 +142,7 @@ type ClientListEdgePoliciesResponse struct { EdgePolicies } -// ClientListResponse contains the response from method Client.List. +// ClientListResponse contains the response from method Client.NewListPager. type ClientListResponse struct { MediaServiceCollection } @@ -152,7 +152,7 @@ type ClientSyncStorageKeysResponse struct { // placeholder for future response values } -// ClientUpdateResponse contains the response from method Client.Update. +// ClientUpdateResponse contains the response from method Client.BeginUpdate. type ClientUpdateResponse struct { MediaService } @@ -177,7 +177,7 @@ type ContentKeyPoliciesClientGetResponse struct { ContentKeyPolicy } -// ContentKeyPoliciesClientListResponse contains the response from method ContentKeyPoliciesClient.List. +// ContentKeyPoliciesClientListResponse contains the response from method ContentKeyPoliciesClient.NewListPager. type ContentKeyPoliciesClientListResponse struct { ContentKeyPolicyCollection } @@ -207,7 +207,7 @@ type JobsClientGetResponse struct { Job } -// JobsClientListResponse contains the response from method JobsClient.List. +// JobsClientListResponse contains the response from method JobsClient.NewListPager. type JobsClientListResponse struct { JobCollection } @@ -217,7 +217,7 @@ type JobsClientUpdateResponse struct { Job } -// LiveEventsClientAllocateResponse contains the response from method LiveEventsClient.Allocate. +// LiveEventsClientAllocateResponse contains the response from method LiveEventsClient.BeginAllocate. type LiveEventsClientAllocateResponse struct { // placeholder for future response values } @@ -227,12 +227,12 @@ type LiveEventsClientAsyncOperationResponse struct { AsyncOperationResult } -// LiveEventsClientCreateResponse contains the response from method LiveEventsClient.Create. +// LiveEventsClientCreateResponse contains the response from method LiveEventsClient.BeginCreate. type LiveEventsClientCreateResponse struct { LiveEvent } -// LiveEventsClientDeleteResponse contains the response from method LiveEventsClient.Delete. +// LiveEventsClientDeleteResponse contains the response from method LiveEventsClient.BeginDelete. type LiveEventsClientDeleteResponse struct { // placeholder for future response values } @@ -242,7 +242,7 @@ type LiveEventsClientGetResponse struct { LiveEvent } -// LiveEventsClientListResponse contains the response from method LiveEventsClient.List. +// LiveEventsClientListResponse contains the response from method LiveEventsClient.NewListPager. type LiveEventsClientListResponse struct { LiveEventListResult } @@ -252,22 +252,22 @@ type LiveEventsClientOperationLocationResponse struct { LiveEvent } -// LiveEventsClientResetResponse contains the response from method LiveEventsClient.Reset. +// LiveEventsClientResetResponse contains the response from method LiveEventsClient.BeginReset. type LiveEventsClientResetResponse struct { // placeholder for future response values } -// LiveEventsClientStartResponse contains the response from method LiveEventsClient.Start. +// LiveEventsClientStartResponse contains the response from method LiveEventsClient.BeginStart. type LiveEventsClientStartResponse struct { // placeholder for future response values } -// LiveEventsClientStopResponse contains the response from method LiveEventsClient.Stop. +// LiveEventsClientStopResponse contains the response from method LiveEventsClient.BeginStop. type LiveEventsClientStopResponse struct { // placeholder for future response values } -// LiveEventsClientUpdateResponse contains the response from method LiveEventsClient.Update. +// LiveEventsClientUpdateResponse contains the response from method LiveEventsClient.BeginUpdate. type LiveEventsClientUpdateResponse struct { LiveEvent } @@ -277,12 +277,12 @@ type LiveOutputsClientAsyncOperationResponse struct { AsyncOperationResult } -// LiveOutputsClientCreateResponse contains the response from method LiveOutputsClient.Create. +// LiveOutputsClientCreateResponse contains the response from method LiveOutputsClient.BeginCreate. type LiveOutputsClientCreateResponse struct { LiveOutput } -// LiveOutputsClientDeleteResponse contains the response from method LiveOutputsClient.Delete. +// LiveOutputsClientDeleteResponse contains the response from method LiveOutputsClient.BeginDelete. type LiveOutputsClientDeleteResponse struct { // placeholder for future response values } @@ -292,7 +292,7 @@ type LiveOutputsClientGetResponse struct { LiveOutput } -// LiveOutputsClientListResponse contains the response from method LiveOutputsClient.List. +// LiveOutputsClientListResponse contains the response from method LiveOutputsClient.NewListPager. type LiveOutputsClientListResponse struct { LiveOutputListResult } @@ -365,12 +365,12 @@ type StreamingEndpointsClientAsyncOperationResponse struct { AsyncOperationResult } -// StreamingEndpointsClientCreateResponse contains the response from method StreamingEndpointsClient.Create. +// StreamingEndpointsClientCreateResponse contains the response from method StreamingEndpointsClient.BeginCreate. type StreamingEndpointsClientCreateResponse struct { StreamingEndpoint } -// StreamingEndpointsClientDeleteResponse contains the response from method StreamingEndpointsClient.Delete. +// StreamingEndpointsClientDeleteResponse contains the response from method StreamingEndpointsClient.BeginDelete. type StreamingEndpointsClientDeleteResponse struct { // placeholder for future response values } @@ -380,7 +380,7 @@ type StreamingEndpointsClientGetResponse struct { StreamingEndpoint } -// StreamingEndpointsClientListResponse contains the response from method StreamingEndpointsClient.List. +// StreamingEndpointsClientListResponse contains the response from method StreamingEndpointsClient.NewListPager. type StreamingEndpointsClientListResponse struct { StreamingEndpointListResult } @@ -395,22 +395,22 @@ type StreamingEndpointsClientSKUsResponse struct { StreamingEndpointSKUInfoListResult } -// StreamingEndpointsClientScaleResponse contains the response from method StreamingEndpointsClient.Scale. +// StreamingEndpointsClientScaleResponse contains the response from method StreamingEndpointsClient.BeginScale. type StreamingEndpointsClientScaleResponse struct { // placeholder for future response values } -// StreamingEndpointsClientStartResponse contains the response from method StreamingEndpointsClient.Start. +// StreamingEndpointsClientStartResponse contains the response from method StreamingEndpointsClient.BeginStart. type StreamingEndpointsClientStartResponse struct { // placeholder for future response values } -// StreamingEndpointsClientStopResponse contains the response from method StreamingEndpointsClient.Stop. +// StreamingEndpointsClientStopResponse contains the response from method StreamingEndpointsClient.BeginStop. type StreamingEndpointsClientStopResponse struct { // placeholder for future response values } -// StreamingEndpointsClientUpdateResponse contains the response from method StreamingEndpointsClient.Update. +// StreamingEndpointsClientUpdateResponse contains the response from method StreamingEndpointsClient.BeginUpdate. type StreamingEndpointsClientUpdateResponse struct { StreamingEndpoint } @@ -440,7 +440,7 @@ type StreamingLocatorsClientListPathsResponse struct { ListPathsResponse } -// StreamingLocatorsClientListResponse contains the response from method StreamingLocatorsClient.List. +// StreamingLocatorsClientListResponse contains the response from method StreamingLocatorsClient.NewListPager. type StreamingLocatorsClientListResponse struct { StreamingLocatorCollection } @@ -460,17 +460,17 @@ type StreamingPoliciesClientGetResponse struct { StreamingPolicy } -// StreamingPoliciesClientListResponse contains the response from method StreamingPoliciesClient.List. +// StreamingPoliciesClientListResponse contains the response from method StreamingPoliciesClient.NewListPager. type StreamingPoliciesClientListResponse struct { StreamingPolicyCollection } -// TracksClientCreateOrUpdateResponse contains the response from method TracksClient.CreateOrUpdate. +// TracksClientCreateOrUpdateResponse contains the response from method TracksClient.BeginCreateOrUpdate. type TracksClientCreateOrUpdateResponse struct { AssetTrack } -// TracksClientDeleteResponse contains the response from method TracksClient.Delete. +// TracksClientDeleteResponse contains the response from method TracksClient.BeginDelete. type TracksClientDeleteResponse struct { // placeholder for future response values } @@ -480,17 +480,17 @@ type TracksClientGetResponse struct { AssetTrack } -// TracksClientListResponse contains the response from method TracksClient.List. +// TracksClientListResponse contains the response from method TracksClient.NewListPager. type TracksClientListResponse struct { AssetTrackCollection } -// TracksClientUpdateResponse contains the response from method TracksClient.Update. +// TracksClientUpdateResponse contains the response from method TracksClient.BeginUpdate. type TracksClientUpdateResponse struct { AssetTrack } -// TracksClientUpdateTrackDataResponse contains the response from method TracksClient.UpdateTrackData. +// TracksClientUpdateTrackDataResponse contains the response from method TracksClient.BeginUpdateTrackData. type TracksClientUpdateTrackDataResponse struct { // placeholder for future response values } @@ -510,7 +510,7 @@ type TransformsClientGetResponse struct { Transform } -// TransformsClientListResponse contains the response from method TransformsClient.List. +// TransformsClientListResponse contains the response from method TransformsClient.NewListPager. type TransformsClientListResponse struct { TransformCollection } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/streamingendpoints_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/streamingendpoints_client.go index 67be18e4854d..0ac47ba18d48 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/streamingendpoints_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/streamingendpoints_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,49 +25,41 @@ import ( // StreamingEndpointsClient contains the methods for the StreamingEndpoints group. // Don't use this type directly, use NewStreamingEndpointsClient() instead. type StreamingEndpointsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewStreamingEndpointsClient creates a new instance of StreamingEndpointsClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewStreamingEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*StreamingEndpointsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".StreamingEndpointsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &StreamingEndpointsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // AsyncOperation - Get a streaming endpoint operation status. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// operationID - The ID of an ongoing async operation. -// options - StreamingEndpointsClientAsyncOperationOptions contains the optional parameters for the StreamingEndpointsClient.AsyncOperation -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - operationID - The ID of an ongoing async operation. +// - options - StreamingEndpointsClientAsyncOperationOptions contains the optional parameters for the StreamingEndpointsClient.AsyncOperation +// method. func (client *StreamingEndpointsClient) AsyncOperation(ctx context.Context, resourceGroupName string, accountName string, operationID string, options *StreamingEndpointsClientAsyncOperationOptions) (StreamingEndpointsClientAsyncOperationResponse, error) { req, err := client.asyncOperationCreateRequest(ctx, resourceGroupName, accountName, operationID, options) if err != nil { return StreamingEndpointsClientAsyncOperationResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StreamingEndpointsClientAsyncOperationResponse{}, err } @@ -98,7 +88,7 @@ func (client *StreamingEndpointsClient) asyncOperationCreateRequest(ctx context. return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -120,34 +110,36 @@ func (client *StreamingEndpointsClient) asyncOperationHandleResponse(resp *http. // BeginCreate - Creates a streaming endpoint. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingEndpointName - The name of the streaming endpoint, maximum length is 24. -// parameters - Streaming endpoint properties needed for creation. -// options - StreamingEndpointsClientBeginCreateOptions contains the optional parameters for the StreamingEndpointsClient.BeginCreate -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingEndpointName - The name of the streaming endpoint, maximum length is 24. +// - parameters - Streaming endpoint properties needed for creation. +// - options - StreamingEndpointsClientBeginCreateOptions contains the optional parameters for the StreamingEndpointsClient.BeginCreate +// method. func (client *StreamingEndpointsClient) BeginCreate(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, parameters StreamingEndpoint, options *StreamingEndpointsClientBeginCreateOptions) (*runtime.Poller[StreamingEndpointsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, accountName, streamingEndpointName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[StreamingEndpointsClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[StreamingEndpointsClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[StreamingEndpointsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[StreamingEndpointsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Creates a streaming endpoint. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *StreamingEndpointsClient) create(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, parameters StreamingEndpoint, options *StreamingEndpointsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, streamingEndpointName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -176,7 +168,7 @@ func (client *StreamingEndpointsClient) createCreateRequest(ctx context.Context, return nil, errors.New("parameter streamingEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingEndpointName}", url.PathEscape(streamingEndpointName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -192,33 +184,35 @@ func (client *StreamingEndpointsClient) createCreateRequest(ctx context.Context, // BeginDelete - Deletes a streaming endpoint. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingEndpointName - The name of the streaming endpoint, maximum length is 24. -// options - StreamingEndpointsClientBeginDeleteOptions contains the optional parameters for the StreamingEndpointsClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingEndpointName - The name of the streaming endpoint, maximum length is 24. +// - options - StreamingEndpointsClientBeginDeleteOptions contains the optional parameters for the StreamingEndpointsClient.BeginDelete +// method. func (client *StreamingEndpointsClient) BeginDelete(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, options *StreamingEndpointsClientBeginDeleteOptions) (*runtime.Poller[StreamingEndpointsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, accountName, streamingEndpointName, options) if err != nil { return nil, err } - return runtime.NewPoller[StreamingEndpointsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[StreamingEndpointsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[StreamingEndpointsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[StreamingEndpointsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a streaming endpoint. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *StreamingEndpointsClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, options *StreamingEndpointsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, streamingEndpointName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -247,7 +241,7 @@ func (client *StreamingEndpointsClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter streamingEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingEndpointName}", url.PathEscape(streamingEndpointName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -260,17 +254,18 @@ func (client *StreamingEndpointsClient) deleteCreateRequest(ctx context.Context, // Get - Gets a streaming endpoint. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingEndpointName - The name of the streaming endpoint, maximum length is 24. -// options - StreamingEndpointsClientGetOptions contains the optional parameters for the StreamingEndpointsClient.Get method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingEndpointName - The name of the streaming endpoint, maximum length is 24. +// - options - StreamingEndpointsClientGetOptions contains the optional parameters for the StreamingEndpointsClient.Get method. func (client *StreamingEndpointsClient) Get(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, options *StreamingEndpointsClientGetOptions) (StreamingEndpointsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, streamingEndpointName, options) if err != nil { return StreamingEndpointsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StreamingEndpointsClientGetResponse{}, err } @@ -299,7 +294,7 @@ func (client *StreamingEndpointsClient) getCreateRequest(ctx context.Context, re return nil, errors.New("parameter streamingEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingEndpointName}", url.PathEscape(streamingEndpointName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -320,10 +315,12 @@ func (client *StreamingEndpointsClient) getHandleResponse(resp *http.Response) ( } // NewListPager - Lists the streaming endpoints in the account. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// options - StreamingEndpointsClientListOptions contains the optional parameters for the StreamingEndpointsClient.List method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - options - StreamingEndpointsClientListOptions contains the optional parameters for the StreamingEndpointsClient.NewListPager +// method. func (client *StreamingEndpointsClient) NewListPager(resourceGroupName string, accountName string, options *StreamingEndpointsClientListOptions) *runtime.Pager[StreamingEndpointsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[StreamingEndpointsClientListResponse]{ More: func(page StreamingEndpointsClientListResponse) bool { @@ -340,7 +337,7 @@ func (client *StreamingEndpointsClient) NewListPager(resourceGroupName string, a if err != nil { return StreamingEndpointsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StreamingEndpointsClientListResponse{}, err } @@ -367,7 +364,7 @@ func (client *StreamingEndpointsClient) listCreateRequest(ctx context.Context, r return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -389,19 +386,20 @@ func (client *StreamingEndpointsClient) listHandleResponse(resp *http.Response) // OperationLocation - Get a streaming endpoint operation status. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingEndpointName - The name of the streaming endpoint, maximum length is 24. -// operationID - The ID of an ongoing async operation. -// options - StreamingEndpointsClientOperationLocationOptions contains the optional parameters for the StreamingEndpointsClient.OperationLocation -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingEndpointName - The name of the streaming endpoint, maximum length is 24. +// - operationID - The ID of an ongoing async operation. +// - options - StreamingEndpointsClientOperationLocationOptions contains the optional parameters for the StreamingEndpointsClient.OperationLocation +// method. func (client *StreamingEndpointsClient) OperationLocation(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, operationID string, options *StreamingEndpointsClientOperationLocationOptions) (StreamingEndpointsClientOperationLocationResponse, error) { req, err := client.operationLocationCreateRequest(ctx, resourceGroupName, accountName, streamingEndpointName, operationID, options) if err != nil { return StreamingEndpointsClientOperationLocationResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StreamingEndpointsClientOperationLocationResponse{}, err } @@ -434,7 +432,7 @@ func (client *StreamingEndpointsClient) operationLocationCreateRequest(ctx conte return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -456,17 +454,18 @@ func (client *StreamingEndpointsClient) operationLocationHandleResponse(resp *ht // SKUs - List streaming endpoint supported skus. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingEndpointName - The name of the streaming endpoint, maximum length is 24. -// options - StreamingEndpointsClientSKUsOptions contains the optional parameters for the StreamingEndpointsClient.SKUs method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingEndpointName - The name of the streaming endpoint, maximum length is 24. +// - options - StreamingEndpointsClientSKUsOptions contains the optional parameters for the StreamingEndpointsClient.SKUs method. func (client *StreamingEndpointsClient) SKUs(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, options *StreamingEndpointsClientSKUsOptions) (StreamingEndpointsClientSKUsResponse, error) { req, err := client.skUsCreateRequest(ctx, resourceGroupName, accountName, streamingEndpointName, options) if err != nil { return StreamingEndpointsClientSKUsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StreamingEndpointsClientSKUsResponse{}, err } @@ -495,7 +494,7 @@ func (client *StreamingEndpointsClient) skUsCreateRequest(ctx context.Context, r return nil, errors.New("parameter streamingEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingEndpointName}", url.PathEscape(streamingEndpointName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -517,34 +516,36 @@ func (client *StreamingEndpointsClient) skUsHandleResponse(resp *http.Response) // BeginScale - Scales an existing streaming endpoint. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingEndpointName - The name of the streaming endpoint, maximum length is 24. -// parameters - Streaming endpoint scale parameters -// options - StreamingEndpointsClientBeginScaleOptions contains the optional parameters for the StreamingEndpointsClient.BeginScale -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingEndpointName - The name of the streaming endpoint, maximum length is 24. +// - parameters - Streaming endpoint scale parameters +// - options - StreamingEndpointsClientBeginScaleOptions contains the optional parameters for the StreamingEndpointsClient.BeginScale +// method. func (client *StreamingEndpointsClient) BeginScale(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, parameters StreamingEntityScaleUnit, options *StreamingEndpointsClientBeginScaleOptions) (*runtime.Poller[StreamingEndpointsClientScaleResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.scale(ctx, resourceGroupName, accountName, streamingEndpointName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[StreamingEndpointsClientScaleResponse](resp, client.pl, nil) + return runtime.NewPoller[StreamingEndpointsClientScaleResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[StreamingEndpointsClientScaleResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[StreamingEndpointsClientScaleResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Scale - Scales an existing streaming endpoint. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *StreamingEndpointsClient) scale(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, parameters StreamingEntityScaleUnit, options *StreamingEndpointsClientBeginScaleOptions) (*http.Response, error) { req, err := client.scaleCreateRequest(ctx, resourceGroupName, accountName, streamingEndpointName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -573,7 +574,7 @@ func (client *StreamingEndpointsClient) scaleCreateRequest(ctx context.Context, return nil, errors.New("parameter streamingEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingEndpointName}", url.PathEscape(streamingEndpointName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -586,33 +587,35 @@ func (client *StreamingEndpointsClient) scaleCreateRequest(ctx context.Context, // BeginStart - Starts an existing streaming endpoint. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingEndpointName - The name of the streaming endpoint, maximum length is 24. -// options - StreamingEndpointsClientBeginStartOptions contains the optional parameters for the StreamingEndpointsClient.BeginStart -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingEndpointName - The name of the streaming endpoint, maximum length is 24. +// - options - StreamingEndpointsClientBeginStartOptions contains the optional parameters for the StreamingEndpointsClient.BeginStart +// method. func (client *StreamingEndpointsClient) BeginStart(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, options *StreamingEndpointsClientBeginStartOptions) (*runtime.Poller[StreamingEndpointsClientStartResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.start(ctx, resourceGroupName, accountName, streamingEndpointName, options) if err != nil { return nil, err } - return runtime.NewPoller[StreamingEndpointsClientStartResponse](resp, client.pl, nil) + return runtime.NewPoller[StreamingEndpointsClientStartResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[StreamingEndpointsClientStartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[StreamingEndpointsClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Start - Starts an existing streaming endpoint. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *StreamingEndpointsClient) start(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, options *StreamingEndpointsClientBeginStartOptions) (*http.Response, error) { req, err := client.startCreateRequest(ctx, resourceGroupName, accountName, streamingEndpointName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -641,7 +644,7 @@ func (client *StreamingEndpointsClient) startCreateRequest(ctx context.Context, return nil, errors.New("parameter streamingEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingEndpointName}", url.PathEscape(streamingEndpointName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -654,33 +657,35 @@ func (client *StreamingEndpointsClient) startCreateRequest(ctx context.Context, // BeginStop - Stops an existing streaming endpoint. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingEndpointName - The name of the streaming endpoint, maximum length is 24. -// options - StreamingEndpointsClientBeginStopOptions contains the optional parameters for the StreamingEndpointsClient.BeginStop -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingEndpointName - The name of the streaming endpoint, maximum length is 24. +// - options - StreamingEndpointsClientBeginStopOptions contains the optional parameters for the StreamingEndpointsClient.BeginStop +// method. func (client *StreamingEndpointsClient) BeginStop(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, options *StreamingEndpointsClientBeginStopOptions) (*runtime.Poller[StreamingEndpointsClientStopResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.stop(ctx, resourceGroupName, accountName, streamingEndpointName, options) if err != nil { return nil, err } - return runtime.NewPoller[StreamingEndpointsClientStopResponse](resp, client.pl, nil) + return runtime.NewPoller[StreamingEndpointsClientStopResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[StreamingEndpointsClientStopResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[StreamingEndpointsClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Stop - Stops an existing streaming endpoint. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *StreamingEndpointsClient) stop(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, options *StreamingEndpointsClientBeginStopOptions) (*http.Response, error) { req, err := client.stopCreateRequest(ctx, resourceGroupName, accountName, streamingEndpointName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -709,7 +714,7 @@ func (client *StreamingEndpointsClient) stopCreateRequest(ctx context.Context, r return nil, errors.New("parameter streamingEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingEndpointName}", url.PathEscape(streamingEndpointName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -722,34 +727,36 @@ func (client *StreamingEndpointsClient) stopCreateRequest(ctx context.Context, r // BeginUpdate - Updates a existing streaming endpoint. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingEndpointName - The name of the streaming endpoint, maximum length is 24. -// parameters - Streaming endpoint properties needed for creation. -// options - StreamingEndpointsClientBeginUpdateOptions contains the optional parameters for the StreamingEndpointsClient.BeginUpdate -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingEndpointName - The name of the streaming endpoint, maximum length is 24. +// - parameters - Streaming endpoint properties needed for creation. +// - options - StreamingEndpointsClientBeginUpdateOptions contains the optional parameters for the StreamingEndpointsClient.BeginUpdate +// method. func (client *StreamingEndpointsClient) BeginUpdate(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, parameters StreamingEndpoint, options *StreamingEndpointsClientBeginUpdateOptions) (*runtime.Poller[StreamingEndpointsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, accountName, streamingEndpointName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[StreamingEndpointsClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[StreamingEndpointsClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[StreamingEndpointsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[StreamingEndpointsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates a existing streaming endpoint. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *StreamingEndpointsClient) update(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, parameters StreamingEndpoint, options *StreamingEndpointsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, streamingEndpointName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -778,7 +785,7 @@ func (client *StreamingEndpointsClient) updateCreateRequest(ctx context.Context, return nil, errors.New("parameter streamingEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingEndpointName}", url.PathEscape(streamingEndpointName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/streamingendpoints_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/streamingendpoints_client_example_test.go index 176d84a6b0de..4d2546adb1c6 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/streamingendpoints_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/streamingendpoints_client_example_test.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 armmediaservices_test @@ -19,61 +20,139 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-list-all.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-list-all.json func ExampleStreamingEndpointsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingEndpointsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("mediaresources", "slitestmedia10", nil) + pager := clientFactory.NewStreamingEndpointsClient().NewListPager("mediaresources", "slitestmedia10", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.StreamingEndpointListResult = armmediaservices.StreamingEndpointListResult{ + // Value: []*armmediaservices.StreamingEndpoint{ + // { + // Name: to.Ptr("myStreamingEndpoint1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints"), + // ID: to.Ptr("/subscriptions/0a6ec948-5a62-437d-b9df-934dc7c1b722/resourceGroups/mediaresources/providers/Microsoft.Media/mediaservices/slitestmedia10/streamingendpoints/myStreamingEndpoint1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armmediaservices.StreamingEndpointProperties{ + // Description: to.Ptr("test event 1"), + // AvailabilitySetName: to.Ptr("availableset"), + // CdnEnabled: to.Ptr(false), + // CdnProfile: to.Ptr(""), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.202013Z"); return t}()), + // CustomHostNames: []*string{ + // }, + // FreeTrialEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T08:00:00Z"); return t}()), + // HostName: to.Ptr("mystreamingendpoint1-slitestmedia10.streaming.mediaservices.windows.net"), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.202013Z"); return t}()), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armmediaservices.StreamingEndpointResourceStateStopped), + // ScaleUnits: to.Ptr[int32](1), + // }, + // }, + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints"), + // ID: to.Ptr("/subscriptions/0a6ec948-5a62-437d-b9df-934dc7c1b722/resourceGroups/mediaresources/providers/Microsoft.Media/mediaservices/slitestmedia10/streamingendpoints/default"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Properties: &armmediaservices.StreamingEndpointProperties{ + // Description: to.Ptr(""), + // CdnEnabled: to.Ptr(true), + // CdnProfile: to.Ptr("AzureMediaStreamingPlatformCdnProfile-StandardVerizon"), + // CdnProvider: to.Ptr("StandardVerizon"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.2310128Z"); return t}()), + // CustomHostNames: []*string{ + // }, + // FreeTrialEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00-08:00"); return t}()), + // HostName: to.Ptr("slitestmedia10.streaming.mediaservices.windows.net"), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.2310128Z"); return t}()), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armmediaservices.StreamingEndpointResourceStateStarting), + // ScaleUnits: to.Ptr[int32](0), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-list-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-list-by-name.json func ExampleStreamingEndpointsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingEndpointsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", nil) + res, err := clientFactory.NewStreamingEndpointsClient().Get(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.StreamingEndpoint = armmediaservices.StreamingEndpoint{ + // Name: to.Ptr("myStreamingEndpoint1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints"), + // ID: to.Ptr("/subscriptions/0a6ec948-5a62-437d-b9df-934dc7c1b722/resourceGroups/mediaresources/providers/Microsoft.Media/mediaservices/slitestmedia10/streamingendpoints/myStreamingEndpoint1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armmediaservices.StreamingEndpointProperties{ + // Description: to.Ptr("test event 1"), + // AvailabilitySetName: to.Ptr("availableset"), + // CdnEnabled: to.Ptr(false), + // CdnProfile: to.Ptr(""), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.3500423Z"); return t}()), + // CustomHostNames: []*string{ + // }, + // FreeTrialEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T08:00:00Z"); return t}()), + // HostName: to.Ptr("mystreamingendpoint1-slitestmedia10.streaming.mediaservices.windows.net"), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.3500423Z"); return t}()), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armmediaservices.StreamingEndpointResourceStateStopped), + // ScaleUnits: to.Ptr[int32](1), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-create.json func ExampleStreamingEndpointsClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingEndpointsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", armmediaservices.StreamingEndpoint{ + poller, err := clientFactory.NewStreamingEndpointsClient().BeginCreate(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", armmediaservices.StreamingEndpoint{ Location: to.Ptr("West US"), Tags: map[string]*string{ "tag1": to.Ptr("value1"), @@ -115,22 +194,70 @@ func ExampleStreamingEndpointsClient_BeginCreate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.StreamingEndpoint = armmediaservices.StreamingEndpoint{ + // Name: to.Ptr("myStreamingEndpoint1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints"), + // ID: to.Ptr("/subscriptions/0a6ec948-5a62-437d-b9df-934dc7c1b722/resourceGroups/mediaresources/providers/Microsoft.Media/mediaservices/slitestmedia10/streamingendpoints/myStreamingEndpoint1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armmediaservices.StreamingEndpointProperties{ + // Description: to.Ptr("test event 1"), + // AccessControl: &armmediaservices.StreamingEndpointAccessControl{ + // Akamai: &armmediaservices.AkamaiAccessControl{ + // AkamaiSignatureHeaderAuthenticationKeyList: []*armmediaservices.AkamaiSignatureHeaderAuthenticationKey{ + // { + // Base64Key: to.Ptr("dGVzdGlkMQ=="), + // Expiration: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2030-01-01T00:00:00Z"); return t}()), + // Identifier: to.Ptr("id1"), + // }, + // { + // Base64Key: to.Ptr("dGVzdGlkMQ=="), + // Expiration: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2031-01-01T00:00:00Z"); return t}()), + // Identifier: to.Ptr("id2"), + // }}, + // }, + // IP: &armmediaservices.IPAccessControl{ + // Allow: []*armmediaservices.IPRange{ + // { + // Name: to.Ptr("AllowedIp"), + // Address: to.Ptr("192.168.1.1"), + // }}, + // }, + // }, + // AvailabilitySetName: to.Ptr("availableset"), + // CdnEnabled: to.Ptr(false), + // CdnProfile: to.Ptr(""), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.7561389Z"); return t}()), + // CustomHostNames: []*string{ + // }, + // FreeTrialEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00-08:00"); return t}()), + // HostName: to.Ptr("mystreamingendpoint1-slitestmedia10.streaming.mediaservices.windows.net"), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.7561389Z"); return t}()), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armmediaservices.StreamingEndpointResourceStateStopped), + // ScaleUnits: to.Ptr[int32](1), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-update.json func ExampleStreamingEndpointsClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingEndpointsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", armmediaservices.StreamingEndpoint{ + poller, err := clientFactory.NewStreamingEndpointsClient().BeginUpdate(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", armmediaservices.StreamingEndpoint{ Location: to.Ptr("West US"), Tags: map[string]*string{ "tag3": to.Ptr("value3"), @@ -149,22 +276,45 @@ func ExampleStreamingEndpointsClient_BeginUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.StreamingEndpoint = armmediaservices.StreamingEndpoint{ + // Name: to.Ptr("myStreamingEndpoint1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints"), + // ID: to.Ptr("/subscriptions/0a6ec948-5a62-437d-b9df-934dc7c1b722/resourceGroups/mediaresources/providers/Microsoft.Media/mediaservices/slitestmedia10/streamingendpoints/myStreamingEndpoint1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "tag3": to.Ptr("value3"), + // "tag5": to.Ptr("value5"), + // }, + // Properties: &armmediaservices.StreamingEndpointProperties{ + // Description: to.Ptr("test event 2"), + // AvailabilitySetName: to.Ptr("availableset"), + // CdnEnabled: to.Ptr(false), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00Z"); return t}()), + // CustomHostNames: []*string{ + // }, + // FreeTrialEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00Z"); return t}()), + // ProvisioningState: to.Ptr("Succeeded"), + // ScaleUnits: to.Ptr[int32](5), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-delete.json func ExampleStreamingEndpointsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingEndpointsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", nil) + poller, err := clientFactory.NewStreamingEndpointsClient().BeginDelete(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -174,37 +324,53 @@ func ExampleStreamingEndpointsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-list-skus.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-list-skus.json func ExampleStreamingEndpointsClient_SKUs() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingEndpointsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.SKUs(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", nil) + res, err := clientFactory.NewStreamingEndpointsClient().SKUs(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.StreamingEndpointSKUInfoListResult = armmediaservices.StreamingEndpointSKUInfoListResult{ + // Value: []*armmediaservices.ArmStreamingEndpointSKUInfo{ + // { + // Capacity: &armmediaservices.ArmStreamingEndpointCapacity{ + // Default: to.Ptr[int32](1), + // Maximum: to.Ptr[int32](10), + // Minimum: to.Ptr[int32](1), + // ScaleType: to.Ptr("Automatic"), + // }, + // ResourceType: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints"), + // SKU: &armmediaservices.ArmStreamingEndpointSKU{ + // Name: to.Ptr("Premium"), + // }, + // }}, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-start.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-start.json func ExampleStreamingEndpointsClient_BeginStart() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingEndpointsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginStart(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", nil) + poller, err := clientFactory.NewStreamingEndpointsClient().BeginStart(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -214,18 +380,18 @@ func ExampleStreamingEndpointsClient_BeginStart() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-stop.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-stop.json func ExampleStreamingEndpointsClient_BeginStop() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingEndpointsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginStop(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", nil) + poller, err := clientFactory.NewStreamingEndpointsClient().BeginStop(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -235,18 +401,18 @@ func ExampleStreamingEndpointsClient_BeginStop() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-scale.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-scale.json func ExampleStreamingEndpointsClient_BeginScale() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingEndpointsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginScale(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", armmediaservices.StreamingEntityScaleUnit{ + poller, err := clientFactory.NewStreamingEndpointsClient().BeginScale(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", armmediaservices.StreamingEntityScaleUnit{ ScaleUnit: to.Ptr[int32](5), }, nil) if err != nil { @@ -258,40 +424,87 @@ func ExampleStreamingEndpointsClient_BeginScale() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/async-operation-result.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/async-operation-result.json func ExampleStreamingEndpointsClient_AsyncOperation() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingEndpointsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.AsyncOperation(ctx, "mediaresources", "slitestmedia10", "62e4d893-d233-4005-988e-a428d9f77076", nil) + res, err := clientFactory.NewStreamingEndpointsClient().AsyncOperation(ctx, "mediaresources", "slitestmedia10", "62e4d893-d233-4005-988e-a428d9f77076", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AsyncOperationResult = armmediaservices.AsyncOperationResult{ + // Name: to.Ptr("62e4d893-d233-4005-988e-a428d9f77076"), + // Error: &armmediaservices.ErrorDetail{ + // Code: to.Ptr("None"), + // Target: to.Ptr("d7aea790-8acb-40b9-8f9f-21cc37c9e519"), + // }, + // Status: to.Ptr(armmediaservices.AsyncOperationStatusInProgress), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-operation-location.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-operation-location.json func ExampleStreamingEndpointsClient_OperationLocation() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingEndpointsClient("0a6ec948-5a62-437d-b9df-934dc7c1b722", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.OperationLocation(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", "62e4d893-d233-4005-988e-a428d9f77076", nil) + res, err := clientFactory.NewStreamingEndpointsClient().OperationLocation(ctx, "mediaresources", "slitestmedia10", "myStreamingEndpoint1", "62e4d893-d233-4005-988e-a428d9f77076", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.StreamingEndpoint = armmediaservices.StreamingEndpoint{ + // Name: to.Ptr("myStreamingEndpoint1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/streamingEndpoints"), + // ID: to.Ptr("/subscriptions/0a6ec948-5a62-437d-b9df-934dc7c1b722/resourceGroups/mediaresources/providers/Microsoft.Media/mediaservices/slitestmedia10/streamingendpoints/myStreamingEndpoint1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armmediaservices.StreamingEndpointProperties{ + // Description: to.Ptr("test event 1"), + // AvailabilitySetName: to.Ptr("availableset"), + // CdnEnabled: to.Ptr(false), + // CdnProfile: to.Ptr(""), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.3500423Z"); return t}()), + // CustomHostNames: []*string{ + // }, + // FreeTrialEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T08:00:00Z"); return t}()), + // HostName: to.Ptr("mystreamingendpoint1-slitestmedia10.streaming.mediaservices.windows.net"), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.3500423Z"); return t}()), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armmediaservices.StreamingEndpointResourceStateStopped), + // ScaleUnits: to.Ptr[int32](1), + // }, + // SKU: &armmediaservices.ArmStreamingEndpointCurrentSKU{ + // Name: to.Ptr("Premium"), + // Capacity: to.Ptr[int32](1), + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.3500423Z"); return t}()), + // CreatedBy: to.Ptr("example@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-03T02:25:09.3500423Z"); return t}()), + // LastModifiedBy: to.Ptr("example@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/streaminglocators_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/streaminglocators_client.go index 28451c258e26..ea0d78b4b20a 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/streaminglocators_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/streaminglocators_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,50 +25,42 @@ import ( // StreamingLocatorsClient contains the methods for the StreamingLocators group. // Don't use this type directly, use NewStreamingLocatorsClient() instead. type StreamingLocatorsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewStreamingLocatorsClient creates a new instance of StreamingLocatorsClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewStreamingLocatorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*StreamingLocatorsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".StreamingLocatorsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &StreamingLocatorsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Create a Streaming Locator in the Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingLocatorName - The Streaming Locator name. -// parameters - The request parameters -// options - StreamingLocatorsClientCreateOptions contains the optional parameters for the StreamingLocatorsClient.Create -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingLocatorName - The Streaming Locator name. +// - parameters - The request parameters +// - options - StreamingLocatorsClientCreateOptions contains the optional parameters for the StreamingLocatorsClient.Create +// method. func (client *StreamingLocatorsClient) Create(ctx context.Context, resourceGroupName string, accountName string, streamingLocatorName string, parameters StreamingLocator, options *StreamingLocatorsClientCreateOptions) (StreamingLocatorsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, streamingLocatorName, parameters, options) if err != nil { return StreamingLocatorsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StreamingLocatorsClientCreateResponse{}, err } @@ -99,7 +89,7 @@ func (client *StreamingLocatorsClient) createCreateRequest(ctx context.Context, return nil, errors.New("parameter streamingLocatorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingLocatorName}", url.PathEscape(streamingLocatorName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -121,18 +111,19 @@ func (client *StreamingLocatorsClient) createHandleResponse(resp *http.Response) // Delete - Deletes a Streaming Locator in the Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingLocatorName - The Streaming Locator name. -// options - StreamingLocatorsClientDeleteOptions contains the optional parameters for the StreamingLocatorsClient.Delete -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingLocatorName - The Streaming Locator name. +// - options - StreamingLocatorsClientDeleteOptions contains the optional parameters for the StreamingLocatorsClient.Delete +// method. func (client *StreamingLocatorsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, streamingLocatorName string, options *StreamingLocatorsClientDeleteOptions) (StreamingLocatorsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, streamingLocatorName, options) if err != nil { return StreamingLocatorsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StreamingLocatorsClientDeleteResponse{}, err } @@ -161,7 +152,7 @@ func (client *StreamingLocatorsClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter streamingLocatorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingLocatorName}", url.PathEscape(streamingLocatorName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -174,17 +165,18 @@ func (client *StreamingLocatorsClient) deleteCreateRequest(ctx context.Context, // Get - Get the details of a Streaming Locator in the Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingLocatorName - The Streaming Locator name. -// options - StreamingLocatorsClientGetOptions contains the optional parameters for the StreamingLocatorsClient.Get method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingLocatorName - The Streaming Locator name. +// - options - StreamingLocatorsClientGetOptions contains the optional parameters for the StreamingLocatorsClient.Get method. func (client *StreamingLocatorsClient) Get(ctx context.Context, resourceGroupName string, accountName string, streamingLocatorName string, options *StreamingLocatorsClientGetOptions) (StreamingLocatorsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, streamingLocatorName, options) if err != nil { return StreamingLocatorsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StreamingLocatorsClientGetResponse{}, err } @@ -213,7 +205,7 @@ func (client *StreamingLocatorsClient) getCreateRequest(ctx context.Context, res return nil, errors.New("parameter streamingLocatorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingLocatorName}", url.PathEscape(streamingLocatorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -234,10 +226,12 @@ func (client *StreamingLocatorsClient) getHandleResponse(resp *http.Response) (S } // NewListPager - Lists the Streaming Locators in the account +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// options - StreamingLocatorsClientListOptions contains the optional parameters for the StreamingLocatorsClient.List method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - options - StreamingLocatorsClientListOptions contains the optional parameters for the StreamingLocatorsClient.NewListPager +// method. func (client *StreamingLocatorsClient) NewListPager(resourceGroupName string, accountName string, options *StreamingLocatorsClientListOptions) *runtime.Pager[StreamingLocatorsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[StreamingLocatorsClientListResponse]{ More: func(page StreamingLocatorsClientListResponse) bool { @@ -254,7 +248,7 @@ func (client *StreamingLocatorsClient) NewListPager(resourceGroupName string, ac if err != nil { return StreamingLocatorsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StreamingLocatorsClientListResponse{}, err } @@ -281,7 +275,7 @@ func (client *StreamingLocatorsClient) listCreateRequest(ctx context.Context, re return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -312,18 +306,19 @@ func (client *StreamingLocatorsClient) listHandleResponse(resp *http.Response) ( // ListContentKeys - List Content Keys used by this Streaming Locator // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingLocatorName - The Streaming Locator name. -// options - StreamingLocatorsClientListContentKeysOptions contains the optional parameters for the StreamingLocatorsClient.ListContentKeys -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingLocatorName - The Streaming Locator name. +// - options - StreamingLocatorsClientListContentKeysOptions contains the optional parameters for the StreamingLocatorsClient.ListContentKeys +// method. func (client *StreamingLocatorsClient) ListContentKeys(ctx context.Context, resourceGroupName string, accountName string, streamingLocatorName string, options *StreamingLocatorsClientListContentKeysOptions) (StreamingLocatorsClientListContentKeysResponse, error) { req, err := client.listContentKeysCreateRequest(ctx, resourceGroupName, accountName, streamingLocatorName, options) if err != nil { return StreamingLocatorsClientListContentKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StreamingLocatorsClientListContentKeysResponse{}, err } @@ -352,7 +347,7 @@ func (client *StreamingLocatorsClient) listContentKeysCreateRequest(ctx context. return nil, errors.New("parameter streamingLocatorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingLocatorName}", url.PathEscape(streamingLocatorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -374,18 +369,19 @@ func (client *StreamingLocatorsClient) listContentKeysHandleResponse(resp *http. // ListPaths - List Paths supported by this Streaming Locator // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingLocatorName - The Streaming Locator name. -// options - StreamingLocatorsClientListPathsOptions contains the optional parameters for the StreamingLocatorsClient.ListPaths -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingLocatorName - The Streaming Locator name. +// - options - StreamingLocatorsClientListPathsOptions contains the optional parameters for the StreamingLocatorsClient.ListPaths +// method. func (client *StreamingLocatorsClient) ListPaths(ctx context.Context, resourceGroupName string, accountName string, streamingLocatorName string, options *StreamingLocatorsClientListPathsOptions) (StreamingLocatorsClientListPathsResponse, error) { req, err := client.listPathsCreateRequest(ctx, resourceGroupName, accountName, streamingLocatorName, options) if err != nil { return StreamingLocatorsClientListPathsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StreamingLocatorsClientListPathsResponse{}, err } @@ -414,7 +410,7 @@ func (client *StreamingLocatorsClient) listPathsCreateRequest(ctx context.Contex return nil, errors.New("parameter streamingLocatorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingLocatorName}", url.PathEscape(streamingLocatorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/streaminglocators_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/streaminglocators_client_example_test.go index bfb2a269368f..8a8173e82a5c 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/streaminglocators_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/streaminglocators_client_example_test.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 armmediaservices_test @@ -19,64 +20,111 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-list.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-list.json func ExampleStreamingLocatorsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingLocatorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contoso", "contosomedia", &armmediaservices.StreamingLocatorsClientListOptions{Filter: nil, + pager := clientFactory.NewStreamingLocatorsClient().NewListPager("contoso", "contosomedia", &armmediaservices.StreamingLocatorsClientListOptions{Filter: nil, Top: nil, Orderby: nil, }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.StreamingLocatorCollection = armmediaservices.StreamingLocatorCollection{ + // Value: []*armmediaservices.StreamingLocator{ + // { + // Name: to.Ptr("clearStreamingLocator"), + // Type: to.Ptr("Microsoft.Media/mediaservices/streamingLocators"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/streamingLocators/clearStreamingLocator"), + // Properties: &armmediaservices.StreamingLocatorProperties{ + // AssetName: to.Ptr("ClimbingMountRainier"), + // ContentKeys: []*armmediaservices.StreamingLocatorContentKey{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:31.9341192Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "9999-12-31T23:59:59.9999999Z"); return t}()), + // StreamingLocatorID: to.Ptr("6a116ec6-0c85-441f-9c31-89a5bc3adf0a"), + // StreamingPolicyName: to.Ptr("clearStreamingPolicy"), + // }, + // }, + // { + // Name: to.Ptr("secureStreamingLocator"), + // Type: to.Ptr("Microsoft.Media/mediaservices/streamingLocators"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/streamingLocators/secureStreamingLocator"), + // Properties: &armmediaservices.StreamingLocatorProperties{ + // AssetName: to.Ptr("ClimbingMountRainier"), + // ContentKeys: []*armmediaservices.StreamingLocatorContentKey{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:31.9544387Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "9999-12-31T23:59:59.9999999Z"); return t}()), + // StreamingLocatorID: to.Ptr("7338ef90-ffc8-42de-8bff-de8f99973300"), + // StreamingPolicyName: to.Ptr("secureStreamingPolicy"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-get-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-get-by-name.json func ExampleStreamingLocatorsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingLocatorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contoso", "contosomedia", "clearStreamingLocator", nil) + res, err := clientFactory.NewStreamingLocatorsClient().Get(ctx, "contoso", "contosomedia", "clearStreamingLocator", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.StreamingLocator = armmediaservices.StreamingLocator{ + // Name: to.Ptr("clearStreamingLocator"), + // Type: to.Ptr("Microsoft.Media/mediaservices/streamingLocators"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/streamingLocators/clearStreamingLocator"), + // Properties: &armmediaservices.StreamingLocatorProperties{ + // AssetName: to.Ptr("ClimbingMountRainier"), + // ContentKeys: []*armmediaservices.StreamingLocatorContentKey{ + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:32.1154071Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "9999-12-31T23:59:59.9999999Z"); return t}()), + // StreamingLocatorID: to.Ptr("7684043b-f6d1-44a7-8bed-8a4aa474c5a4"), + // StreamingPolicyName: to.Ptr("clearStreamingPolicy"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-create-clear.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-create-clear.json func ExampleStreamingLocatorsClient_Create_createsAStreamingLocatorWithClearStreaming() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingLocatorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Create(ctx, "contoso", "contosomedia", "UserCreatedClearStreamingLocator", armmediaservices.StreamingLocator{ + _, err = clientFactory.NewStreamingLocatorsClient().Create(ctx, "contoso", "contosomedia", "UserCreatedClearStreamingLocator", armmediaservices.StreamingLocator{ Properties: &armmediaservices.StreamingLocatorProperties{ AssetName: to.Ptr("ClimbingMountRainier"), StreamingPolicyName: to.Ptr("clearStreamingPolicy"), @@ -87,18 +135,18 @@ func ExampleStreamingLocatorsClient_Create_createsAStreamingLocatorWithClearStre } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-create-secure.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-create-secure.json func ExampleStreamingLocatorsClient_Create_createsAStreamingLocatorWithSecureStreaming() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingLocatorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingLocator", armmediaservices.StreamingLocator{ + _, err = clientFactory.NewStreamingLocatorsClient().Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingLocator", armmediaservices.StreamingLocator{ Properties: &armmediaservices.StreamingLocatorProperties{ AssetName: to.Ptr("ClimbingMountRainier"), EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2028-12-31T23:59:59.9999999Z"); return t }()), @@ -111,18 +159,18 @@ func ExampleStreamingLocatorsClient_Create_createsAStreamingLocatorWithSecureStr } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-create-secure-userDefinedContentKeys.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-create-secure-userDefinedContentKeys.json func ExampleStreamingLocatorsClient_Create_createsAStreamingLocatorWithUserDefinedContentKeys() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingLocatorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingLocatorWithUserDefinedContentKeys", armmediaservices.StreamingLocator{ + _, err = clientFactory.NewStreamingLocatorsClient().Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingLocatorWithUserDefinedContentKeys", armmediaservices.StreamingLocator{ Properties: &armmediaservices.StreamingLocatorProperties{ AssetName: to.Ptr("ClimbingMountRainier"), ContentKeys: []*armmediaservices.StreamingLocatorContentKey{ @@ -150,76 +198,194 @@ func ExampleStreamingLocatorsClient_Create_createsAStreamingLocatorWithUserDefin } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-delete.json func ExampleStreamingLocatorsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingLocatorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "contoso", "contosomedia", "clearStreamingLocator", nil) + _, err = clientFactory.NewStreamingLocatorsClient().Delete(ctx, "contoso", "contosomedia", "clearStreamingLocator", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-list-content-keys.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-list-content-keys.json func ExampleStreamingLocatorsClient_ListContentKeys() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingLocatorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListContentKeys(ctx, "contoso", "contosomedia", "secureStreamingLocator", nil) + res, err := clientFactory.NewStreamingLocatorsClient().ListContentKeys(ctx, "contoso", "contosomedia", "secureStreamingLocator", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ListContentKeysResponse = armmediaservices.ListContentKeysResponse{ + // ContentKeys: []*armmediaservices.StreamingLocatorContentKey{ + // { + // Type: to.Ptr(armmediaservices.StreamingLocatorContentKeyTypeEnvelopeEncryption), + // ID: to.Ptr("9259eb06-eeee-4f77-987f-48f4ea5c649f"), + // LabelReferenceInStreamingPolicy: to.Ptr("aesDefaultKey"), + // PolicyName: to.Ptr("PolicyWithMultipleOptions"), + // Tracks: []*armmediaservices.TrackSelection{ + // }, + // Value: to.Ptr("QpiqeQROdN5xamnfUF2Wdw=="), + // }, + // { + // Type: to.Ptr(armmediaservices.StreamingLocatorContentKeyTypeCommonEncryptionCenc), + // ID: to.Ptr("06bfeff1-2bb6-4f58-af27-a2767f058bca"), + // LabelReferenceInStreamingPolicy: to.Ptr("cencDefaultKey"), + // PolicyName: to.Ptr("PolicyWithMultipleOptions"), + // Tracks: []*armmediaservices.TrackSelection{ + // }, + // Value: to.Ptr("ZjgWhNnqnqcov/h+wrYusw=="), + // }, + // { + // Type: to.Ptr(armmediaservices.StreamingLocatorContentKeyTypeCommonEncryptionCbcs), + // ID: to.Ptr("799e78a0-ed6f-4179-9222-ed4ec4223cec"), + // LabelReferenceInStreamingPolicy: to.Ptr("cbcsDefaultKey"), + // PolicyName: to.Ptr("PolicyWithMultipleOptions"), + // Tracks: []*armmediaservices.TrackSelection{ + // }, + // Value: to.Ptr("FjZ3n3yRcVxRFftdYFbe9g=="), + // }}, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-list-paths-streaming-and-download.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-list-paths-streaming-and-download.json func ExampleStreamingLocatorsClient_ListPaths_listPathsWhichHasStreamingPathsAndDownloadPaths() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingLocatorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListPaths(ctx, "contoso", "contosomedia", "clearStreamingLocator", nil) + res, err := clientFactory.NewStreamingLocatorsClient().ListPaths(ctx, "contoso", "contosomedia", "clearStreamingLocator", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ListPathsResponse = armmediaservices.ListPathsResponse{ + // DownloadPaths: []*string{ + // to.Ptr("/262a87b6-b538-4657-bac1-b6897924471d/textTrack.vtt"), + // to.Ptr("/262a87b6-b538-4657-bac1-b6897924471d/video1.mp4"), + // to.Ptr("/262a87b6-b538-4657-bac1-b6897924471d/video2.mp4"), + // to.Ptr("/262a87b6-b538-4657-bac1-b6897924471d/video3.mp4")}, + // StreamingPaths: []*armmediaservices.StreamingPath{ + // { + // EncryptionScheme: to.Ptr(armmediaservices.EncryptionSchemeNoEncryption), + // Paths: []*string{ + // to.Ptr("/262a87b6-b538-4657-bac1-b6897924471d/videoManifest1.ism/manifest(format=m3u8-aapl)"), + // to.Ptr("/262a87b6-b538-4657-bac1-b6897924471d/videoManifest2.ism/manifest(format=m3u8-aapl)"), + // to.Ptr("/262a87b6-b538-4657-bac1-b6897924471d/videoManifest3.ism/manifest(format=m3u8-aapl)")}, + // StreamingProtocol: to.Ptr(armmediaservices.StreamingPolicyStreamingProtocolHls), + // }, + // { + // EncryptionScheme: to.Ptr(armmediaservices.EncryptionSchemeNoEncryption), + // Paths: []*string{ + // to.Ptr("/262a87b6-b538-4657-bac1-b6897924471d/videoManifest1.ism/manifest(format=mpd-time-csf)"), + // to.Ptr("/262a87b6-b538-4657-bac1-b6897924471d/videoManifest2.ism/manifest(format=mpd-time-csf)"), + // to.Ptr("/262a87b6-b538-4657-bac1-b6897924471d/videoManifest3.ism/manifest(format=mpd-time-csf)")}, + // StreamingProtocol: to.Ptr(armmediaservices.StreamingPolicyStreamingProtocolDash), + // }, + // { + // EncryptionScheme: to.Ptr(armmediaservices.EncryptionSchemeNoEncryption), + // Paths: []*string{ + // to.Ptr("/262a87b6-b538-4657-bac1-b6897924471d/videoManifest1.ism/manifest"), + // to.Ptr("/262a87b6-b538-4657-bac1-b6897924471d/videoManifest2.ism/manifest"), + // to.Ptr("/262a87b6-b538-4657-bac1-b6897924471d/videoManifest3.ism/manifest")}, + // StreamingProtocol: to.Ptr(armmediaservices.StreamingPolicyStreamingProtocolSmoothStreaming), + // }}, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-list-paths-streaming-only.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-locators-list-paths-streaming-only.json func ExampleStreamingLocatorsClient_ListPaths_listPathsWhichHasStreamingPathsOnly() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingLocatorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListPaths(ctx, "contoso", "contosomedia", "secureStreamingLocator", nil) + res, err := clientFactory.NewStreamingLocatorsClient().ListPaths(ctx, "contoso", "contosomedia", "secureStreamingLocator", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ListPathsResponse = armmediaservices.ListPathsResponse{ + // DownloadPaths: []*string{ + // }, + // StreamingPaths: []*armmediaservices.StreamingPath{ + // { + // EncryptionScheme: to.Ptr(armmediaservices.EncryptionSchemeEnvelopeEncryption), + // Paths: []*string{ + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest1.ism/manifest(format=m3u8-aapl,encryption=cbc)"), + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest2.ism/manifest(format=m3u8-aapl,encryption=cbc)"), + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest3.ism/manifest(format=m3u8-aapl,encryption=cbc)")}, + // StreamingProtocol: to.Ptr(armmediaservices.StreamingPolicyStreamingProtocolHls), + // }, + // { + // EncryptionScheme: to.Ptr(armmediaservices.EncryptionSchemeEnvelopeEncryption), + // Paths: []*string{ + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest1.ism/manifest(format=mpd-time-csf,encryption=cbc)"), + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest2.ism/manifest(format=mpd-time-csf,encryption=cbc)"), + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest3.ism/manifest(format=mpd-time-csf,encryption=cbc)")}, + // StreamingProtocol: to.Ptr(armmediaservices.StreamingPolicyStreamingProtocolDash), + // }, + // { + // EncryptionScheme: to.Ptr(armmediaservices.EncryptionSchemeEnvelopeEncryption), + // Paths: []*string{ + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest1.ism/manifest(encryption=cbc)"), + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest2.ism/manifest(encryption=cbc)"), + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest3.ism/manifest(encryption=cbc)")}, + // StreamingProtocol: to.Ptr(armmediaservices.StreamingPolicyStreamingProtocolSmoothStreaming), + // }, + // { + // EncryptionScheme: to.Ptr(armmediaservices.EncryptionSchemeCommonEncryptionCenc), + // Paths: []*string{ + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest1.ism/manifest(format=mpd-time-csf,encryption=cenc)"), + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest2.ism/manifest(format=mpd-time-csf,encryption=cenc)"), + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest3.ism/manifest(format=mpd-time-csf,encryption=cenc)")}, + // StreamingProtocol: to.Ptr(armmediaservices.StreamingPolicyStreamingProtocolDash), + // }, + // { + // EncryptionScheme: to.Ptr(armmediaservices.EncryptionSchemeCommonEncryptionCenc), + // Paths: []*string{ + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest1.ism/manifest(encryption=cenc)"), + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest2.ism/manifest(encryption=cenc)"), + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest3.ism/manifest(encryption=cenc)")}, + // StreamingProtocol: to.Ptr(armmediaservices.StreamingPolicyStreamingProtocolSmoothStreaming), + // }, + // { + // EncryptionScheme: to.Ptr(armmediaservices.EncryptionSchemeCommonEncryptionCbcs), + // Paths: []*string{ + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest1.ism/manifest(format=m3u8-aapl,encryption=cbcs-aapl)"), + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest2.ism/manifest(format=m3u8-aapl,encryption=cbcs-aapl)"), + // to.Ptr("/c3cd62e3-d117-4619-bcbd-99f96edd8dbe/videoManifest3.ism/manifest(format=m3u8-aapl,encryption=cbcs-aapl)")}, + // StreamingProtocol: to.Ptr(armmediaservices.StreamingPolicyStreamingProtocolHls), + // }}, + // } } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/streamingpolicies_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/streamingpolicies_client.go index 7ce608bd6d54..c42df93b3d62 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/streamingpolicies_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/streamingpolicies_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,50 +25,42 @@ import ( // StreamingPoliciesClient contains the methods for the StreamingPolicies group. // Don't use this type directly, use NewStreamingPoliciesClient() instead. type StreamingPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewStreamingPoliciesClient creates a new instance of StreamingPoliciesClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewStreamingPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*StreamingPoliciesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".StreamingPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &StreamingPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Create a Streaming Policy in the Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingPolicyName - The Streaming Policy name. -// parameters - The request parameters -// options - StreamingPoliciesClientCreateOptions contains the optional parameters for the StreamingPoliciesClient.Create -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingPolicyName - The Streaming Policy name. +// - parameters - The request parameters +// - options - StreamingPoliciesClientCreateOptions contains the optional parameters for the StreamingPoliciesClient.Create +// method. func (client *StreamingPoliciesClient) Create(ctx context.Context, resourceGroupName string, accountName string, streamingPolicyName string, parameters StreamingPolicy, options *StreamingPoliciesClientCreateOptions) (StreamingPoliciesClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, streamingPolicyName, parameters, options) if err != nil { return StreamingPoliciesClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StreamingPoliciesClientCreateResponse{}, err } @@ -99,7 +89,7 @@ func (client *StreamingPoliciesClient) createCreateRequest(ctx context.Context, return nil, errors.New("parameter streamingPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingPolicyName}", url.PathEscape(streamingPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -121,18 +111,19 @@ func (client *StreamingPoliciesClient) createHandleResponse(resp *http.Response) // Delete - Deletes a Streaming Policy in the Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingPolicyName - The Streaming Policy name. -// options - StreamingPoliciesClientDeleteOptions contains the optional parameters for the StreamingPoliciesClient.Delete -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingPolicyName - The Streaming Policy name. +// - options - StreamingPoliciesClientDeleteOptions contains the optional parameters for the StreamingPoliciesClient.Delete +// method. func (client *StreamingPoliciesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, streamingPolicyName string, options *StreamingPoliciesClientDeleteOptions) (StreamingPoliciesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, streamingPolicyName, options) if err != nil { return StreamingPoliciesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StreamingPoliciesClientDeleteResponse{}, err } @@ -161,7 +152,7 @@ func (client *StreamingPoliciesClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter streamingPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingPolicyName}", url.PathEscape(streamingPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -174,17 +165,18 @@ func (client *StreamingPoliciesClient) deleteCreateRequest(ctx context.Context, // Get - Get the details of a Streaming Policy in the Media Services account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// streamingPolicyName - The Streaming Policy name. -// options - StreamingPoliciesClientGetOptions contains the optional parameters for the StreamingPoliciesClient.Get method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - streamingPolicyName - The Streaming Policy name. +// - options - StreamingPoliciesClientGetOptions contains the optional parameters for the StreamingPoliciesClient.Get method. func (client *StreamingPoliciesClient) Get(ctx context.Context, resourceGroupName string, accountName string, streamingPolicyName string, options *StreamingPoliciesClientGetOptions) (StreamingPoliciesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, streamingPolicyName, options) if err != nil { return StreamingPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StreamingPoliciesClientGetResponse{}, err } @@ -213,7 +205,7 @@ func (client *StreamingPoliciesClient) getCreateRequest(ctx context.Context, res return nil, errors.New("parameter streamingPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{streamingPolicyName}", url.PathEscape(streamingPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -234,10 +226,12 @@ func (client *StreamingPoliciesClient) getHandleResponse(resp *http.Response) (S } // NewListPager - Lists the Streaming Policies in the account +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// options - StreamingPoliciesClientListOptions contains the optional parameters for the StreamingPoliciesClient.List method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - options - StreamingPoliciesClientListOptions contains the optional parameters for the StreamingPoliciesClient.NewListPager +// method. func (client *StreamingPoliciesClient) NewListPager(resourceGroupName string, accountName string, options *StreamingPoliciesClientListOptions) *runtime.Pager[StreamingPoliciesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[StreamingPoliciesClientListResponse]{ More: func(page StreamingPoliciesClientListResponse) bool { @@ -254,7 +248,7 @@ func (client *StreamingPoliciesClient) NewListPager(resourceGroupName string, ac if err != nil { return StreamingPoliciesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StreamingPoliciesClientListResponse{}, err } @@ -281,7 +275,7 @@ func (client *StreamingPoliciesClient) listCreateRequest(ctx context.Context, re return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/streamingpolicies_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/streamingpolicies_client_example_test.go index d389777e5969..b1d05b892469 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/streamingpolicies_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/streamingpolicies_client_example_test.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 armmediaservices_test @@ -17,64 +18,286 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-list.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-list.json func ExampleStreamingPoliciesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contoso", "contosomedia", &armmediaservices.StreamingPoliciesClientListOptions{Filter: nil, + pager := clientFactory.NewStreamingPoliciesClient().NewListPager("contoso", "contosomedia", &armmediaservices.StreamingPoliciesClientListOptions{Filter: nil, Top: nil, Orderby: nil, }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.StreamingPolicyCollection = armmediaservices.StreamingPolicyCollection{ + // ODataNextLink: to.Ptr("http://server/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaServices/contosomedia/streamingPolicies?api-version=2022-08-01&$skiptoken=secureStreamingPolicyWithEnvelopeEncryptionOnly"), + // Value: []*armmediaservices.StreamingPolicy{ + // { + // Name: to.Ptr("clearStreamingPolicy"), + // Type: to.Ptr("Microsoft.Media/mediaservices/streamingPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/streamingPolicies/clearStreamingPolicy"), + // Properties: &armmediaservices.StreamingPolicyProperties{ + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:30.676067Z"); return t}()), + // NoEncryption: &armmediaservices.NoEncryption{ + // EnabledProtocols: &armmediaservices.EnabledProtocols{ + // Dash: to.Ptr(true), + // Download: to.Ptr(true), + // Hls: to.Ptr(true), + // SmoothStreaming: to.Ptr(true), + // }, + // }, + // }, + // }, + // { + // Name: to.Ptr("secureStreamingPolicy"), + // Type: to.Ptr("Microsoft.Media/mediaservices/streamingPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/streamingPolicies/secureStreamingPolicy"), + // Properties: &armmediaservices.StreamingPolicyProperties{ + // CommonEncryptionCbcs: &armmediaservices.CommonEncryptionCbcs{ + // ClearTracks: []*armmediaservices.TrackSelection{ + // }, + // ContentKeys: &armmediaservices.StreamingPolicyContentKeys{ + // DefaultKey: &armmediaservices.DefaultKey{ + // Label: to.Ptr("cbcsDefaultKey"), + // }, + // KeyToTrackMappings: []*armmediaservices.StreamingPolicyContentKey{ + // }, + // }, + // Drm: &armmediaservices.CbcsDrmConfiguration{ + // FairPlay: &armmediaservices.StreamingPolicyFairPlayConfiguration{ + // AllowPersistentLicense: to.Ptr(true), + // CustomLicenseAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}"), + // }, + // }, + // EnabledProtocols: &armmediaservices.EnabledProtocols{ + // Dash: to.Ptr(false), + // Download: to.Ptr(false), + // Hls: to.Ptr(true), + // SmoothStreaming: to.Ptr(false), + // }, + // }, + // CommonEncryptionCenc: &armmediaservices.CommonEncryptionCenc{ + // ClearTracks: []*armmediaservices.TrackSelection{ + // { + // TrackSelections: []*armmediaservices.TrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.TrackPropertyCompareOperationUnknown), + // Property: to.Ptr(armmediaservices.TrackPropertyTypeFourCC), + // Value: to.Ptr("hev1"), + // }}, + // }}, + // ContentKeys: &armmediaservices.StreamingPolicyContentKeys{ + // DefaultKey: &armmediaservices.DefaultKey{ + // Label: to.Ptr("cencDefaultKey"), + // }, + // KeyToTrackMappings: []*armmediaservices.StreamingPolicyContentKey{ + // }, + // }, + // Drm: &armmediaservices.CencDrmConfiguration{ + // PlayReady: &armmediaservices.StreamingPolicyPlayReadyConfiguration{ + // CustomLicenseAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}"), + // PlayReadyCustomAttributes: to.Ptr("PlayReady CustomAttributes"), + // }, + // Widevine: &armmediaservices.StreamingPolicyWidevineConfiguration{ + // CustomLicenseAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId"), + // }, + // }, + // EnabledProtocols: &armmediaservices.EnabledProtocols{ + // Dash: to.Ptr(true), + // Download: to.Ptr(false), + // Hls: to.Ptr(false), + // SmoothStreaming: to.Ptr(true), + // }, + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:30.6781134Z"); return t}()), + // DefaultContentKeyPolicyName: to.Ptr("PolicyWithMultipleOptions"), + // EnvelopeEncryption: &armmediaservices.EnvelopeEncryption{ + // ClearTracks: []*armmediaservices.TrackSelection{ + // }, + // ContentKeys: &armmediaservices.StreamingPolicyContentKeys{ + // DefaultKey: &armmediaservices.DefaultKey{ + // Label: to.Ptr("aesDefaultKey"), + // }, + // KeyToTrackMappings: []*armmediaservices.StreamingPolicyContentKey{ + // }, + // }, + // CustomKeyAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}"), + // EnabledProtocols: &armmediaservices.EnabledProtocols{ + // Dash: to.Ptr(true), + // Download: to.Ptr(false), + // Hls: to.Ptr(true), + // SmoothStreaming: to.Ptr(true), + // }, + // }, + // }, + // }, + // { + // Name: to.Ptr("secureStreamingPolicyWithCommonEncryptionCbcsOnly"), + // Type: to.Ptr("Microsoft.Media/mediaservices/streamingPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/streamingPolicies/secureStreamingPolicyWithCommonEncryptionCbcsOnly"), + // Properties: &armmediaservices.StreamingPolicyProperties{ + // CommonEncryptionCbcs: &armmediaservices.CommonEncryptionCbcs{ + // ClearTracks: []*armmediaservices.TrackSelection{ + // }, + // ContentKeys: &armmediaservices.StreamingPolicyContentKeys{ + // DefaultKey: &armmediaservices.DefaultKey{ + // Label: to.Ptr("cbcsDefaultKey"), + // }, + // KeyToTrackMappings: []*armmediaservices.StreamingPolicyContentKey{ + // }, + // }, + // Drm: &armmediaservices.CbcsDrmConfiguration{ + // FairPlay: &armmediaservices.StreamingPolicyFairPlayConfiguration{ + // AllowPersistentLicense: to.Ptr(true), + // CustomLicenseAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}"), + // }, + // }, + // EnabledProtocols: &armmediaservices.EnabledProtocols{ + // Dash: to.Ptr(false), + // Download: to.Ptr(false), + // Hls: to.Ptr(true), + // SmoothStreaming: to.Ptr(false), + // }, + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:30.6781134Z"); return t}()), + // DefaultContentKeyPolicyName: to.Ptr("PolicyWithMultipleOptions"), + // }, + // }, + // { + // Name: to.Ptr("secureStreamingPolicyWithCommonEncryptionCencOnly"), + // Type: to.Ptr("Microsoft.Media/mediaservices/streamingPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/streamingPolicies/secureStreamingPolicyWithCommonEncryptionCencOnly"), + // Properties: &armmediaservices.StreamingPolicyProperties{ + // CommonEncryptionCenc: &armmediaservices.CommonEncryptionCenc{ + // ClearTracks: []*armmediaservices.TrackSelection{ + // { + // TrackSelections: []*armmediaservices.TrackPropertyCondition{ + // { + // Operation: to.Ptr(armmediaservices.TrackPropertyCompareOperationUnknown), + // Property: to.Ptr(armmediaservices.TrackPropertyTypeFourCC), + // Value: to.Ptr("hev1"), + // }}, + // }}, + // ContentKeys: &armmediaservices.StreamingPolicyContentKeys{ + // DefaultKey: &armmediaservices.DefaultKey{ + // Label: to.Ptr("cencDefaultKey"), + // }, + // KeyToTrackMappings: []*armmediaservices.StreamingPolicyContentKey{ + // }, + // }, + // Drm: &armmediaservices.CencDrmConfiguration{ + // PlayReady: &armmediaservices.StreamingPolicyPlayReadyConfiguration{ + // CustomLicenseAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}"), + // PlayReadyCustomAttributes: to.Ptr("PlayReady CustomAttributes"), + // }, + // Widevine: &armmediaservices.StreamingPolicyWidevineConfiguration{ + // CustomLicenseAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId"), + // }, + // }, + // EnabledProtocols: &armmediaservices.EnabledProtocols{ + // Dash: to.Ptr(true), + // Download: to.Ptr(false), + // Hls: to.Ptr(false), + // SmoothStreaming: to.Ptr(true), + // }, + // }, + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:30.6781134Z"); return t}()), + // DefaultContentKeyPolicyName: to.Ptr("PolicyWithMultipleOptions"), + // }, + // }, + // { + // Name: to.Ptr("secureStreamingPolicyWithEnvelopeEncryptionOnly"), + // Type: to.Ptr("Microsoft.Media/mediaservices/streamingPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/streamingPolicies/secureStreamingPolicyWithEnvelopeEncryptionOnly"), + // Properties: &armmediaservices.StreamingPolicyProperties{ + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:30.6781134Z"); return t}()), + // DefaultContentKeyPolicyName: to.Ptr("PolicyWithClearKeyOptionAndTokenRestriction"), + // EnvelopeEncryption: &armmediaservices.EnvelopeEncryption{ + // ClearTracks: []*armmediaservices.TrackSelection{ + // }, + // ContentKeys: &armmediaservices.StreamingPolicyContentKeys{ + // DefaultKey: &armmediaservices.DefaultKey{ + // Label: to.Ptr("aesDefaultKey"), + // }, + // KeyToTrackMappings: []*armmediaservices.StreamingPolicyContentKey{ + // }, + // }, + // CustomKeyAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}"), + // EnabledProtocols: &armmediaservices.EnabledProtocols{ + // Dash: to.Ptr(true), + // Download: to.Ptr(false), + // Hls: to.Ptr(true), + // SmoothStreaming: to.Ptr(true), + // }, + // }, + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policy-get-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policy-get-by-name.json func ExampleStreamingPoliciesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contoso", "contosomedia", "clearStreamingPolicy", nil) + res, err := clientFactory.NewStreamingPoliciesClient().Get(ctx, "contoso", "contosomedia", "clearStreamingPolicy", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.StreamingPolicy = armmediaservices.StreamingPolicy{ + // Name: to.Ptr("clearStreamingPolicy"), + // Type: to.Ptr("Microsoft.Media/mediaservices/streamingPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/streamingPolicies/clearStreamingPolicy"), + // Properties: &armmediaservices.StreamingPolicyProperties{ + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-08T18:29:30.8501486Z"); return t}()), + // NoEncryption: &armmediaservices.NoEncryption{ + // EnabledProtocols: &armmediaservices.EnabledProtocols{ + // Dash: to.Ptr(true), + // Download: to.Ptr(true), + // Hls: to.Ptr(true), + // SmoothStreaming: to.Ptr(true), + // }, + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCbcs-clearKeyEncryption.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCbcs-clearKeyEncryption.json func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithClearKeyEncryptionInCommonEncryptionCbcs() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly", armmediaservices.StreamingPolicy{ + _, err = clientFactory.NewStreamingPoliciesClient().Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly", armmediaservices.StreamingPolicy{ Properties: &armmediaservices.StreamingPolicyProperties{ CommonEncryptionCbcs: &armmediaservices.CommonEncryptionCbcs{ ClearKeyEncryptionConfiguration: &armmediaservices.ClearKeyEncryptionConfiguration{ @@ -100,18 +323,18 @@ func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithClearKeyEn } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCenc-clearKeyEncryption.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCenc-clearKeyEncryption.json func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithClearKeyEncryptionInCommonEncryptionCenc() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly", armmediaservices.StreamingPolicy{ + _, err = clientFactory.NewStreamingPoliciesClient().Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly", armmediaservices.StreamingPolicy{ Properties: &armmediaservices.StreamingPolicyProperties{ CommonEncryptionCenc: &armmediaservices.CommonEncryptionCenc{ ClearKeyEncryptionConfiguration: &armmediaservices.ClearKeyEncryptionConfiguration{ @@ -146,18 +369,18 @@ func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithClearKeyEn } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-clear.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-clear.json func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithClearStreaming() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Create(ctx, "contoso", "contosomedia", "UserCreatedClearStreamingPolicy", armmediaservices.StreamingPolicy{ + _, err = clientFactory.NewStreamingPoliciesClient().Create(ctx, "contoso", "contosomedia", "UserCreatedClearStreamingPolicy", armmediaservices.StreamingPolicy{ Properties: &armmediaservices.StreamingPolicyProperties{ NoEncryption: &armmediaservices.NoEncryption{ EnabledProtocols: &armmediaservices.EnabledProtocols{ @@ -174,18 +397,18 @@ func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithClearStrea } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCbcs-only.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCbcs-only.json func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithCommonEncryptionCbcsOnly() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly", armmediaservices.StreamingPolicy{ + _, err = clientFactory.NewStreamingPoliciesClient().Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly", armmediaservices.StreamingPolicy{ Properties: &armmediaservices.StreamingPolicyProperties{ CommonEncryptionCbcs: &armmediaservices.CommonEncryptionCbcs{ ContentKeys: &armmediaservices.StreamingPolicyContentKeys{ @@ -214,18 +437,18 @@ func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithCommonEncr } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCenc-only.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCenc-only.json func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithCommonEncryptionCencOnly() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly", armmediaservices.StreamingPolicy{ + _, err = clientFactory.NewStreamingPoliciesClient().Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly", armmediaservices.StreamingPolicy{ Properties: &armmediaservices.StreamingPolicyProperties{ CommonEncryptionCenc: &armmediaservices.CommonEncryptionCenc{ ClearTracks: []*armmediaservices.TrackSelection{ @@ -266,18 +489,18 @@ func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithCommonEncr } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-envelopeEncryption-only.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-envelopeEncryption-only.json func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithEnvelopeEncryptionOnly() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicyWithEnvelopeEncryptionOnly", armmediaservices.StreamingPolicy{ + _, err = clientFactory.NewStreamingPoliciesClient().Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicyWithEnvelopeEncryptionOnly", armmediaservices.StreamingPolicy{ Properties: &armmediaservices.StreamingPolicyProperties{ DefaultContentKeyPolicyName: to.Ptr("PolicyWithClearKeyOptionAndTokenRestriction"), EnvelopeEncryption: &armmediaservices.EnvelopeEncryption{ @@ -301,18 +524,18 @@ func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithEnvelopeEn } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-secure-streaming.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-secure-streaming.json func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithSecureStreaming() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicy", armmediaservices.StreamingPolicy{ + _, err = clientFactory.NewStreamingPoliciesClient().Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicy", armmediaservices.StreamingPolicy{ Properties: &armmediaservices.StreamingPolicyProperties{ CommonEncryptionCbcs: &armmediaservices.CommonEncryptionCbcs{ ContentKeys: &armmediaservices.StreamingPolicyContentKeys{ @@ -386,18 +609,18 @@ func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithSecureStre } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-delete.json func ExampleStreamingPoliciesClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewStreamingPoliciesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "contoso", "contosomedia", "secureStreamingPolicyWithCommonEncryptionCbcsOnly", nil) + _, err = clientFactory.NewStreamingPoliciesClient().Delete(ctx, "contoso", "contosomedia", "secureStreamingPolicyWithCommonEncryptionCbcsOnly", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/time_rfc3339.go b/sdk/resourcemanager/mediaservices/armmediaservices/time_rfc3339.go index 59986c46def5..4d3aabbdeda7 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/time_rfc3339.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/time_rfc3339.go @@ -62,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/tracks_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/tracks_client.go index 65f999315e4e..ab1810bb3d22 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/tracks_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/tracks_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,66 +24,59 @@ import ( // TracksClient contains the methods for the Tracks group. // Don't use this type directly, use NewTracksClient() instead. type TracksClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTracksClient creates a new instance of TracksClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewTracksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TracksClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".TracksClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TracksClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create or update a Track in the asset // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// trackName - The Asset Track name. -// parameters - The request parameters -// options - TracksClientBeginCreateOrUpdateOptions contains the optional parameters for the TracksClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - trackName - The Asset Track name. +// - parameters - The request parameters +// - options - TracksClientBeginCreateOrUpdateOptions contains the optional parameters for the TracksClient.BeginCreateOrUpdate +// method. func (client *TracksClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, parameters AssetTrack, options *TracksClientBeginCreateOrUpdateOptions) (*runtime.Poller[TracksClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, accountName, assetName, trackName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[TracksClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[TracksClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[TracksClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[TracksClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or update a Track in the asset // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *TracksClient) createOrUpdate(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, parameters AssetTrack, options *TracksClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, assetName, trackName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -118,7 +109,7 @@ func (client *TracksClient) createOrUpdateCreateRequest(ctx context.Context, res return nil, errors.New("parameter trackName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{trackName}", url.PathEscape(trackName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -131,33 +122,35 @@ func (client *TracksClient) createOrUpdateCreateRequest(ctx context.Context, res // BeginDelete - Deletes a Track in the asset // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// trackName - The Asset Track name. -// options - TracksClientBeginDeleteOptions contains the optional parameters for the TracksClient.BeginDelete method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - trackName - The Asset Track name. +// - options - TracksClientBeginDeleteOptions contains the optional parameters for the TracksClient.BeginDelete method. func (client *TracksClient) BeginDelete(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, options *TracksClientBeginDeleteOptions) (*runtime.Poller[TracksClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, accountName, assetName, trackName, options) if err != nil { return nil, err } - return runtime.NewPoller[TracksClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[TracksClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[TracksClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[TracksClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a Track in the asset // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *TracksClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, options *TracksClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, assetName, trackName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -190,7 +183,7 @@ func (client *TracksClient) deleteCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter trackName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{trackName}", url.PathEscape(trackName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -203,18 +196,19 @@ func (client *TracksClient) deleteCreateRequest(ctx context.Context, resourceGro // Get - Get the details of a Track in the Asset // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// trackName - The Asset Track name. -// options - TracksClientGetOptions contains the optional parameters for the TracksClient.Get method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - trackName - The Asset Track name. +// - options - TracksClientGetOptions contains the optional parameters for the TracksClient.Get method. func (client *TracksClient) Get(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, options *TracksClientGetOptions) (TracksClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, assetName, trackName, options) if err != nil { return TracksClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TracksClientGetResponse{}, err } @@ -247,7 +241,7 @@ func (client *TracksClient) getCreateRequest(ctx context.Context, resourceGroupN return nil, errors.New("parameter trackName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{trackName}", url.PathEscape(trackName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -268,11 +262,12 @@ func (client *TracksClient) getHandleResponse(resp *http.Response) (TracksClient } // NewListPager - Lists the Tracks in the asset +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// options - TracksClientListOptions contains the optional parameters for the TracksClient.List method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - options - TracksClientListOptions contains the optional parameters for the TracksClient.NewListPager method. func (client *TracksClient) NewListPager(resourceGroupName string, accountName string, assetName string, options *TracksClientListOptions) *runtime.Pager[TracksClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TracksClientListResponse]{ More: func(page TracksClientListResponse) bool { @@ -283,7 +278,7 @@ func (client *TracksClient) NewListPager(resourceGroupName string, accountName s if err != nil { return TracksClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TracksClientListResponse{}, err } @@ -314,7 +309,7 @@ func (client *TracksClient) listCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter assetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assetName}", url.PathEscape(assetName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -336,34 +331,36 @@ func (client *TracksClient) listHandleResponse(resp *http.Response) (TracksClien // BeginUpdate - Updates an existing Track in the asset // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// trackName - The Asset Track name. -// parameters - The request parameters -// options - TracksClientBeginUpdateOptions contains the optional parameters for the TracksClient.BeginUpdate method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - trackName - The Asset Track name. +// - parameters - The request parameters +// - options - TracksClientBeginUpdateOptions contains the optional parameters for the TracksClient.BeginUpdate method. func (client *TracksClient) BeginUpdate(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, parameters AssetTrack, options *TracksClientBeginUpdateOptions) (*runtime.Poller[TracksClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, accountName, assetName, trackName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[TracksClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[TracksClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[TracksClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[TracksClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates an existing Track in the asset // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *TracksClient) update(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, parameters AssetTrack, options *TracksClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, assetName, trackName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -396,7 +393,7 @@ func (client *TracksClient) updateCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter trackName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{trackName}", url.PathEscape(trackName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -413,22 +410,23 @@ func (client *TracksClient) updateCreateRequest(ctx context.Context, resourceGro // may not be reflected immediately. CDN cache may also need to be purged if // applicable. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// assetName - The Asset name. -// trackName - The Asset Track name. -// options - TracksClientBeginUpdateTrackDataOptions contains the optional parameters for the TracksClient.BeginUpdateTrackData -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - assetName - The Asset name. +// - trackName - The Asset Track name. +// - options - TracksClientBeginUpdateTrackDataOptions contains the optional parameters for the TracksClient.BeginUpdateTrackData +// method. func (client *TracksClient) BeginUpdateTrackData(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, options *TracksClientBeginUpdateTrackDataOptions) (*runtime.Poller[TracksClientUpdateTrackDataResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.updateTrackData(ctx, resourceGroupName, accountName, assetName, trackName, options) if err != nil { return nil, err } - return runtime.NewPoller[TracksClientUpdateTrackDataResponse](resp, client.pl, nil) + return runtime.NewPoller[TracksClientUpdateTrackDataResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[TracksClientUpdateTrackDataResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[TracksClientUpdateTrackDataResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -438,13 +436,14 @@ func (client *TracksClient) BeginUpdateTrackData(ctx context.Context, resourceGr // may not be reflected immediately. CDN cache may also need to be purged if // applicable. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *TracksClient) updateTrackData(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, options *TracksClientBeginUpdateTrackDataOptions) (*http.Response, error) { req, err := client.updateTrackDataCreateRequest(ctx, resourceGroupName, accountName, assetName, trackName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -477,7 +476,7 @@ func (client *TracksClient) updateTrackDataCreateRequest(ctx context.Context, re return nil, errors.New("parameter trackName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{trackName}", url.PathEscape(trackName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/tracks_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/tracks_client_example_test.go index 9ee25489ac3b..b04388aeec76 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/tracks_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/tracks_client_example_test.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 armmediaservices_test @@ -17,61 +18,138 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-list-all.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-list-all.json func ExampleTracksClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewTracksClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contoso", "contosomedia", "ClimbingMountRainer", nil) + pager := clientFactory.NewTracksClient().NewListPager("contoso", "contosomedia", "ClimbingMountRainer", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AssetTrackCollection = armmediaservices.AssetTrackCollection{ + // Value: []*armmediaservices.AssetTrack{ + // { + // Name: to.Ptr("video"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets/tracks"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/tracks/video"), + // Properties: &armmediaservices.AssetTrackProperties{ + // ProvisioningState: to.Ptr(armmediaservices.ProvisioningStateSucceeded), + // Track: &armmediaservices.VideoTrack{ + // ODataType: to.Ptr("#Microsoft.Media.VideoTrack"), + // }, + // }, + // }, + // { + // Name: to.Ptr("audio"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets/tracks"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/tracks/audio"), + // Properties: &armmediaservices.AssetTrackProperties{ + // ProvisioningState: to.Ptr(armmediaservices.ProvisioningStateSucceeded), + // Track: &armmediaservices.AudioTrack{ + // ODataType: to.Ptr("#Microsoft.Media.AudioTrack"), + // }, + // }, + // }, + // { + // Name: to.Ptr("text1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets/tracks"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/tracks/text1"), + // Properties: &armmediaservices.AssetTrackProperties{ + // ProvisioningState: to.Ptr(armmediaservices.ProvisioningStateSucceeded), + // Track: &armmediaservices.TextTrack{ + // ODataType: to.Ptr("#Microsoft.Media.TextTrack"), + // DisplayName: to.Ptr("Auto generated"), + // FileName: to.Ptr("auto_generated.ttml"), + // LanguageCode: to.Ptr("en-us"), + // PlayerVisibility: to.Ptr(armmediaservices.VisibilityVisible), + // }, + // }, + // }, + // { + // Name: to.Ptr("text2"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets/tracks"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/tracks/text2"), + // Properties: &armmediaservices.AssetTrackProperties{ + // ProvisioningState: to.Ptr(armmediaservices.ProvisioningStateSucceeded), + // Track: &armmediaservices.TextTrack{ + // ODataType: to.Ptr("#Microsoft.Media.TextTrack"), + // DisplayName: to.Ptr("user uploaded text track"), + // FileName: to.Ptr("text2.vtt"), + // HlsSettings: &armmediaservices.HlsSettings{ + // Default: to.Ptr(true), + // Characteristics: to.Ptr("public.accessibility.transcribes-spoken-dialog,public.easy-to-read"), + // Forced: to.Ptr(true), + // }, + // LanguageCode: to.Ptr("en-us"), + // PlayerVisibility: to.Ptr(armmediaservices.VisibilityHidden), + // }, + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-get-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-get-by-name.json func ExampleTracksClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewTracksClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text1", nil) + res, err := clientFactory.NewTracksClient().Get(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AssetTrack = armmediaservices.AssetTrack{ + // Name: to.Ptr("text1"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets/tracks"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/tracks/text1"), + // Properties: &armmediaservices.AssetTrackProperties{ + // ProvisioningState: to.Ptr(armmediaservices.ProvisioningStateSucceeded), + // Track: &armmediaservices.TextTrack{ + // ODataType: to.Ptr("#Microsoft.Media.TextTrack"), + // DisplayName: to.Ptr("Auto generated"), + // FileName: to.Ptr("auto_generated.ttml"), + // LanguageCode: to.Ptr("en-us"), + // PlayerVisibility: to.Ptr(armmediaservices.VisibilityVisible), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-create.json func ExampleTracksClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewTracksClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text3", armmediaservices.AssetTrack{ + poller, err := clientFactory.NewTracksClient().BeginCreateOrUpdate(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text3", armmediaservices.AssetTrack{ Properties: &armmediaservices.AssetTrackProperties{ Track: &armmediaservices.TextTrack{ ODataType: to.Ptr("#Microsoft.Media.TextTrack"), @@ -88,22 +166,37 @@ func ExampleTracksClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AssetTrack = armmediaservices.AssetTrack{ + // Name: to.Ptr("text3"), + // Type: to.Ptr("Microsoft.Media/mediaservices/assets/tracks"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/tracks/text3"), + // Properties: &armmediaservices.AssetTrackProperties{ + // ProvisioningState: to.Ptr(armmediaservices.ProvisioningStateSucceeded), + // Track: &armmediaservices.TextTrack{ + // ODataType: to.Ptr("#Microsoft.Media.TextTrack"), + // DisplayName: to.Ptr("A new track"), + // FileName: to.Ptr("text3.ttml"), + // PlayerVisibility: to.Ptr(armmediaservices.VisibilityVisible), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-delete.json func ExampleTracksClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewTracksClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text2", nil) + poller, err := clientFactory.NewTracksClient().BeginDelete(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text2", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -113,18 +206,18 @@ func ExampleTracksClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-update.json func ExampleTracksClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewTracksClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text1", armmediaservices.AssetTrack{ + poller, err := clientFactory.NewTracksClient().BeginUpdate(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text1", armmediaservices.AssetTrack{ Properties: &armmediaservices.AssetTrackProperties{ Track: &armmediaservices.TextTrack{ ODataType: to.Ptr("#Microsoft.Media.TextTrack"), @@ -141,18 +234,18 @@ func ExampleTracksClient_BeginUpdate() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-update-data.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-update-data.json func ExampleTracksClient_BeginUpdateTrackData() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewTracksClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdateTrackData(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text2", nil) + poller, err := clientFactory.NewTracksClient().BeginUpdateTrackData(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text2", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/transforms_client.go b/sdk/resourcemanager/mediaservices/armmediaservices/transforms_client.go index 40f5ad0062d6..6a8b995a0e80 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/transforms_client.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/transforms_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,50 +24,42 @@ import ( // TransformsClient contains the methods for the Transforms group. // Don't use this type directly, use NewTransformsClient() instead. type TransformsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTransformsClient creates a new instance of TransformsClient with the specified values. -// subscriptionID - The unique identifier for a Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The unique identifier for a Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewTransformsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TransformsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".TransformsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TransformsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Creates or updates a new Transform. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// transformName - The Transform name. -// parameters - The request parameters -// options - TransformsClientCreateOrUpdateOptions contains the optional parameters for the TransformsClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - transformName - The Transform name. +// - parameters - The request parameters +// - options - TransformsClientCreateOrUpdateOptions contains the optional parameters for the TransformsClient.CreateOrUpdate +// method. func (client *TransformsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, transformName string, parameters Transform, options *TransformsClientCreateOrUpdateOptions) (TransformsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, transformName, parameters, options) if err != nil { return TransformsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TransformsClientCreateOrUpdateResponse{}, err } @@ -98,7 +88,7 @@ func (client *TransformsClient) createOrUpdateCreateRequest(ctx context.Context, return nil, errors.New("parameter transformName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{transformName}", url.PathEscape(transformName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -120,17 +110,18 @@ func (client *TransformsClient) createOrUpdateHandleResponse(resp *http.Response // Delete - Deletes a Transform. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// transformName - The Transform name. -// options - TransformsClientDeleteOptions contains the optional parameters for the TransformsClient.Delete method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - transformName - The Transform name. +// - options - TransformsClientDeleteOptions contains the optional parameters for the TransformsClient.Delete method. func (client *TransformsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, transformName string, options *TransformsClientDeleteOptions) (TransformsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, transformName, options) if err != nil { return TransformsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TransformsClientDeleteResponse{}, err } @@ -159,7 +150,7 @@ func (client *TransformsClient) deleteCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter transformName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{transformName}", url.PathEscape(transformName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -172,17 +163,18 @@ func (client *TransformsClient) deleteCreateRequest(ctx context.Context, resourc // Get - Gets a Transform. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// transformName - The Transform name. -// options - TransformsClientGetOptions contains the optional parameters for the TransformsClient.Get method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - transformName - The Transform name. +// - options - TransformsClientGetOptions contains the optional parameters for the TransformsClient.Get method. func (client *TransformsClient) Get(ctx context.Context, resourceGroupName string, accountName string, transformName string, options *TransformsClientGetOptions) (TransformsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, transformName, options) if err != nil { return TransformsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TransformsClientGetResponse{}, err } @@ -211,7 +203,7 @@ func (client *TransformsClient) getCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter transformName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{transformName}", url.PathEscape(transformName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -232,10 +224,11 @@ func (client *TransformsClient) getHandleResponse(resp *http.Response) (Transfor } // NewListPager - Lists the Transforms in the account. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// options - TransformsClientListOptions contains the optional parameters for the TransformsClient.List method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - options - TransformsClientListOptions contains the optional parameters for the TransformsClient.NewListPager method. func (client *TransformsClient) NewListPager(resourceGroupName string, accountName string, options *TransformsClientListOptions) *runtime.Pager[TransformsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TransformsClientListResponse]{ More: func(page TransformsClientListResponse) bool { @@ -252,7 +245,7 @@ func (client *TransformsClient) NewListPager(resourceGroupName string, accountNa if err != nil { return TransformsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TransformsClientListResponse{}, err } @@ -279,7 +272,7 @@ func (client *TransformsClient) listCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -307,18 +300,19 @@ func (client *TransformsClient) listHandleResponse(resp *http.Response) (Transfo // Update - Updates a Transform. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group within the Azure subscription. -// accountName - The Media Services account name. -// transformName - The Transform name. -// parameters - The request parameters -// options - TransformsClientUpdateOptions contains the optional parameters for the TransformsClient.Update method. +// - resourceGroupName - The name of the resource group within the Azure subscription. +// - accountName - The Media Services account name. +// - transformName - The Transform name. +// - parameters - The request parameters +// - options - TransformsClientUpdateOptions contains the optional parameters for the TransformsClient.Update method. func (client *TransformsClient) Update(ctx context.Context, resourceGroupName string, accountName string, transformName string, parameters Transform, options *TransformsClientUpdateOptions) (TransformsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, transformName, parameters, options) if err != nil { return TransformsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TransformsClientUpdateResponse{}, err } @@ -347,7 +341,7 @@ func (client *TransformsClient) updateCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter transformName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{transformName}", url.PathEscape(transformName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mediaservices/armmediaservices/transforms_client_example_test.go b/sdk/resourcemanager/mediaservices/armmediaservices/transforms_client_example_test.go index 4a286626c005..f0a5d35383ef 100644 --- a/sdk/resourcemanager/mediaservices/armmediaservices/transforms_client_example_test.go +++ b/sdk/resourcemanager/mediaservices/armmediaservices/transforms_client_example_test.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 armmediaservices_test @@ -17,141 +18,367 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-list-all.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-list-all.json func ExampleTransformsClient_NewListPager_listsTheTransforms() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewTransformsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contosoresources", "contosomedia", &armmediaservices.TransformsClientListOptions{Filter: nil, + pager := clientFactory.NewTransformsClient().NewListPager("contosoresources", "contosomedia", &armmediaservices.TransformsClientListOptions{Filter: nil, Orderby: nil, }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.TransformCollection = armmediaservices.TransformCollection{ + // Value: []*armmediaservices.Transform{ + // { + // Name: to.Ptr("sampleEncode"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/sampleEncode"), + // Properties: &armmediaservices.TransformProperties{ + // Description: to.Ptr("A sample Transform using the Standard Encoder with a built in preset."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:30.2486761Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:30.2486761Z"); return t}()), + // Outputs: []*armmediaservices.TransformOutput{ + // { + // OnError: to.Ptr(armmediaservices.OnErrorTypeStopProcessingJob), + // Preset: &armmediaservices.BuiltInStandardEncoderPreset{ + // ODataType: to.Ptr("#Microsoft.Media.BuiltInStandardEncoderPreset"), + // PresetName: to.Ptr(armmediaservices.EncoderNamedPresetAdaptiveStreaming), + // }, + // RelativePriority: to.Ptr(armmediaservices.PriorityNormal), + // }}, + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:30.2486761Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:30.2486761Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }, + // { + // Name: to.Ptr("sampleEncodeAndVideoIndex"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/sampleEncodeAndVideoIndex"), + // Properties: &armmediaservices.TransformProperties{ + // Description: to.Ptr("A sample Transform using the Standard Encoder with a built-in preset, as well as the Video Analyzer."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:30.4774769Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:30.4774769Z"); return t}()), + // Outputs: []*armmediaservices.TransformOutput{ + // { + // OnError: to.Ptr(armmediaservices.OnErrorTypeStopProcessingJob), + // Preset: &armmediaservices.BuiltInStandardEncoderPreset{ + // ODataType: to.Ptr("#Microsoft.Media.BuiltInStandardEncoderPreset"), + // PresetName: to.Ptr(armmediaservices.EncoderNamedPresetAdaptiveStreaming), + // }, + // RelativePriority: to.Ptr(armmediaservices.PriorityNormal), + // }, + // { + // OnError: to.Ptr(armmediaservices.OnErrorTypeStopProcessingJob), + // Preset: &armmediaservices.VideoAnalyzerPreset{ + // ODataType: to.Ptr("#Microsoft.Media.VideoAnalyzerPreset"), + // Mode: to.Ptr(armmediaservices.AudioAnalysisModeStandard), + // InsightsToExtract: to.Ptr(armmediaservices.InsightsTypeAllInsights), + // }, + // RelativePriority: to.Ptr(armmediaservices.PriorityNormal), + // }}, + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:30.4774769Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:30.4774769Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-list-all-filter-by-created.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-list-all-filter-by-created.json func ExampleTransformsClient_NewListPager_listsTheTransformsFilterByCreated() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewTransformsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contosoresources", "contosomedia", &armmediaservices.TransformsClientListOptions{Filter: to.Ptr("properties/created gt 2021-06-01T00:00:00.0000000Z and properties/created le 2021-06-01T00:00:10.0000000Z"), + pager := clientFactory.NewTransformsClient().NewListPager("contosoresources", "contosomedia", &armmediaservices.TransformsClientListOptions{Filter: to.Ptr("properties/created gt 2021-06-01T00:00:00.0000000Z and properties/created le 2021-06-01T00:00:10.0000000Z"), Orderby: to.Ptr("properties/created"), }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.TransformCollection = armmediaservices.TransformCollection{ + // Value: []*armmediaservices.Transform{ + // { + // Name: to.Ptr("sampleEncodeAndVideoIndex"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/sampleEncodeAndVideoIndex"), + // Properties: &armmediaservices.TransformProperties{ + // Description: to.Ptr("A sample Transform using the Video Analyzer."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // Outputs: []*armmediaservices.TransformOutput{ + // { + // OnError: to.Ptr(armmediaservices.OnErrorTypeStopProcessingJob), + // Preset: &armmediaservices.VideoAnalyzerPreset{ + // ODataType: to.Ptr("#Microsoft.Media.VideoAnalyzerPreset"), + // Mode: to.Ptr(armmediaservices.AudioAnalysisModeStandard), + // InsightsToExtract: to.Ptr(armmediaservices.InsightsTypeAllInsights), + // }, + // RelativePriority: to.Ptr(armmediaservices.PriorityNormal), + // }}, + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-list-all-filter-by-lastmodified.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-list-all-filter-by-lastmodified.json func ExampleTransformsClient_NewListPager_listsTheTransformsFilterByLastmodified() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewTransformsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contosoresources", "contosomedia", &armmediaservices.TransformsClientListOptions{Filter: to.Ptr("properties/lastmodified gt 2021-06-01T00:00:00.0000000Z and properties/lastmodified le 2021-06-01T00:00:10.0000000Z"), + pager := clientFactory.NewTransformsClient().NewListPager("contosoresources", "contosomedia", &armmediaservices.TransformsClientListOptions{Filter: to.Ptr("properties/lastmodified gt 2021-06-01T00:00:00.0000000Z and properties/lastmodified le 2021-06-01T00:00:10.0000000Z"), Orderby: to.Ptr("properties/lastmodified desc"), }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.TransformCollection = armmediaservices.TransformCollection{ + // Value: []*armmediaservices.Transform{ + // { + // Name: to.Ptr("sampleEncodeAndVideoIndex"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/sampleEncodeAndVideoIndex"), + // Properties: &armmediaservices.TransformProperties{ + // Description: to.Ptr("A sample Transform using the Video Analyzer."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // Outputs: []*armmediaservices.TransformOutput{ + // { + // OnError: to.Ptr(armmediaservices.OnErrorTypeStopProcessingJob), + // Preset: &armmediaservices.VideoAnalyzerPreset{ + // ODataType: to.Ptr("#Microsoft.Media.VideoAnalyzerPreset"), + // Mode: to.Ptr(armmediaservices.AudioAnalysisModeStandard), + // InsightsToExtract: to.Ptr(armmediaservices.InsightsTypeAllInsights), + // }, + // RelativePriority: to.Ptr(armmediaservices.PriorityNormal), + // }}, + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-01T00:00:10Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-list-all-filter-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-list-all-filter-by-name.json func ExampleTransformsClient_NewListPager_listsTheTransformsFilterByName() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewTransformsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("contosoresources", "contosomedia", &armmediaservices.TransformsClientListOptions{Filter: to.Ptr("(name eq 'sampleEncode') or (name eq 'sampleEncodeAndVideoIndex')"), + pager := clientFactory.NewTransformsClient().NewListPager("contosoresources", "contosomedia", &armmediaservices.TransformsClientListOptions{Filter: to.Ptr("(name eq 'sampleEncode') or (name eq 'sampleEncodeAndVideoIndex')"), Orderby: to.Ptr("name desc"), }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.TransformCollection = armmediaservices.TransformCollection{ + // Value: []*armmediaservices.Transform{ + // { + // Name: to.Ptr("sampleEncodeAndVideoIndex"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/sampleEncodeAndVideoIndex"), + // Properties: &armmediaservices.TransformProperties{ + // Description: to.Ptr("A sample Transform using the Standard Encoder with a built-in preset, as well as the Video Analyzer."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.2387023Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.2387023Z"); return t}()), + // Outputs: []*armmediaservices.TransformOutput{ + // { + // OnError: to.Ptr(armmediaservices.OnErrorTypeStopProcessingJob), + // Preset: &armmediaservices.BuiltInStandardEncoderPreset{ + // ODataType: to.Ptr("#Microsoft.Media.BuiltInStandardEncoderPreset"), + // PresetName: to.Ptr(armmediaservices.EncoderNamedPresetAdaptiveStreaming), + // }, + // RelativePriority: to.Ptr(armmediaservices.PriorityNormal), + // }, + // { + // OnError: to.Ptr(armmediaservices.OnErrorTypeStopProcessingJob), + // Preset: &armmediaservices.VideoAnalyzerPreset{ + // ODataType: to.Ptr("#Microsoft.Media.VideoAnalyzerPreset"), + // Mode: to.Ptr(armmediaservices.AudioAnalysisModeStandard), + // InsightsToExtract: to.Ptr(armmediaservices.InsightsTypeAllInsights), + // }, + // RelativePriority: to.Ptr(armmediaservices.PriorityNormal), + // }}, + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.2387023Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.2387023Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }, + // { + // Name: to.Ptr("sampleEncode"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/sampleEncode"), + // Properties: &armmediaservices.TransformProperties{ + // Description: to.Ptr("A sample Transform using the Standard Encoder with a built in preset."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.2387023Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.2387023Z"); return t}()), + // Outputs: []*armmediaservices.TransformOutput{ + // { + // OnError: to.Ptr(armmediaservices.OnErrorTypeStopProcessingJob), + // Preset: &armmediaservices.BuiltInStandardEncoderPreset{ + // ODataType: to.Ptr("#Microsoft.Media.BuiltInStandardEncoderPreset"), + // PresetName: to.Ptr(armmediaservices.EncoderNamedPresetAdaptiveStreaming), + // }, + // RelativePriority: to.Ptr(armmediaservices.PriorityNormal), + // }}, + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.2387023Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.2387023Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-get-by-name.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-get-by-name.json func ExampleTransformsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewTransformsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "contosoresources", "contosomedia", "sampleTransform", nil) + res, err := clientFactory.NewTransformsClient().Get(ctx, "contosoresources", "contosomedia", "sampleTransform", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Transform = armmediaservices.Transform{ + // Name: to.Ptr("sampleTransform"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/sampleTransform"), + // Properties: &armmediaservices.TransformProperties{ + // Description: to.Ptr("A sample Transform using the Standard Encoder with a built in preset."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.6281097Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.6281097Z"); return t}()), + // Outputs: []*armmediaservices.TransformOutput{ + // { + // OnError: to.Ptr(armmediaservices.OnErrorTypeStopProcessingJob), + // Preset: &armmediaservices.BuiltInStandardEncoderPreset{ + // ODataType: to.Ptr("#Microsoft.Media.BuiltInStandardEncoderPreset"), + // PresetName: to.Ptr(armmediaservices.EncoderNamedPresetH264MultipleBitrate1080P), + // }, + // RelativePriority: to.Ptr(armmediaservices.PriorityNormal), + // }}, + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.6281097Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.6281097Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-create.json func ExampleTransformsClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewTransformsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "contosoresources", "contosomedia", "createdTransform", armmediaservices.Transform{ + res, err := clientFactory.NewTransformsClient().CreateOrUpdate(ctx, "contosoresources", "contosomedia", "createdTransform", armmediaservices.Transform{ Properties: &armmediaservices.TransformProperties{ Description: to.Ptr("Example Transform to illustrate create and update."), Outputs: []*armmediaservices.TransformOutput{ @@ -166,39 +393,67 @@ func ExampleTransformsClient_CreateOrUpdate() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Transform = armmediaservices.Transform{ + // Name: to.Ptr("createdTransform"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/createdTransform"), + // Properties: &armmediaservices.TransformProperties{ + // Description: to.Ptr("Example Transform to illustrate create and update."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.7664818Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.7664818Z"); return t}()), + // Outputs: []*armmediaservices.TransformOutput{ + // { + // OnError: to.Ptr(armmediaservices.OnErrorTypeStopProcessingJob), + // Preset: &armmediaservices.BuiltInStandardEncoderPreset{ + // ODataType: to.Ptr("#Microsoft.Media.BuiltInStandardEncoderPreset"), + // PresetName: to.Ptr(armmediaservices.EncoderNamedPresetAdaptiveStreaming), + // }, + // RelativePriority: to.Ptr(armmediaservices.PriorityNormal), + // }}, + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.7664818Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:31.7664818Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-delete.json func ExampleTransformsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewTransformsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "contosoresources", "contosomedia", "sampleTransform", nil) + _, err = clientFactory.NewTransformsClient().Delete(ctx, "contosoresources", "contosomedia", "sampleTransform", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-update.json func ExampleTransformsClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmediaservices.NewTransformsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "contosoresources", "contosomedia", "transformToUpdate", armmediaservices.Transform{ + res, err := clientFactory.NewTransformsClient().Update(ctx, "contosoresources", "contosomedia", "transformToUpdate", armmediaservices.Transform{ Properties: &armmediaservices.TransformProperties{ Description: to.Ptr("Example transform to illustrate update."), Outputs: []*armmediaservices.TransformOutput{ @@ -214,6 +469,34 @@ func ExampleTransformsClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Transform = armmediaservices.Transform{ + // Name: to.Ptr("transformToUpdate"), + // Type: to.Ptr("Microsoft.Media/mediaservices/transforms"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosoresources/providers/Microsoft.Media/mediaservices/contosomedia/transforms/transformToUpdate"), + // Properties: &armmediaservices.TransformProperties{ + // Description: to.Ptr("Example transform to illustrate update."), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:32.1435128Z"); return t}()), + // LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:32.1455494Z"); return t}()), + // Outputs: []*armmediaservices.TransformOutput{ + // { + // OnError: to.Ptr(armmediaservices.OnErrorTypeStopProcessingJob), + // Preset: &armmediaservices.BuiltInStandardEncoderPreset{ + // ODataType: to.Ptr("#Microsoft.Media.BuiltInStandardEncoderPreset"), + // PresetName: to.Ptr(armmediaservices.EncoderNamedPresetH264MultipleBitrate720P), + // }, + // RelativePriority: to.Ptr(armmediaservices.PriorityHigh), + // }}, + // }, + // SystemData: &armmediaservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:32.1435128Z"); return t}()), + // CreatedBy: to.Ptr("contoso@microsoft.com"), + // CreatedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T23:14:32.1455494Z"); return t}()), + // LastModifiedBy: to.Ptr("contoso@microsoft.com"), + // LastModifiedByType: to.Ptr(armmediaservices.CreatedByTypeUser), + // }, + // } } diff --git a/sdk/resourcemanager/migrate/armmigrate/CHANGELOG.md b/sdk/resourcemanager/migrate/armmigrate/CHANGELOG.md index 490011fca132..c7bd604dd371 100644 --- a/sdk/resourcemanager/migrate/armmigrate/CHANGELOG.md +++ b/sdk/resourcemanager/migrate/armmigrate/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-06-10) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/migrate/armmigrate` 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/migrate/armmigrate/README.md b/sdk/resourcemanager/migrate/armmigrate/README.md index 2bbd6bb23fc3..186f045a1e7b 100644 --- a/sdk/resourcemanager/migrate/armmigrate/README.md +++ b/sdk/resourcemanager/migrate/armmigrate/README.md @@ -33,23 +33,31 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Migrate modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Migrate module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armmigrate.NewServerCollectorsClient(, cred, nil) +clientFactory, err := armmigrate.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). ```go -options := arm.ClientOptions{ +options := arm.ClientOptions { ClientOptions: azcore.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armmigrate.NewServerCollectorsClient(, cred, &options) +clientFactory, err := armmigrate.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewGroupsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_assessedmachines_client.go b/sdk/resourcemanager/migrate/armmigrate/assessedmachines_client.go similarity index 82% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_assessedmachines_client.go rename to sdk/resourcemanager/migrate/armmigrate/assessedmachines_client.go index 10cb1b60fa39..61d7457e39a3 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_assessedmachines_client.go +++ b/sdk/resourcemanager/migrate/armmigrate/assessedmachines_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 armmigrate @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,50 +24,42 @@ import ( // AssessedMachinesClient contains the methods for the AssessedMachines group. // Don't use this type directly, use NewAssessedMachinesClient() instead. type AssessedMachinesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAssessedMachinesClient creates a new instance of AssessedMachinesClient with the specified values. -// subscriptionID - Azure Subscription Id in which project was created. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription Id in which project was created. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAssessedMachinesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssessedMachinesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AssessedMachinesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AssessedMachinesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get an assessed machine with its size & cost estimate that was evaluated in the specified assessment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// groupName - Unique name of a group within a project. -// assessmentName - Unique name of an assessment within a project. -// assessedMachineName - Unique name of an assessed machine evaluated as part of an assessment. -// options - AssessedMachinesClientGetOptions contains the optional parameters for the AssessedMachinesClient.Get method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - groupName - Unique name of a group within a project. +// - assessmentName - Unique name of an assessment within a project. +// - assessedMachineName - Unique name of an assessed machine evaluated as part of an assessment. +// - options - AssessedMachinesClientGetOptions contains the optional parameters for the AssessedMachinesClient.Get method. func (client *AssessedMachinesClient) Get(ctx context.Context, resourceGroupName string, projectName string, groupName string, assessmentName string, assessedMachineName string, options *AssessedMachinesClientGetOptions) (AssessedMachinesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, projectName, groupName, assessmentName, assessedMachineName, options) if err != nil { return AssessedMachinesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessedMachinesClientGetResponse{}, err } @@ -105,7 +96,7 @@ func (client *AssessedMachinesClient) getCreateRequest(ctx context.Context, reso return nil, errors.New("parameter assessedMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assessedMachineName}", url.PathEscape(assessedMachineName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -133,14 +124,14 @@ func (client *AssessedMachinesClient) getHandleResponse(resp *http.Response) (As // Whenever an assessment is created or updated, it goes under computation. During this phase, the 'status' field of Assessment // object reports 'Computing'. During the period when the assessment is under // computation, the list of assessed machines is empty and no assessed machines are returned by this call. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// groupName - Unique name of a group within a project. -// assessmentName - Unique name of an assessment within a project. -// options - AssessedMachinesClientListByAssessmentOptions contains the optional parameters for the AssessedMachinesClient.ListByAssessment -// method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - groupName - Unique name of a group within a project. +// - assessmentName - Unique name of an assessment within a project. +// - options - AssessedMachinesClientListByAssessmentOptions contains the optional parameters for the AssessedMachinesClient.NewListByAssessmentPager +// method. func (client *AssessedMachinesClient) NewListByAssessmentPager(resourceGroupName string, projectName string, groupName string, assessmentName string, options *AssessedMachinesClientListByAssessmentOptions) *runtime.Pager[AssessedMachinesClientListByAssessmentResponse] { return runtime.NewPager(runtime.PagingHandler[AssessedMachinesClientListByAssessmentResponse]{ More: func(page AssessedMachinesClientListByAssessmentResponse) bool { @@ -157,7 +148,7 @@ func (client *AssessedMachinesClient) NewListByAssessmentPager(resourceGroupName if err != nil { return AssessedMachinesClientListByAssessmentResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessedMachinesClientListByAssessmentResponse{}, err } @@ -192,7 +183,7 @@ func (client *AssessedMachinesClient) listByAssessmentCreateRequest(ctx context. return nil, errors.New("parameter assessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assessmentName}", url.PathEscape(assessmentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/migrate/armmigrate/assessedmachines_client_example_test.go b/sdk/resourcemanager/migrate/armmigrate/assessedmachines_client_example_test.go new file mode 100644 index 000000000000..034d723fefb9 --- /dev/null +++ b/sdk/resourcemanager/migrate/armmigrate/assessedmachines_client_example_test.go @@ -0,0 +1,267 @@ +//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 armmigrate_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/migrate/armmigrate" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/AssessedMachines_ListByAssessment.json +func ExampleAssessedMachinesClient_NewListByAssessmentPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAssessedMachinesClient().NewListByAssessmentPager("abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "Test1", "assessment_5_9_2019_16_22_14", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AssessedMachineResultList = armmigrate.AssessedMachineResultList{ + // Value: []*armmigrate.AssessedMachine{ + // { + // Name: to.Ptr("f57fe432-3bd2-486a-a83a-6f4d99f1a952"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/groups/assessments/assessedMachines"), + // ETag: to.Ptr("\"b300e5dd-0000-0d00-0000-5cd4065f0000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Test1/assessments/assessment_5_9_2019_16_22_14/assessedMachines/f57fe432-3bd2-486a-a83a-6f4d99f1a952"), + // Properties: &armmigrate.AssessedMachineProperties{ + // Description: to.Ptr("Microsoft Azure Migration Image on Windows Server 2016"), + // BootType: to.Ptr(armmigrate.MachineBootTypeBIOS), + // ConfidenceRatingInPercentage: to.Ptr[float64](0), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:15.7789159Z"); return t}()), + // DatacenterMachineArmID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/abgoyal-westeurope/providers/microsoft.offazure/vmwaresites/portalvcenterbc2fsite/machines/idclab-a360-fareast-corp-micros-86617dcf-effe-59ad-8c3a-cdd3ea7300d3_52e1f68c-bea5-19ff-d0ad-6a94b79a286f"), + // DatacenterManagementServerArmID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.OffAzure/VMwareSites/PortalvCenterbc2fsite/vcenters/idclab-a360-fareast-corp-micros-86617dcf-effe-59ad-8c3a-cdd3ea7300d3"), + // DatacenterManagementServerName: to.Ptr("IDCLAB-A360.fareast.corp.microsoft.com"), + // Disks: map[string]*armmigrate.AssessedDisk{ + // "6000C299-02f5-d137-9bab-8a8ee7b192a0": &armmigrate.AssessedDisk{ + // Name: to.Ptr("6000C299-02f5-d137-9bab-8a8ee7b192a0"), + // DisplayName: to.Ptr("scsi0:0"), + // GigabytesForRecommendedDiskSize: to.Ptr[int32](128), + // GigabytesProvisioned: to.Ptr[float64](80), + // MegabytesPerSecondOfRead: to.Ptr[float64](0), + // MegabytesPerSecondOfWrite: to.Ptr[float64](0), + // MonthlyStorageCost: to.Ptr[float64](5.888), + // NumberOfReadOperationsPerSecond: to.Ptr[float64](0), + // NumberOfWriteOperationsPerSecond: to.Ptr[float64](0), + // RecommendedDiskSize: to.Ptr(armmigrate.AzureDiskSizeStandardS10), + // RecommendedDiskType: to.Ptr(armmigrate.AzureDiskTypeStandard), + // Suitability: to.Ptr(armmigrate.CloudSuitabilitySuitable), + // SuitabilityDetail: to.Ptr(armmigrate.AzureDiskSuitabilityDetail("NumberOfReadOperationsPerSecondMissing, NumberOfWriteOperationsPerSecondMissing, MegabytesPerSecondOfReadMissing, MegabytesPerSecondOfWriteMissing")), + // SuitabilityExplanation: to.Ptr(armmigrate.AzureDiskSuitabilityExplanationNotApplicable), + // }, + // }, + // DisplayName: to.Ptr("SHubhamVMNew"), + // MegabytesOfMemory: to.Ptr[float64](16384), + // MegabytesOfMemoryForRecommendedSize: to.Ptr[float64](16384), + // MonthlyBandwidthCost: to.Ptr[float64](0), + // MonthlyComputeCostForRecommendedSize: to.Ptr[float64](101.138616), + // MonthlyPremiumStorageCost: to.Ptr[float64](0), + // MonthlyStandardSSDStorageCost: to.Ptr[float64](0), + // MonthlyStorageCost: to.Ptr[float64](5.888), + // NetworkAdapters: map[string]*armmigrate.AssessedNetworkAdapter{ + // "4000": &armmigrate.AssessedNetworkAdapter{ + // DisplayName: to.Ptr("VM Network"), + // IPAddresses: []*string{ + // }, + // MacAddress: to.Ptr("00:0c:29:ad:13:d3"), + // MegabytesPerSecondReceived: to.Ptr[float64](0), + // MegabytesPerSecondTransmitted: to.Ptr[float64](0), + // MonthlyBandwidthCosts: to.Ptr[float64](0), + // NetGigabytesTransmittedPerMonth: to.Ptr[float64](0), + // Suitability: to.Ptr(armmigrate.CloudSuitabilitySuitable), + // SuitabilityDetail: to.Ptr(armmigrate.AzureNetworkAdapterSuitabilityDetailMegabytesOfDataTransmittedMissing), + // SuitabilityExplanation: to.Ptr(armmigrate.AzureNetworkAdapterSuitabilityExplanationNotApplicable), + // }, + // }, + // NumberOfCores: to.Ptr[int32](8), + // NumberOfCoresForRecommendedSize: to.Ptr[int32](8), + // OperatingSystemName: to.Ptr("Microsoft Windows Server 2016 (64-bit)"), + // OperatingSystemType: to.Ptr("windowsGuest"), + // PercentageCoresUtilization: to.Ptr[float64](0), + // PercentageMemoryUtilization: to.Ptr[float64](0), + // RecommendedSize: to.Ptr(armmigrate.AzureVMSizeStandardF8SV2), + // Suitability: to.Ptr(armmigrate.CloudSuitabilitySuitable), + // SuitabilityDetail: to.Ptr(armmigrate.AzureVMSuitabilityDetail("PercentageOfCoresUtilizedMissing, PercentageOfMemoryUtilizedMissing")), + // SuitabilityExplanation: to.Ptr(armmigrate.AzureVMSuitabilityExplanationNotApplicable), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:15.7789159Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("3b4a34a6-c729-46d2-bfd1-bcb52cc4935e"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/groups/assessments/assessedMachines"), + // ETag: to.Ptr("\"b300e6dd-0000-0d00-0000-5cd4065f0000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Test1/assessments/assessment_5_9_2019_16_22_14/assessedMachines/3b4a34a6-c729-46d2-bfd1-bcb52cc4935e"), + // Properties: &armmigrate.AssessedMachineProperties{ + // Description: to.Ptr("Microsoft Azure Migration Image on Windows Server 2016"), + // BootType: to.Ptr(armmigrate.MachineBootTypeBIOS), + // ConfidenceRatingInPercentage: to.Ptr[float64](0), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:15.7789159Z"); return t}()), + // DatacenterMachineArmID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/abgoyal-westeurope/providers/microsoft.offazure/vmwaresites/portalvcenterbc2fsite/machines/idclab-a360-fareast-corp-micros-86617dcf-effe-59ad-8c3a-cdd3ea7300d3_50296915-8b4b-5c82-79a1-adf3966acb6b"), + // DatacenterManagementServerArmID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.OffAzure/VMwareSites/PortalvCenterbc2fsite/vcenters/idclab-a360-fareast-corp-micros-86617dcf-effe-59ad-8c3a-cdd3ea7300d3"), + // DatacenterManagementServerName: to.Ptr("IDCLAB-A360.fareast.corp.microsoft.com"), + // Disks: map[string]*armmigrate.AssessedDisk{ + // "6000C298-8305-5635-e618-3a8675c42495": &armmigrate.AssessedDisk{ + // Name: to.Ptr("6000C298-8305-5635-e618-3a8675c42495"), + // DisplayName: to.Ptr("scsi0:0"), + // GigabytesForRecommendedDiskSize: to.Ptr[int32](128), + // GigabytesProvisioned: to.Ptr[float64](80), + // MegabytesPerSecondOfRead: to.Ptr[float64](0), + // MegabytesPerSecondOfWrite: to.Ptr[float64](0), + // MonthlyStorageCost: to.Ptr[float64](5.888), + // NumberOfReadOperationsPerSecond: to.Ptr[float64](0), + // NumberOfWriteOperationsPerSecond: to.Ptr[float64](0), + // RecommendedDiskSize: to.Ptr(armmigrate.AzureDiskSizeStandardS10), + // RecommendedDiskType: to.Ptr(armmigrate.AzureDiskTypeStandard), + // Suitability: to.Ptr(armmigrate.CloudSuitabilitySuitable), + // SuitabilityDetail: to.Ptr(armmigrate.AzureDiskSuitabilityDetail("NumberOfReadOperationsPerSecondMissing, NumberOfWriteOperationsPerSecondMissing, MegabytesPerSecondOfReadMissing, MegabytesPerSecondOfWriteMissing")), + // SuitabilityExplanation: to.Ptr(armmigrate.AzureDiskSuitabilityExplanationNotApplicable), + // }, + // }, + // DisplayName: to.Ptr("testfpl1"), + // MegabytesOfMemory: to.Ptr[float64](16384), + // MegabytesOfMemoryForRecommendedSize: to.Ptr[float64](16384), + // MonthlyBandwidthCost: to.Ptr[float64](0), + // MonthlyComputeCostForRecommendedSize: to.Ptr[float64](101.138616), + // MonthlyPremiumStorageCost: to.Ptr[float64](0), + // MonthlyStandardSSDStorageCost: to.Ptr[float64](0), + // MonthlyStorageCost: to.Ptr[float64](5.888), + // NetworkAdapters: map[string]*armmigrate.AssessedNetworkAdapter{ + // "4000": &armmigrate.AssessedNetworkAdapter{ + // DisplayName: to.Ptr("VM Network"), + // IPAddresses: []*string{ + // }, + // MacAddress: to.Ptr("00:50:56:a9:35:ca"), + // MegabytesPerSecondReceived: to.Ptr[float64](0), + // MegabytesPerSecondTransmitted: to.Ptr[float64](0), + // MonthlyBandwidthCosts: to.Ptr[float64](0), + // NetGigabytesTransmittedPerMonth: to.Ptr[float64](0), + // Suitability: to.Ptr(armmigrate.CloudSuitabilitySuitable), + // SuitabilityDetail: to.Ptr(armmigrate.AzureNetworkAdapterSuitabilityDetailMegabytesOfDataTransmittedMissing), + // SuitabilityExplanation: to.Ptr(armmigrate.AzureNetworkAdapterSuitabilityExplanationNotApplicable), + // }, + // }, + // NumberOfCores: to.Ptr[int32](8), + // NumberOfCoresForRecommendedSize: to.Ptr[int32](8), + // OperatingSystemName: to.Ptr("Microsoft Windows Server 2016 (64-bit)"), + // OperatingSystemType: to.Ptr("windowsguest"), + // PercentageCoresUtilization: to.Ptr[float64](0), + // PercentageMemoryUtilization: to.Ptr[float64](0), + // RecommendedSize: to.Ptr(armmigrate.AzureVMSizeStandardF8SV2), + // Suitability: to.Ptr(armmigrate.CloudSuitabilitySuitable), + // SuitabilityDetail: to.Ptr(armmigrate.AzureVMSuitabilityDetail("PercentageOfCoresUtilizedMissing, PercentageOfMemoryUtilizedMissing")), + // SuitabilityExplanation: to.Ptr(armmigrate.AzureVMSuitabilityExplanationNotApplicable), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:15.7789159Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/AssessedMachines_Get.json +func ExampleAssessedMachinesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAssessedMachinesClient().Get(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "Test1", "assessment_5_9_2019_16_22_14", "f57fe432-3bd2-486a-a83a-6f4d99f1a952", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AssessedMachine = armmigrate.AssessedMachine{ + // Name: to.Ptr("f57fe432-3bd2-486a-a83a-6f4d99f1a952"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/groups/assessments/assessedMachines"), + // ETag: to.Ptr("\"b300e5dd-0000-0d00-0000-5cd4065f0000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Test1/assessments/assessment_5_9_2019_16_22_14/assessedMachines/f57fe432-3bd2-486a-a83a-6f4d99f1a952"), + // Properties: &armmigrate.AssessedMachineProperties{ + // Description: to.Ptr("Microsoft Azure Migration Image on Windows Server 2016"), + // BootType: to.Ptr(armmigrate.MachineBootTypeBIOS), + // ConfidenceRatingInPercentage: to.Ptr[float64](0), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:15.7789159Z"); return t}()), + // DatacenterMachineArmID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/abgoyal-westeurope/providers/microsoft.offazure/vmwaresites/portalvcenterbc2fsite/machines/idclab-a360-fareast-corp-micros-86617dcf-effe-59ad-8c3a-cdd3ea7300d3_52e1f68c-bea5-19ff-d0ad-6a94b79a286f"), + // DatacenterManagementServerArmID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.OffAzure/VMwareSites/PortalvCenterbc2fsite/vcenters/idclab-a360-fareast-corp-micros-86617dcf-effe-59ad-8c3a-cdd3ea7300d3"), + // DatacenterManagementServerName: to.Ptr("IDCLAB-A360.fareast.corp.microsoft.com"), + // Disks: map[string]*armmigrate.AssessedDisk{ + // "6000C299-02f5-d137-9bab-8a8ee7b192a0": &armmigrate.AssessedDisk{ + // Name: to.Ptr("6000C299-02f5-d137-9bab-8a8ee7b192a0"), + // DisplayName: to.Ptr("scsi0:0"), + // GigabytesForRecommendedDiskSize: to.Ptr[int32](128), + // GigabytesProvisioned: to.Ptr[float64](80), + // MegabytesPerSecondOfRead: to.Ptr[float64](0), + // MegabytesPerSecondOfWrite: to.Ptr[float64](0), + // MonthlyStorageCost: to.Ptr[float64](5.888), + // NumberOfReadOperationsPerSecond: to.Ptr[float64](0), + // NumberOfWriteOperationsPerSecond: to.Ptr[float64](0), + // RecommendedDiskSize: to.Ptr(armmigrate.AzureDiskSizeStandardS10), + // RecommendedDiskType: to.Ptr(armmigrate.AzureDiskTypeStandard), + // Suitability: to.Ptr(armmigrate.CloudSuitabilitySuitable), + // SuitabilityDetail: to.Ptr(armmigrate.AzureDiskSuitabilityDetail("NumberOfReadOperationsPerSecondMissing, NumberOfWriteOperationsPerSecondMissing, MegabytesPerSecondOfReadMissing, MegabytesPerSecondOfWriteMissing")), + // SuitabilityExplanation: to.Ptr(armmigrate.AzureDiskSuitabilityExplanationNotApplicable), + // }, + // }, + // DisplayName: to.Ptr("SHubhamVMNew"), + // MegabytesOfMemory: to.Ptr[float64](16384), + // MegabytesOfMemoryForRecommendedSize: to.Ptr[float64](16384), + // MonthlyBandwidthCost: to.Ptr[float64](0), + // MonthlyComputeCostForRecommendedSize: to.Ptr[float64](101.138616), + // MonthlyPremiumStorageCost: to.Ptr[float64](0), + // MonthlyStandardSSDStorageCost: to.Ptr[float64](0), + // MonthlyStorageCost: to.Ptr[float64](5.888), + // NetworkAdapters: map[string]*armmigrate.AssessedNetworkAdapter{ + // "4000": &armmigrate.AssessedNetworkAdapter{ + // DisplayName: to.Ptr("VM Network"), + // IPAddresses: []*string{ + // }, + // MacAddress: to.Ptr("00:0c:29:ad:13:d3"), + // MegabytesPerSecondReceived: to.Ptr[float64](0), + // MegabytesPerSecondTransmitted: to.Ptr[float64](0), + // MonthlyBandwidthCosts: to.Ptr[float64](0), + // NetGigabytesTransmittedPerMonth: to.Ptr[float64](0), + // Suitability: to.Ptr(armmigrate.CloudSuitabilitySuitable), + // SuitabilityDetail: to.Ptr(armmigrate.AzureNetworkAdapterSuitabilityDetailMegabytesOfDataTransmittedMissing), + // SuitabilityExplanation: to.Ptr(armmigrate.AzureNetworkAdapterSuitabilityExplanationNotApplicable), + // }, + // }, + // NumberOfCores: to.Ptr[int32](8), + // NumberOfCoresForRecommendedSize: to.Ptr[int32](8), + // OperatingSystemName: to.Ptr("Microsoft Windows Server 2016 (64-bit)"), + // OperatingSystemType: to.Ptr("windowsGuest"), + // PercentageCoresUtilization: to.Ptr[float64](0), + // PercentageMemoryUtilization: to.Ptr[float64](0), + // RecommendedSize: to.Ptr(armmigrate.AzureVMSizeStandardF8SV2), + // Suitability: to.Ptr(armmigrate.CloudSuitabilitySuitable), + // SuitabilityDetail: to.Ptr(armmigrate.AzureVMSuitabilityDetail("PercentageOfCoresUtilizedMissing, PercentageOfMemoryUtilizedMissing")), + // SuitabilityExplanation: to.Ptr(armmigrate.AzureVMSuitabilityExplanationNotApplicable), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:15.7789159Z"); return t}()), + // }, + // } +} diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_assessments_client.go b/sdk/resourcemanager/migrate/armmigrate/assessments_client.go similarity index 86% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_assessments_client.go rename to sdk/resourcemanager/migrate/armmigrate/assessments_client.go index 449dc423503d..b0f4a10052fb 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_assessments_client.go +++ b/sdk/resourcemanager/migrate/armmigrate/assessments_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 armmigrate @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,31 +24,22 @@ import ( // AssessmentsClient contains the methods for the Assessments group. // Don't use this type directly, use NewAssessmentsClient() instead. type AssessmentsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAssessmentsClient creates a new instance of AssessmentsClient with the specified values. -// subscriptionID - Azure Subscription Id in which project was created. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription Id in which project was created. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAssessmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssessmentsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AssessmentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AssessmentsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -64,18 +54,19 @@ func NewAssessmentsClient(subscriptionID string, credential azcore.TokenCredenti // 'computationState' will be updated to 'Ready', and then other PUT or DELETE operations can happen on the assessment. // When assessment is under computation, any PUT will lead to a 400 - Bad Request error. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// groupName - Unique name of a group within a project. -// assessmentName - Unique name of an assessment within a project. -// options - AssessmentsClientCreateOptions contains the optional parameters for the AssessmentsClient.Create method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - groupName - Unique name of a group within a project. +// - assessmentName - Unique name of an assessment within a project. +// - options - AssessmentsClientCreateOptions contains the optional parameters for the AssessmentsClient.Create method. func (client *AssessmentsClient) Create(ctx context.Context, resourceGroupName string, projectName string, groupName string, assessmentName string, options *AssessmentsClientCreateOptions) (AssessmentsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, projectName, groupName, assessmentName, options) if err != nil { return AssessmentsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsClientCreateResponse{}, err } @@ -108,7 +99,7 @@ func (client *AssessmentsClient) createCreateRequest(ctx context.Context, resour return nil, errors.New("parameter assessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assessmentName}", url.PathEscape(assessmentName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -139,18 +130,19 @@ func (client *AssessmentsClient) createHandleResponse(resp *http.Response) (Asse // When an assessment is under computation, as indicated by the 'computationState' field, it cannot be deleted. Any such attempt // will return a 400 - Bad Request. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// groupName - Unique name of a group within a project. -// assessmentName - Unique name of an assessment within a project. -// options - AssessmentsClientDeleteOptions contains the optional parameters for the AssessmentsClient.Delete method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - groupName - Unique name of a group within a project. +// - assessmentName - Unique name of an assessment within a project. +// - options - AssessmentsClientDeleteOptions contains the optional parameters for the AssessmentsClient.Delete method. func (client *AssessmentsClient) Delete(ctx context.Context, resourceGroupName string, projectName string, groupName string, assessmentName string, options *AssessmentsClientDeleteOptions) (AssessmentsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, projectName, groupName, assessmentName, options) if err != nil { return AssessmentsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsClientDeleteResponse{}, err } @@ -183,7 +175,7 @@ func (client *AssessmentsClient) deleteCreateRequest(ctx context.Context, resour return nil, errors.New("parameter assessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assessmentName}", url.PathEscape(assessmentName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -206,18 +198,19 @@ func (client *AssessmentsClient) deleteHandleResponse(resp *http.Response) (Asse // Get - Get an existing assessment with the specified name. Returns a json object of type 'assessment' as specified in Models // section. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// groupName - Unique name of a group within a project. -// assessmentName - Unique name of an assessment within a project. -// options - AssessmentsClientGetOptions contains the optional parameters for the AssessmentsClient.Get method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - groupName - Unique name of a group within a project. +// - assessmentName - Unique name of an assessment within a project. +// - options - AssessmentsClientGetOptions contains the optional parameters for the AssessmentsClient.Get method. func (client *AssessmentsClient) Get(ctx context.Context, resourceGroupName string, projectName string, groupName string, assessmentName string, options *AssessmentsClientGetOptions) (AssessmentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, projectName, groupName, assessmentName, options) if err != nil { return AssessmentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsClientGetResponse{}, err } @@ -250,7 +243,7 @@ func (client *AssessmentsClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter assessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assessmentName}", url.PathEscape(assessmentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -275,19 +268,20 @@ func (client *AssessmentsClient) getHandleResponse(resp *http.Response) (Assessm // GetReportDownloadURL - Get the URL for downloading the assessment in a report format. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// groupName - Unique name of a group within a project. -// assessmentName - Unique name of an assessment within a project. -// options - AssessmentsClientGetReportDownloadURLOptions contains the optional parameters for the AssessmentsClient.GetReportDownloadURL -// method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - groupName - Unique name of a group within a project. +// - assessmentName - Unique name of an assessment within a project. +// - options - AssessmentsClientGetReportDownloadURLOptions contains the optional parameters for the AssessmentsClient.GetReportDownloadURL +// method. func (client *AssessmentsClient) GetReportDownloadURL(ctx context.Context, resourceGroupName string, projectName string, groupName string, assessmentName string, options *AssessmentsClientGetReportDownloadURLOptions) (AssessmentsClientGetReportDownloadURLResponse, error) { req, err := client.getReportDownloadURLCreateRequest(ctx, resourceGroupName, projectName, groupName, assessmentName, options) if err != nil { return AssessmentsClientGetReportDownloadURLResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsClientGetReportDownloadURLResponse{}, err } @@ -320,7 +314,7 @@ func (client *AssessmentsClient) getReportDownloadURLCreateRequest(ctx context.C return nil, errors.New("parameter assessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assessmentName}", url.PathEscape(assessmentName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -345,12 +339,13 @@ func (client *AssessmentsClient) getReportDownloadURLHandleResponse(resp *http.R // NewListByGroupPager - Get all assessments created for the specified group. // Returns a json array of objects of type 'assessment' as specified in Models section. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// groupName - Unique name of a group within a project. -// options - AssessmentsClientListByGroupOptions contains the optional parameters for the AssessmentsClient.ListByGroup method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - groupName - Unique name of a group within a project. +// - options - AssessmentsClientListByGroupOptions contains the optional parameters for the AssessmentsClient.NewListByGroupPager +// method. func (client *AssessmentsClient) NewListByGroupPager(resourceGroupName string, projectName string, groupName string, options *AssessmentsClientListByGroupOptions) *runtime.Pager[AssessmentsClientListByGroupResponse] { return runtime.NewPager(runtime.PagingHandler[AssessmentsClientListByGroupResponse]{ More: func(page AssessmentsClientListByGroupResponse) bool { @@ -361,7 +356,7 @@ func (client *AssessmentsClient) NewListByGroupPager(resourceGroupName string, p if err != nil { return AssessmentsClientListByGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsClientListByGroupResponse{}, err } @@ -392,7 +387,7 @@ func (client *AssessmentsClient) listByGroupCreateRequest(ctx context.Context, r return nil, errors.New("parameter groupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{groupName}", url.PathEscape(groupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -417,12 +412,12 @@ func (client *AssessmentsClient) listByGroupHandleResponse(resp *http.Response) // NewListByProjectPager - Get all assessments created in the project. // Returns a json array of objects of type 'assessment' as specified in Models section. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// options - AssessmentsClientListByProjectOptions contains the optional parameters for the AssessmentsClient.ListByProject -// method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - options - AssessmentsClientListByProjectOptions contains the optional parameters for the AssessmentsClient.NewListByProjectPager +// method. func (client *AssessmentsClient) NewListByProjectPager(resourceGroupName string, projectName string, options *AssessmentsClientListByProjectOptions) *runtime.Pager[AssessmentsClientListByProjectResponse] { return runtime.NewPager(runtime.PagingHandler[AssessmentsClientListByProjectResponse]{ More: func(page AssessmentsClientListByProjectResponse) bool { @@ -433,7 +428,7 @@ func (client *AssessmentsClient) NewListByProjectPager(resourceGroupName string, if err != nil { return AssessmentsClientListByProjectResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsClientListByProjectResponse{}, err } @@ -460,7 +455,7 @@ func (client *AssessmentsClient) listByProjectCreateRequest(ctx context.Context, return nil, errors.New("parameter projectName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/migrate/armmigrate/assessments_client_example_test.go b/sdk/resourcemanager/migrate/armmigrate/assessments_client_example_test.go new file mode 100644 index 000000000000..97ac43f2539e --- /dev/null +++ b/sdk/resourcemanager/migrate/armmigrate/assessments_client_example_test.go @@ -0,0 +1,511 @@ +//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 armmigrate_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/migrate/armmigrate" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Assessments_ListByGroup.json +func ExampleAssessmentsClient_NewListByGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAssessmentsClient().NewListByGroupPager("abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "Test1", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AssessmentResultList = armmigrate.AssessmentResultList{ + // Value: []*armmigrate.Assessment{ + // { + // Name: to.Ptr("assessment_5_9_2019_16_22_14"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/groups/assessments"), + // ETag: to.Ptr("\"21009c31-0000-0d00-0000-5cd585ad0000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Test1/assessments/assessment_5_9_2019_16_22_14"), + // Properties: &armmigrate.AssessmentProperties{ + // AzureDiskType: to.Ptr(armmigrate.AzureDiskTypeStandardOrPremium), + // AzureHybridUseBenefit: to.Ptr(armmigrate.AzureHybridUseBenefitYes), + // AzureLocation: to.Ptr(armmigrate.AzureLocationNorthEurope), + // AzureOfferCode: to.Ptr(armmigrate.AzureOfferCodeMSAZR0003P), + // AzurePricingTier: to.Ptr(armmigrate.AzurePricingTierStandard), + // AzureStorageRedundancy: to.Ptr(armmigrate.AzureStorageRedundancyLocallyRedundant), + // AzureVMFamilies: []*armmigrate.AzureVMFamily{ + // to.Ptr(armmigrate.AzureVMFamilyDv2Series), + // to.Ptr(armmigrate.AzureVMFamilyFSeries), + // to.Ptr(armmigrate.AzureVMFamilyDv3Series), + // to.Ptr(armmigrate.AzureVMFamilyDSSeries), + // to.Ptr(armmigrate.AzureVMFamilyDSv2Series), + // to.Ptr(armmigrate.AzureVMFamilyFsSeries), + // to.Ptr(armmigrate.AzureVMFamilyDsv3Series), + // to.Ptr(armmigrate.AzureVMFamilyEv3Series), + // to.Ptr(armmigrate.AzureVMFamilyEsv3Series), + // to.Ptr(armmigrate.AzureVMFamilyDSeries), + // to.Ptr(armmigrate.AzureVMFamilyMSeries), + // to.Ptr(armmigrate.AzureVMFamilyFsv2Series), + // to.Ptr(armmigrate.AzureVMFamilyHSeries)}, + // ConfidenceRatingInPercentage: to.Ptr[float64](0), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:14.4896347Z"); return t}()), + // Currency: to.Ptr(armmigrate.CurrencyUSD), + // DiscountPercentage: to.Ptr[float64](0), + // MonthlyBandwidthCost: to.Ptr[float64](0), + // MonthlyComputeCost: to.Ptr[float64](2588.830584), + // MonthlyPremiumStorageCost: to.Ptr[float64](0), + // MonthlyStandardSSDStorageCost: to.Ptr[float64](0), + // MonthlyStorageCost: to.Ptr[float64](238.016), + // NumberOfMachines: to.Ptr[int32](26), + // Percentile: to.Ptr(armmigrate.PercentilePercentile95), + // PerfDataEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:14.4896347Z"); return t}()), + // PerfDataStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-08T10:52:14.4896347Z"); return t}()), + // PricesTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-26T11:07:37.139768Z"); return t}()), + // ReservedInstance: to.Ptr(armmigrate.ReservedInstanceRI3Year), + // ScalingFactor: to.Ptr[float64](1), + // SizingCriterion: to.Ptr(armmigrate.AssessmentSizingCriterionPerformanceBased), + // Stage: to.Ptr(armmigrate.AssessmentStageInProgress), + // Status: to.Ptr(armmigrate.AssessmentStatusOutDated), + // TimeRange: to.Ptr(armmigrate.TimeRangeDay), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:14.4896347Z"); return t}()), + // VMUptime: &armmigrate.VMUptime{ + // DaysPerMonth: to.Ptr[int32](31), + // HoursPerDay: to.Ptr[int32](24), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Assessments_ListByProject.json +func ExampleAssessmentsClient_NewListByProjectPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAssessmentsClient().NewListByProjectPager("abgoyal-westEurope", "abgoyalWEselfhostb72bproject", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AssessmentResultList = armmigrate.AssessmentResultList{ + // Value: []*armmigrate.Assessment{ + // { + // Name: to.Ptr("assessment_5_9_2019_16_22_14"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/groups/assessments"), + // ETag: to.Ptr("\"21009c31-0000-0d00-0000-5cd585ad0000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Test1/assessments/assessment_5_9_2019_16_22_14"), + // Properties: &armmigrate.AssessmentProperties{ + // AzureDiskType: to.Ptr(armmigrate.AzureDiskTypeStandardOrPremium), + // AzureHybridUseBenefit: to.Ptr(armmigrate.AzureHybridUseBenefitYes), + // AzureLocation: to.Ptr(armmigrate.AzureLocationNorthEurope), + // AzureOfferCode: to.Ptr(armmigrate.AzureOfferCodeMSAZR0003P), + // AzurePricingTier: to.Ptr(armmigrate.AzurePricingTierStandard), + // AzureStorageRedundancy: to.Ptr(armmigrate.AzureStorageRedundancyLocallyRedundant), + // AzureVMFamilies: []*armmigrate.AzureVMFamily{ + // to.Ptr(armmigrate.AzureVMFamilyDv2Series), + // to.Ptr(armmigrate.AzureVMFamilyFSeries), + // to.Ptr(armmigrate.AzureVMFamilyDv3Series), + // to.Ptr(armmigrate.AzureVMFamilyDSSeries), + // to.Ptr(armmigrate.AzureVMFamilyDSv2Series), + // to.Ptr(armmigrate.AzureVMFamilyFsSeries), + // to.Ptr(armmigrate.AzureVMFamilyDsv3Series), + // to.Ptr(armmigrate.AzureVMFamilyEv3Series), + // to.Ptr(armmigrate.AzureVMFamilyEsv3Series), + // to.Ptr(armmigrate.AzureVMFamilyDSeries), + // to.Ptr(armmigrate.AzureVMFamilyMSeries), + // to.Ptr(armmigrate.AzureVMFamilyFsv2Series), + // to.Ptr(armmigrate.AzureVMFamilyHSeries)}, + // ConfidenceRatingInPercentage: to.Ptr[float64](0), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:14.4896347Z"); return t}()), + // Currency: to.Ptr(armmigrate.CurrencyUSD), + // DiscountPercentage: to.Ptr[float64](0), + // MonthlyBandwidthCost: to.Ptr[float64](0), + // MonthlyComputeCost: to.Ptr[float64](2588.830584), + // MonthlyPremiumStorageCost: to.Ptr[float64](0), + // MonthlyStandardSSDStorageCost: to.Ptr[float64](0), + // MonthlyStorageCost: to.Ptr[float64](238.016), + // NumberOfMachines: to.Ptr[int32](26), + // Percentile: to.Ptr(armmigrate.PercentilePercentile95), + // PerfDataEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:14.4896347Z"); return t}()), + // PerfDataStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-08T10:52:14.4896347Z"); return t}()), + // PricesTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-26T11:07:37.139768Z"); return t}()), + // ReservedInstance: to.Ptr(armmigrate.ReservedInstanceRI3Year), + // ScalingFactor: to.Ptr[float64](1), + // SizingCriterion: to.Ptr(armmigrate.AssessmentSizingCriterionPerformanceBased), + // Stage: to.Ptr(armmigrate.AssessmentStageInProgress), + // Status: to.Ptr(armmigrate.AssessmentStatusOutDated), + // TimeRange: to.Ptr(armmigrate.TimeRangeDay), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:14.4896347Z"); return t}()), + // VMUptime: &armmigrate.VMUptime{ + // DaysPerMonth: to.Ptr[int32](31), + // HoursPerDay: to.Ptr[int32](24), + // }, + // }, + // }, + // { + // Name: to.Ptr("assessment_5_9_2019_17_0_56"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/groups/assessments"), + // ETag: to.Ptr("\"1e000c2c-0000-0d00-0000-5cdaa4190000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Group2/assessments/assessment_5_9_2019_17_0_56"), + // Properties: &armmigrate.AssessmentProperties{ + // AzureDiskType: to.Ptr(armmigrate.AzureDiskTypeStandardOrPremium), + // AzureHybridUseBenefit: to.Ptr(armmigrate.AzureHybridUseBenefitYes), + // AzureLocation: to.Ptr(armmigrate.AzureLocationNorthEurope), + // AzureOfferCode: to.Ptr(armmigrate.AzureOfferCodeMSAZR0003P), + // AzurePricingTier: to.Ptr(armmigrate.AzurePricingTierStandard), + // AzureStorageRedundancy: to.Ptr(armmigrate.AzureStorageRedundancyLocallyRedundant), + // AzureVMFamilies: []*armmigrate.AzureVMFamily{ + // to.Ptr(armmigrate.AzureVMFamilyDv2Series), + // to.Ptr(armmigrate.AzureVMFamilyFSeries), + // to.Ptr(armmigrate.AzureVMFamilyDv3Series), + // to.Ptr(armmigrate.AzureVMFamilyDSSeries), + // to.Ptr(armmigrate.AzureVMFamilyDSv2Series), + // to.Ptr(armmigrate.AzureVMFamilyFsSeries), + // to.Ptr(armmigrate.AzureVMFamilyDsv3Series), + // to.Ptr(armmigrate.AzureVMFamilyEv3Series), + // to.Ptr(armmigrate.AzureVMFamilyEsv3Series), + // to.Ptr(armmigrate.AzureVMFamilyDSeries), + // to.Ptr(armmigrate.AzureVMFamilyMSeries), + // to.Ptr(armmigrate.AzureVMFamilyFsv2Series), + // to.Ptr(armmigrate.AzureVMFamilyHSeries)}, + // ConfidenceRatingInPercentage: to.Ptr[float64](0), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T11:30:57.0035869Z"); return t}()), + // Currency: to.Ptr(armmigrate.CurrencyUSD), + // DiscountPercentage: to.Ptr[float64](0), + // MonthlyBandwidthCost: to.Ptr[float64](0), + // MonthlyComputeCost: to.Ptr[float64](607.443264), + // MonthlyPremiumStorageCost: to.Ptr[float64](0), + // MonthlyStandardSSDStorageCost: to.Ptr[float64](0), + // MonthlyStorageCost: to.Ptr[float64](111.36), + // NumberOfMachines: to.Ptr[int32](5), + // Percentile: to.Ptr(armmigrate.PercentilePercentile95), + // PerfDataEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T11:30:57.0035869Z"); return t}()), + // PerfDataStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-08T11:30:57.0035869Z"); return t}()), + // PricesTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-26T11:07:37.139768Z"); return t}()), + // ReservedInstance: to.Ptr(armmigrate.ReservedInstanceRI3Year), + // ScalingFactor: to.Ptr[float64](1), + // SizingCriterion: to.Ptr(armmigrate.AssessmentSizingCriterionPerformanceBased), + // Stage: to.Ptr(armmigrate.AssessmentStageInProgress), + // Status: to.Ptr(armmigrate.AssessmentStatusCompleted), + // TimeRange: to.Ptr(armmigrate.TimeRangeDay), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T11:30:57.0035869Z"); return t}()), + // VMUptime: &armmigrate.VMUptime{ + // DaysPerMonth: to.Ptr[int32](31), + // HoursPerDay: to.Ptr[int32](24), + // }, + // }, + // }, + // { + // Name: to.Ptr("assessment_5_14_2019_16_48_47"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/groups/assessments"), + // ETag: to.Ptr("\"1e000c2c-0000-0d00-0000-5cdaa4190000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Group2/assessments/assessment_5_14_2019_16_48_47"), + // Properties: &armmigrate.AssessmentProperties{ + // AzureDiskType: to.Ptr(armmigrate.AzureDiskTypeStandardOrPremium), + // AzureHybridUseBenefit: to.Ptr(armmigrate.AzureHybridUseBenefitYes), + // AzureLocation: to.Ptr(armmigrate.AzureLocationNorthEurope), + // AzureOfferCode: to.Ptr(armmigrate.AzureOfferCodeMSAZR0003P), + // AzurePricingTier: to.Ptr(armmigrate.AzurePricingTierStandard), + // AzureStorageRedundancy: to.Ptr(armmigrate.AzureStorageRedundancyLocallyRedundant), + // AzureVMFamilies: []*armmigrate.AzureVMFamily{ + // to.Ptr(armmigrate.AzureVMFamilyDv2Series), + // to.Ptr(armmigrate.AzureVMFamilyFSeries), + // to.Ptr(armmigrate.AzureVMFamilyDv3Series), + // to.Ptr(armmigrate.AzureVMFamilyDSSeries), + // to.Ptr(armmigrate.AzureVMFamilyDSv2Series), + // to.Ptr(armmigrate.AzureVMFamilyFsSeries), + // to.Ptr(armmigrate.AzureVMFamilyDsv3Series), + // to.Ptr(armmigrate.AzureVMFamilyEv3Series), + // to.Ptr(armmigrate.AzureVMFamilyEsv3Series), + // to.Ptr(armmigrate.AzureVMFamilyDSeries), + // to.Ptr(armmigrate.AzureVMFamilyMSeries), + // to.Ptr(armmigrate.AzureVMFamilyFsv2Series), + // to.Ptr(armmigrate.AzureVMFamilyHSeries)}, + // ConfidenceRatingInPercentage: to.Ptr[float64](0), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-14T11:18:47.7893715Z"); return t}()), + // Currency: to.Ptr(armmigrate.CurrencyUSD), + // DiscountPercentage: to.Ptr[float64](0), + // MonthlyBandwidthCost: to.Ptr[float64](0), + // MonthlyComputeCost: to.Ptr[float64](607.443264), + // MonthlyPremiumStorageCost: to.Ptr[float64](0), + // MonthlyStandardSSDStorageCost: to.Ptr[float64](0), + // MonthlyStorageCost: to.Ptr[float64](111.36), + // NumberOfMachines: to.Ptr[int32](5), + // Percentile: to.Ptr(armmigrate.PercentilePercentile95), + // PerfDataEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-14T11:18:47.7893715Z"); return t}()), + // PerfDataStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-13T11:18:47.7893715Z"); return t}()), + // PricesTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-26T11:07:37.139768Z"); return t}()), + // ReservedInstance: to.Ptr(armmigrate.ReservedInstanceRI3Year), + // ScalingFactor: to.Ptr[float64](1), + // SizingCriterion: to.Ptr(armmigrate.AssessmentSizingCriterionPerformanceBased), + // Stage: to.Ptr(armmigrate.AssessmentStageInProgress), + // Status: to.Ptr(armmigrate.AssessmentStatusCompleted), + // TimeRange: to.Ptr(armmigrate.TimeRangeDay), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-14T11:18:47.7893715Z"); return t}()), + // VMUptime: &armmigrate.VMUptime{ + // DaysPerMonth: to.Ptr[int32](31), + // HoursPerDay: to.Ptr[int32](24), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Assessments_Get.json +func ExampleAssessmentsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAssessmentsClient().Get(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "Test1", "assessment_5_9_2019_16_22_14", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Assessment = armmigrate.Assessment{ + // Name: to.Ptr("assessment_5_9_2019_16_22_14"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/groups/assessments"), + // ETag: to.Ptr("\"21009c31-0000-0d00-0000-5cd585ad0000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Test1/assessments/assessment_5_9_2019_16_22_14"), + // Properties: &armmigrate.AssessmentProperties{ + // AzureDiskType: to.Ptr(armmigrate.AzureDiskTypeStandardOrPremium), + // AzureHybridUseBenefit: to.Ptr(armmigrate.AzureHybridUseBenefitYes), + // AzureLocation: to.Ptr(armmigrate.AzureLocationNorthEurope), + // AzureOfferCode: to.Ptr(armmigrate.AzureOfferCodeMSAZR0003P), + // AzurePricingTier: to.Ptr(armmigrate.AzurePricingTierStandard), + // AzureStorageRedundancy: to.Ptr(armmigrate.AzureStorageRedundancyLocallyRedundant), + // AzureVMFamilies: []*armmigrate.AzureVMFamily{ + // to.Ptr(armmigrate.AzureVMFamilyDv2Series), + // to.Ptr(armmigrate.AzureVMFamilyFSeries), + // to.Ptr(armmigrate.AzureVMFamilyDv3Series), + // to.Ptr(armmigrate.AzureVMFamilyDSSeries), + // to.Ptr(armmigrate.AzureVMFamilyDSv2Series), + // to.Ptr(armmigrate.AzureVMFamilyFsSeries), + // to.Ptr(armmigrate.AzureVMFamilyDsv3Series), + // to.Ptr(armmigrate.AzureVMFamilyEv3Series), + // to.Ptr(armmigrate.AzureVMFamilyEsv3Series), + // to.Ptr(armmigrate.AzureVMFamilyDSeries), + // to.Ptr(armmigrate.AzureVMFamilyMSeries), + // to.Ptr(armmigrate.AzureVMFamilyFsv2Series), + // to.Ptr(armmigrate.AzureVMFamilyHSeries)}, + // ConfidenceRatingInPercentage: to.Ptr[float64](0), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:14.4896347Z"); return t}()), + // Currency: to.Ptr(armmigrate.CurrencyUSD), + // DiscountPercentage: to.Ptr[float64](0), + // MonthlyBandwidthCost: to.Ptr[float64](0), + // MonthlyComputeCost: to.Ptr[float64](2588.830584), + // MonthlyPremiumStorageCost: to.Ptr[float64](0), + // MonthlyStandardSSDStorageCost: to.Ptr[float64](0), + // MonthlyStorageCost: to.Ptr[float64](238.016), + // NumberOfMachines: to.Ptr[int32](26), + // Percentile: to.Ptr(armmigrate.PercentilePercentile95), + // PerfDataEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:14.4896347Z"); return t}()), + // PerfDataStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-08T10:52:14.4896347Z"); return t}()), + // PricesTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-26T11:07:37.139768Z"); return t}()), + // ReservedInstance: to.Ptr(armmigrate.ReservedInstanceRI3Year), + // ScalingFactor: to.Ptr[float64](1), + // SizingCriterion: to.Ptr(armmigrate.AssessmentSizingCriterionPerformanceBased), + // Stage: to.Ptr(armmigrate.AssessmentStageInProgress), + // Status: to.Ptr(armmigrate.AssessmentStatusOutDated), + // TimeRange: to.Ptr(armmigrate.TimeRangeDay), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:14.4896347Z"); return t}()), + // VMUptime: &armmigrate.VMUptime{ + // DaysPerMonth: to.Ptr[int32](31), + // HoursPerDay: to.Ptr[int32](24), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Assessments_Create.json +func ExampleAssessmentsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAssessmentsClient().Create(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "Group2", "assessment_5_14_2019_16_48_47", &armmigrate.AssessmentsClientCreateOptions{Assessment: &armmigrate.Assessment{ + ETag: to.Ptr("\"1e000c2c-0000-0d00-0000-5cdaa4190000\""), + Properties: &armmigrate.AssessmentProperties{ + AzureDiskType: to.Ptr(armmigrate.AzureDiskTypeStandardOrPremium), + AzureHybridUseBenefit: to.Ptr(armmigrate.AzureHybridUseBenefitYes), + AzureLocation: to.Ptr(armmigrate.AzureLocationNorthEurope), + AzureOfferCode: to.Ptr(armmigrate.AzureOfferCodeMSAZR0003P), + AzurePricingTier: to.Ptr(armmigrate.AzurePricingTierStandard), + AzureStorageRedundancy: to.Ptr(armmigrate.AzureStorageRedundancyLocallyRedundant), + AzureVMFamilies: []*armmigrate.AzureVMFamily{ + to.Ptr(armmigrate.AzureVMFamilyDv2Series), + to.Ptr(armmigrate.AzureVMFamilyFSeries), + to.Ptr(armmigrate.AzureVMFamilyDv3Series), + to.Ptr(armmigrate.AzureVMFamilyDSSeries), + to.Ptr(armmigrate.AzureVMFamilyDSv2Series), + to.Ptr(armmigrate.AzureVMFamilyFsSeries), + to.Ptr(armmigrate.AzureVMFamilyDsv3Series), + to.Ptr(armmigrate.AzureVMFamilyEv3Series), + to.Ptr(armmigrate.AzureVMFamilyEsv3Series), + to.Ptr(armmigrate.AzureVMFamilyDSeries), + to.Ptr(armmigrate.AzureVMFamilyMSeries), + to.Ptr(armmigrate.AzureVMFamilyFsv2Series), + to.Ptr(armmigrate.AzureVMFamilyHSeries)}, + Currency: to.Ptr(armmigrate.CurrencyUSD), + DiscountPercentage: to.Ptr[float64](100), + Percentile: to.Ptr(armmigrate.PercentilePercentile95), + ReservedInstance: to.Ptr(armmigrate.ReservedInstanceRI3Year), + ScalingFactor: to.Ptr[float64](1), + SizingCriterion: to.Ptr(armmigrate.AssessmentSizingCriterionPerformanceBased), + Stage: to.Ptr(armmigrate.AssessmentStageInProgress), + TimeRange: to.Ptr(armmigrate.TimeRangeDay), + VMUptime: &armmigrate.VMUptime{ + DaysPerMonth: to.Ptr[int32](31), + HoursPerDay: to.Ptr[int32](24), + }, + }, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Assessment = armmigrate.Assessment{ + // Name: to.Ptr("assessment_5_14_2019_16_48_47"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/groups/assessments"), + // ETag: to.Ptr("\"1e000c2c-0000-0d00-0000-5cdaa4190000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Group2/assessments/assessment_5_14_2019_16_48_47"), + // Properties: &armmigrate.AssessmentProperties{ + // AzureDiskType: to.Ptr(armmigrate.AzureDiskTypeStandardOrPremium), + // AzureHybridUseBenefit: to.Ptr(armmigrate.AzureHybridUseBenefitYes), + // AzureLocation: to.Ptr(armmigrate.AzureLocationNorthEurope), + // AzureOfferCode: to.Ptr(armmigrate.AzureOfferCodeMSAZR0003P), + // AzurePricingTier: to.Ptr(armmigrate.AzurePricingTierStandard), + // AzureStorageRedundancy: to.Ptr(armmigrate.AzureStorageRedundancyLocallyRedundant), + // AzureVMFamilies: []*armmigrate.AzureVMFamily{ + // to.Ptr(armmigrate.AzureVMFamilyDv2Series), + // to.Ptr(armmigrate.AzureVMFamilyFSeries), + // to.Ptr(armmigrate.AzureVMFamilyDv3Series), + // to.Ptr(armmigrate.AzureVMFamilyDSSeries), + // to.Ptr(armmigrate.AzureVMFamilyDSv2Series), + // to.Ptr(armmigrate.AzureVMFamilyFsSeries), + // to.Ptr(armmigrate.AzureVMFamilyDsv3Series), + // to.Ptr(armmigrate.AzureVMFamilyEv3Series), + // to.Ptr(armmigrate.AzureVMFamilyEsv3Series), + // to.Ptr(armmigrate.AzureVMFamilyDSeries), + // to.Ptr(armmigrate.AzureVMFamilyMSeries), + // to.Ptr(armmigrate.AzureVMFamilyFsv2Series), + // to.Ptr(armmigrate.AzureVMFamilyHSeries)}, + // ConfidenceRatingInPercentage: to.Ptr[float64](0), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-14T11:18:47.7893715Z"); return t}()), + // Currency: to.Ptr(armmigrate.CurrencyUSD), + // DiscountPercentage: to.Ptr[float64](0), + // MonthlyBandwidthCost: to.Ptr[float64](0), + // MonthlyComputeCost: to.Ptr[float64](607.443264), + // MonthlyPremiumStorageCost: to.Ptr[float64](0), + // MonthlyStandardSSDStorageCost: to.Ptr[float64](0), + // MonthlyStorageCost: to.Ptr[float64](111.36), + // NumberOfMachines: to.Ptr[int32](5), + // Percentile: to.Ptr(armmigrate.PercentilePercentile95), + // PerfDataEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-14T11:18:47.7893715Z"); return t}()), + // PerfDataStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-13T11:18:47.7893715Z"); return t}()), + // PricesTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-26T11:07:37.139768Z"); return t}()), + // ReservedInstance: to.Ptr(armmigrate.ReservedInstanceRI3Year), + // ScalingFactor: to.Ptr[float64](1), + // SizingCriterion: to.Ptr(armmigrate.AssessmentSizingCriterionPerformanceBased), + // Stage: to.Ptr(armmigrate.AssessmentStageInProgress), + // Status: to.Ptr(armmigrate.AssessmentStatusCompleted), + // TimeRange: to.Ptr(armmigrate.TimeRangeDay), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-14T11:18:47.7893715Z"); return t}()), + // VMUptime: &armmigrate.VMUptime{ + // DaysPerMonth: to.Ptr[int32](31), + // HoursPerDay: to.Ptr[int32](24), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Assessments_Delete.json +func ExampleAssessmentsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewAssessmentsClient().Delete(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "Test1", "assessment_5_9_2019_16_22_14", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Assessments_GetReportDownloadUrl.json +func ExampleAssessmentsClient_GetReportDownloadURL() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAssessmentsClient().GetReportDownloadURL(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "Test1", "assessment_5_9_2019_16_22_14", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DownloadURL = armmigrate.DownloadURL{ + // AssessmentReportURL: to.Ptr("link-to-download-assessment-report"), + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-05T13:17:23.5437337Z"); return t}()), + // } +} diff --git a/sdk/resourcemanager/migrate/armmigrate/autorest.md b/sdk/resourcemanager/migrate/armmigrate/autorest.md index e4d09bdf6b21..8d09f2870aa2 100644 --- a/sdk/resourcemanager/migrate/armmigrate/autorest.md +++ b/sdk/resourcemanager/migrate/armmigrate/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/migrate/armmigrate/client_factory.go b/sdk/resourcemanager/migrate/armmigrate/client_factory.go new file mode 100644 index 000000000000..92223dcb1631 --- /dev/null +++ b/sdk/resourcemanager/migrate/armmigrate/client_factory.go @@ -0,0 +1,99 @@ +//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 armmigrate + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - Azure Subscription Id in which project was created. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewProjectsClient() *ProjectsClient { + subClient, _ := NewProjectsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewMachinesClient() *MachinesClient { + subClient, _ := NewMachinesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewGroupsClient() *GroupsClient { + subClient, _ := NewGroupsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAssessmentsClient() *AssessmentsClient { + subClient, _ := NewAssessmentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAssessedMachinesClient() *AssessedMachinesClient { + subClient, _ := NewAssessedMachinesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewHyperVCollectorsClient() *HyperVCollectorsClient { + subClient, _ := NewHyperVCollectorsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewServerCollectorsClient() *ServerCollectorsClient { + subClient, _ := NewServerCollectorsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVMwareCollectorsClient() *VMwareCollectorsClient { + subClient, _ := NewVMwareCollectorsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewImportCollectorsClient() *ImportCollectorsClient { + subClient, _ := NewImportCollectorsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPrivateEndpointConnectionClient() *PrivateEndpointConnectionClient { + subClient, _ := NewPrivateEndpointConnectionClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPrivateLinkResourceClient() *PrivateLinkResourceClient { + subClient, _ := NewPrivateLinkResourceClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_constants.go b/sdk/resourcemanager/migrate/armmigrate/constants.go similarity index 99% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_constants.go rename to sdk/resourcemanager/migrate/armmigrate/constants.go index 54fc29e53eeb..549da8bc520f 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_constants.go +++ b/sdk/resourcemanager/migrate/armmigrate/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 armmigrate const ( moduleName = "armmigrate" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // AssessmentSizingCriterion - Assessment sizing criterion. diff --git a/sdk/resourcemanager/migrate/armmigrate/go.mod b/sdk/resourcemanager/migrate/armmigrate/go.mod index 819cb999087f..f201c719329a 100644 --- a/sdk/resourcemanager/migrate/armmigrate/go.mod +++ b/sdk/resourcemanager/migrate/armmigrate/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/migrate/armmigrate 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.1.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/migrate/armmigrate/go.sum b/sdk/resourcemanager/migrate/armmigrate/go.sum index 8828b17b1853..8ba445a8c4da 100644 --- a/sdk/resourcemanager/migrate/armmigrate/go.sum +++ b/sdk/resourcemanager/migrate/armmigrate/go.sum @@ -1,33 +1,31 @@ -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.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= -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.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= 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/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_groups_client.go b/sdk/resourcemanager/migrate/armmigrate/groups_client.go similarity index 85% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_groups_client.go rename to sdk/resourcemanager/migrate/armmigrate/groups_client.go index 550ecdeae494..a57a342b5d10 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_groups_client.go +++ b/sdk/resourcemanager/migrate/armmigrate/groups_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 armmigrate @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,31 +24,22 @@ import ( // GroupsClient contains the methods for the Groups group. // Don't use this type directly, use NewGroupsClient() instead. type GroupsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewGroupsClient creates a new instance of GroupsClient with the specified values. -// subscriptionID - Azure Subscription Id in which project was created. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription Id in which project was created. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewGroupsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GroupsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".GroupsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &GroupsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,17 +48,18 @@ func NewGroupsClient(subscriptionID string, credential azcore.TokenCredential, o // Body. The group name in a project is unique. // This operation is Idempotent. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// groupName - Unique name of a group within a project. -// options - GroupsClientCreateOptions contains the optional parameters for the GroupsClient.Create method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - groupName - Unique name of a group within a project. +// - options - GroupsClientCreateOptions contains the optional parameters for the GroupsClient.Create method. func (client *GroupsClient) Create(ctx context.Context, resourceGroupName string, projectName string, groupName string, options *GroupsClientCreateOptions) (GroupsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, projectName, groupName, options) if err != nil { return GroupsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GroupsClientCreateResponse{}, err } @@ -97,7 +88,7 @@ func (client *GroupsClient) createCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter groupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{groupName}", url.PathEscape(groupName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -127,17 +118,18 @@ func (client *GroupsClient) createHandleResponse(resp *http.Response) (GroupsCli // a no-operation. // A group is an aggregation mechanism for machines in a project. Therefore, deleting group does not delete machines in it. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// groupName - Unique name of a group within a project. -// options - GroupsClientDeleteOptions contains the optional parameters for the GroupsClient.Delete method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - groupName - Unique name of a group within a project. +// - options - GroupsClientDeleteOptions contains the optional parameters for the GroupsClient.Delete method. func (client *GroupsClient) Delete(ctx context.Context, resourceGroupName string, projectName string, groupName string, options *GroupsClientDeleteOptions) (GroupsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, projectName, groupName, options) if err != nil { return GroupsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GroupsClientDeleteResponse{}, err } @@ -166,7 +158,7 @@ func (client *GroupsClient) deleteCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter groupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{groupName}", url.PathEscape(groupName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -189,17 +181,18 @@ func (client *GroupsClient) deleteHandleResponse(resp *http.Response) (GroupsCli // Get - Get information related to a specific group in the project. Returns a json object of type 'group' as specified in // the models section. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// groupName - Unique name of a group within a project. -// options - GroupsClientGetOptions contains the optional parameters for the GroupsClient.Get method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - groupName - Unique name of a group within a project. +// - options - GroupsClientGetOptions contains the optional parameters for the GroupsClient.Get method. func (client *GroupsClient) Get(ctx context.Context, resourceGroupName string, projectName string, groupName string, options *GroupsClientGetOptions) (GroupsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, projectName, groupName, options) if err != nil { return GroupsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GroupsClientGetResponse{}, err } @@ -228,7 +221,7 @@ func (client *GroupsClient) getCreateRequest(ctx context.Context, resourceGroupN return nil, errors.New("parameter groupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{groupName}", url.PathEscape(groupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -253,11 +246,12 @@ func (client *GroupsClient) getHandleResponse(resp *http.Response) (GroupsClient // NewListByProjectPager - Get all groups created in the project. Returns a json array of objects of type 'group' as specified // in the Models section. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// options - GroupsClientListByProjectOptions contains the optional parameters for the GroupsClient.ListByProject method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - options - GroupsClientListByProjectOptions contains the optional parameters for the GroupsClient.NewListByProjectPager +// method. func (client *GroupsClient) NewListByProjectPager(resourceGroupName string, projectName string, options *GroupsClientListByProjectOptions) *runtime.Pager[GroupsClientListByProjectResponse] { return runtime.NewPager(runtime.PagingHandler[GroupsClientListByProjectResponse]{ More: func(page GroupsClientListByProjectResponse) bool { @@ -268,7 +262,7 @@ func (client *GroupsClient) NewListByProjectPager(resourceGroupName string, proj if err != nil { return GroupsClientListByProjectResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GroupsClientListByProjectResponse{}, err } @@ -295,7 +289,7 @@ func (client *GroupsClient) listByProjectCreateRequest(ctx context.Context, reso return nil, errors.New("parameter projectName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -320,17 +314,18 @@ func (client *GroupsClient) listByProjectHandleResponse(resp *http.Response) (Gr // UpdateMachines - Update machines in group by adding or removing machines. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// groupName - Unique name of a group within a project. -// options - GroupsClientUpdateMachinesOptions contains the optional parameters for the GroupsClient.UpdateMachines method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - groupName - Unique name of a group within a project. +// - options - GroupsClientUpdateMachinesOptions contains the optional parameters for the GroupsClient.UpdateMachines method. func (client *GroupsClient) UpdateMachines(ctx context.Context, resourceGroupName string, projectName string, groupName string, options *GroupsClientUpdateMachinesOptions) (GroupsClientUpdateMachinesResponse, error) { req, err := client.updateMachinesCreateRequest(ctx, resourceGroupName, projectName, groupName, options) if err != nil { return GroupsClientUpdateMachinesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GroupsClientUpdateMachinesResponse{}, err } @@ -359,7 +354,7 @@ func (client *GroupsClient) updateMachinesCreateRequest(ctx context.Context, res return nil, errors.New("parameter groupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{groupName}", url.PathEscape(groupName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/migrate/armmigrate/groups_client_example_test.go b/sdk/resourcemanager/migrate/armmigrate/groups_client_example_test.go new file mode 100644 index 000000000000..9ead9f896f6e --- /dev/null +++ b/sdk/resourcemanager/migrate/armmigrate/groups_client_example_test.go @@ -0,0 +1,204 @@ +//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 armmigrate_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/migrate/armmigrate" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Groups_ListByProject.json +func ExampleGroupsClient_NewListByProjectPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewGroupsClient().NewListByProjectPager("abgoyal-westEurope", "abgoyalWEselfhostb72bproject", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.GroupResultList = armmigrate.GroupResultList{ + // Value: []*armmigrate.Group{ + // { + // Name: to.Ptr("Test1"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/groups"), + // ETag: to.Ptr("\"21009c31-0000-0d00-0000-5cd585ad0000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Test1"), + // Properties: &armmigrate.GroupProperties{ + // AreAssessmentsRunning: to.Ptr(false), + // Assessments: []*string{ + // to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Test1/assessments/assessment_5_9_2019_16_22_14")}, + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:07.7368474Z"); return t}()), + // GroupStatus: to.Ptr(armmigrate.GroupStatusCompleted), + // MachineCount: to.Ptr[int32](26), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-10T14:07:41.752989Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("Group2"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/groups"), + // ETag: to.Ptr("\"1e000c2c-0000-0d00-0000-5cdaa4190000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Group2"), + // Properties: &armmigrate.GroupProperties{ + // AreAssessmentsRunning: to.Ptr(false), + // Assessments: []*string{ + // to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Group2/assessments/assessment_5_9_2019_17_0_56"), + // to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Group2/assessments/assessment_5_14_2019_16_48_47")}, + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:56.1574737Z"); return t}()), + // GroupStatus: to.Ptr(armmigrate.GroupStatusCompleted), + // MachineCount: to.Ptr[int32](5), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-14T11:18:49.5485462Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Groups_Get.json +func ExampleGroupsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewGroupsClient().Get(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "Test1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Group = armmigrate.Group{ + // Name: to.Ptr("Test1"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/groups"), + // ETag: to.Ptr("\"21009c31-0000-0d00-0000-5cd585ad0000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Test1"), + // Properties: &armmigrate.GroupProperties{ + // AreAssessmentsRunning: to.Ptr(false), + // Assessments: []*string{ + // to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Test1/assessments/assessment_5_9_2019_16_22_14")}, + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:07.7368474Z"); return t}()), + // GroupStatus: to.Ptr(armmigrate.GroupStatusCompleted), + // MachineCount: to.Ptr[int32](26), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-10T14:07:41.752989Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Groups_Create.json +func ExampleGroupsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewGroupsClient().Create(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "Group2", &armmigrate.GroupsClientCreateOptions{Group: &armmigrate.Group{ + ETag: to.Ptr("\"1e000c2c-0000-0d00-0000-5cdaa4190000\""), + Properties: &armmigrate.GroupProperties{}, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Group = armmigrate.Group{ + // Name: to.Ptr("Group2"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/groups"), + // ETag: to.Ptr("\"1e000c2c-0000-0d00-0000-5cdaa4190000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Group2"), + // Properties: &armmigrate.GroupProperties{ + // AreAssessmentsRunning: to.Ptr(false), + // Assessments: []*string{ + // }, + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:56.1574737Z"); return t}()), + // GroupStatus: to.Ptr(armmigrate.GroupStatusCompleted), + // MachineCount: to.Ptr[int32](0), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-14T11:18:49.5485462Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Groups_Delete.json +func ExampleGroupsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewGroupsClient().Delete(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "Test1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Groups_UpdateMachines.json +func ExampleGroupsClient_UpdateMachines() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewGroupsClient().UpdateMachines(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "Group2", &armmigrate.GroupsClientUpdateMachinesOptions{GroupUpdateProperties: nil}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Group = armmigrate.Group{ + // Name: to.Ptr("Group2"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/groups"), + // ETag: to.Ptr("\"1e000c2c-0000-0d00-0000-5cdaa4190000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Test1"), + // Properties: &armmigrate.GroupProperties{ + // AreAssessmentsRunning: to.Ptr(false), + // Assessments: []*string{ + // to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/Test1/assessments/assessment_5_9_2019_16_22_14")}, + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:52:07.7368474Z"); return t}()), + // GroupStatus: to.Ptr(armmigrate.GroupStatusCompleted), + // MachineCount: to.Ptr[int32](26), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-10T14:07:41.752989Z"); return t}()), + // }, + // } +} diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_hypervcollectors_client.go b/sdk/resourcemanager/migrate/armmigrate/hypervcollectors_client.go similarity index 84% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_hypervcollectors_client.go rename to sdk/resourcemanager/migrate/armmigrate/hypervcollectors_client.go index 6a4c6dd37ae2..97fb22b05610 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_hypervcollectors_client.go +++ b/sdk/resourcemanager/migrate/armmigrate/hypervcollectors_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 armmigrate @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // HyperVCollectorsClient contains the methods for the HyperVCollectors group. // Don't use this type directly, use NewHyperVCollectorsClient() instead. type HyperVCollectorsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewHyperVCollectorsClient creates a new instance of HyperVCollectorsClient with the specified values. -// subscriptionID - Azure Subscription Id in which project was created. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription Id in which project was created. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewHyperVCollectorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*HyperVCollectorsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".HyperVCollectorsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &HyperVCollectorsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Create or Update Hyper-V collector // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// hyperVCollectorName - Unique name of a Hyper-V collector within a project. -// options - HyperVCollectorsClientCreateOptions contains the optional parameters for the HyperVCollectorsClient.Create method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - hyperVCollectorName - Unique name of a Hyper-V collector within a project. +// - options - HyperVCollectorsClientCreateOptions contains the optional parameters for the HyperVCollectorsClient.Create method. func (client *HyperVCollectorsClient) Create(ctx context.Context, resourceGroupName string, projectName string, hyperVCollectorName string, options *HyperVCollectorsClientCreateOptions) (HyperVCollectorsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, projectName, hyperVCollectorName, options) if err != nil { return HyperVCollectorsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HyperVCollectorsClientCreateResponse{}, err } @@ -95,7 +86,7 @@ func (client *HyperVCollectorsClient) createCreateRequest(ctx context.Context, r return nil, errors.New("parameter hyperVCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{hyperVCollectorName}", url.PathEscape(hyperVCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -123,17 +114,18 @@ func (client *HyperVCollectorsClient) createHandleResponse(resp *http.Response) // Delete - Delete a Hyper-V collector from the project. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// hyperVCollectorName - Unique name of a Hyper-V collector within a project. -// options - HyperVCollectorsClientDeleteOptions contains the optional parameters for the HyperVCollectorsClient.Delete method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - hyperVCollectorName - Unique name of a Hyper-V collector within a project. +// - options - HyperVCollectorsClientDeleteOptions contains the optional parameters for the HyperVCollectorsClient.Delete method. func (client *HyperVCollectorsClient) Delete(ctx context.Context, resourceGroupName string, projectName string, hyperVCollectorName string, options *HyperVCollectorsClientDeleteOptions) (HyperVCollectorsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, projectName, hyperVCollectorName, options) if err != nil { return HyperVCollectorsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HyperVCollectorsClientDeleteResponse{}, err } @@ -162,7 +154,7 @@ func (client *HyperVCollectorsClient) deleteCreateRequest(ctx context.Context, r return nil, errors.New("parameter hyperVCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{hyperVCollectorName}", url.PathEscape(hyperVCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -184,17 +176,18 @@ func (client *HyperVCollectorsClient) deleteHandleResponse(resp *http.Response) // Get - Get a Hyper-V collector. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// hyperVCollectorName - Unique name of a Hyper-V collector within a project. -// options - HyperVCollectorsClientGetOptions contains the optional parameters for the HyperVCollectorsClient.Get method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - hyperVCollectorName - Unique name of a Hyper-V collector within a project. +// - options - HyperVCollectorsClientGetOptions contains the optional parameters for the HyperVCollectorsClient.Get method. func (client *HyperVCollectorsClient) Get(ctx context.Context, resourceGroupName string, projectName string, hyperVCollectorName string, options *HyperVCollectorsClientGetOptions) (HyperVCollectorsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, projectName, hyperVCollectorName, options) if err != nil { return HyperVCollectorsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HyperVCollectorsClientGetResponse{}, err } @@ -223,7 +216,7 @@ func (client *HyperVCollectorsClient) getCreateRequest(ctx context.Context, reso return nil, errors.New("parameter hyperVCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{hyperVCollectorName}", url.PathEscape(hyperVCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -247,12 +240,12 @@ func (client *HyperVCollectorsClient) getHandleResponse(resp *http.Response) (Hy } // NewListByProjectPager - Get a list of Hyper-V collector. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// options - HyperVCollectorsClientListByProjectOptions contains the optional parameters for the HyperVCollectorsClient.ListByProject -// method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - options - HyperVCollectorsClientListByProjectOptions contains the optional parameters for the HyperVCollectorsClient.NewListByProjectPager +// method. func (client *HyperVCollectorsClient) NewListByProjectPager(resourceGroupName string, projectName string, options *HyperVCollectorsClientListByProjectOptions) *runtime.Pager[HyperVCollectorsClientListByProjectResponse] { return runtime.NewPager(runtime.PagingHandler[HyperVCollectorsClientListByProjectResponse]{ More: func(page HyperVCollectorsClientListByProjectResponse) bool { @@ -263,7 +256,7 @@ func (client *HyperVCollectorsClient) NewListByProjectPager(resourceGroupName st if err != nil { return HyperVCollectorsClientListByProjectResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HyperVCollectorsClientListByProjectResponse{}, err } @@ -290,7 +283,7 @@ func (client *HyperVCollectorsClient) listByProjectCreateRequest(ctx context.Con return nil, errors.New("parameter projectName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/migrate/armmigrate/hypervcollectors_client_example_test.go b/sdk/resourcemanager/migrate/armmigrate/hypervcollectors_client_example_test.go new file mode 100644 index 000000000000..763cb2dd138c --- /dev/null +++ b/sdk/resourcemanager/migrate/armmigrate/hypervcollectors_client_example_test.go @@ -0,0 +1,188 @@ +//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 armmigrate_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/migrate/armmigrate" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/HyperVCollectors_ListByProject.json +func ExampleHyperVCollectorsClient_NewListByProjectPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewHyperVCollectorsClient().NewListByProjectPager("contosoithyperv", "migrateprojectce73project", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.HyperVCollectorList = armmigrate.HyperVCollectorList{ + // Value: []*armmigrate.HyperVCollector{ + // { + // Name: to.Ptr("migrateprojectce73collector"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/hypervcollectors"), + // ETag: to.Ptr("\"00000981-0000-0300-0000-5d74cd5f0000\""), + // ID: to.Ptr("/subscriptions/8c3c936a-c09b-4de3-830b-3f5f244d72e9/resourceGroups/contosoithyperv/providers/Microsoft.Migrate/assessmentprojects/migrateprojectce73project/hypervcollectors/migrateprojectce73collector"), + // Properties: &armmigrate.CollectorProperties{ + // AgentProperties: &armmigrate.CollectorAgentProperties{ + // ID: to.Ptr("d86c7d5a-2103-5157-bb20-9026b75e5de8"), + // LastHeartbeatUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-08T09:43:59.0573145Z"); return t}()), + // SpnDetails: &armmigrate.CollectorBodyAgentSpnProperties{ + // ApplicationID: to.Ptr("827f1053-44dc-439f-b832-05416dcce12b"), + // Audience: to.Ptr("https://72f988bf-86f1-41af-91ab-2d7cd011db47/migrateprojectce73agentauthaadapp"), + // Authority: to.Ptr("https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47"), + // ObjectID: to.Ptr("be75098e-c0fc-4ac4-98c7-282ebbcf8370"), + // TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), + // }, + // Version: to.Ptr("1.0.8.218"), + // }, + // CreatedTimestamp: to.Ptr("2019-04-10T10:22:51.6271816Z"), + // DiscoverySiteID: to.Ptr("/subscriptions/8c3c936a-c09b-4de3-830b-3f5f244d72e9/resourceGroups/ContosoITHyperV/providers/Microsoft.OffAzure/HyperVSites/migrateprojectce73site"), + // UpdatedTimestamp: to.Ptr("2019-09-08T09:43:59.0573145Z"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/HyperVCollectors_Get.json +func ExampleHyperVCollectorsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewHyperVCollectorsClient().Get(ctx, "contosoithyperv", "migrateprojectce73project", "migrateprojectce73collector", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.HyperVCollector = armmigrate.HyperVCollector{ + // Name: to.Ptr("migrateprojectce73collector"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/hypervcollectors"), + // ETag: to.Ptr("\"00000981-0000-0300-0000-5d74cd5f0000\""), + // ID: to.Ptr("/subscriptions/8c3c936a-c09b-4de3-830b-3f5f244d72e9/resourceGroups/contosoithyperv/providers/Microsoft.Migrate/assessmentprojects/migrateprojectce73project/hypervcollectors/migrateprojectce73collector"), + // Properties: &armmigrate.CollectorProperties{ + // AgentProperties: &armmigrate.CollectorAgentProperties{ + // ID: to.Ptr("d86c7d5a-2103-5157-bb20-9026b75e5de8"), + // LastHeartbeatUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-08T09:43:59.0573145Z"); return t}()), + // SpnDetails: &armmigrate.CollectorBodyAgentSpnProperties{ + // ApplicationID: to.Ptr("827f1053-44dc-439f-b832-05416dcce12b"), + // Audience: to.Ptr("https://72f988bf-86f1-41af-91ab-2d7cd011db47/migrateprojectce73agentauthaadapp"), + // Authority: to.Ptr("https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47"), + // ObjectID: to.Ptr("be75098e-c0fc-4ac4-98c7-282ebbcf8370"), + // TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), + // }, + // Version: to.Ptr("1.0.8.218"), + // }, + // CreatedTimestamp: to.Ptr("2019-04-10T10:22:51.6271816Z"), + // DiscoverySiteID: to.Ptr("/subscriptions/8c3c936a-c09b-4de3-830b-3f5f244d72e9/resourceGroups/ContosoITHyperV/providers/Microsoft.OffAzure/HyperVSites/migrateprojectce73site"), + // UpdatedTimestamp: to.Ptr("2019-09-08T09:43:59.0573145Z"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/HyperVCollectors_Create.json +func ExampleHyperVCollectorsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewHyperVCollectorsClient().Create(ctx, "contosoithyperv", "migrateprojectce73project", "migrateprojectce73collector", &armmigrate.HyperVCollectorsClientCreateOptions{CollectorBody: &armmigrate.HyperVCollector{ + ETag: to.Ptr("\"00000981-0000-0300-0000-5d74cd5f0000\""), + Properties: &armmigrate.CollectorProperties{ + AgentProperties: &armmigrate.CollectorAgentProperties{ + SpnDetails: &armmigrate.CollectorBodyAgentSpnProperties{ + ApplicationID: to.Ptr("827f1053-44dc-439f-b832-05416dcce12b"), + Audience: to.Ptr("https://72f988bf-86f1-41af-91ab-2d7cd011db47/migrateprojectce73agentauthaadapp"), + Authority: to.Ptr("https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47"), + ObjectID: to.Ptr("be75098e-c0fc-4ac4-98c7-282ebbcf8370"), + TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), + }, + }, + DiscoverySiteID: to.Ptr("/subscriptions/8c3c936a-c09b-4de3-830b-3f5f244d72e9/resourceGroups/ContosoITHyperV/providers/Microsoft.OffAzure/HyperVSites/migrateprojectce73site"), + }, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.HyperVCollector = armmigrate.HyperVCollector{ + // Name: to.Ptr("migrateprojectce73collector"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/hypervcollectors"), + // ETag: to.Ptr("\"00000981-0000-0300-0000-5d74cd5f0000\""), + // ID: to.Ptr("/subscriptions/8c3c936a-c09b-4de3-830b-3f5f244d72e9/resourceGroups/contosoithyperv/providers/Microsoft.Migrate/assessmentprojects/migrateprojectce73project/hypervcollectors/migrateprojectce73collector"), + // Properties: &armmigrate.CollectorProperties{ + // AgentProperties: &armmigrate.CollectorAgentProperties{ + // ID: to.Ptr("d86c7d5a-2103-5157-bb20-9026b75e5de8"), + // LastHeartbeatUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-08T09:43:59.0573145Z"); return t}()), + // SpnDetails: &armmigrate.CollectorBodyAgentSpnProperties{ + // ApplicationID: to.Ptr("827f1053-44dc-439f-b832-05416dcce12b"), + // Audience: to.Ptr("https://72f988bf-86f1-41af-91ab-2d7cd011db47/migrateprojectce73agentauthaadapp"), + // Authority: to.Ptr("https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47"), + // ObjectID: to.Ptr("be75098e-c0fc-4ac4-98c7-282ebbcf8370"), + // TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), + // }, + // Version: to.Ptr("1.0.8.218"), + // }, + // CreatedTimestamp: to.Ptr("2019-04-10T10:22:51.6271816Z"), + // DiscoverySiteID: to.Ptr("/subscriptions/8c3c936a-c09b-4de3-830b-3f5f244d72e9/resourceGroups/ContosoITHyperV/providers/Microsoft.OffAzure/HyperVSites/migrateprojectce73site"), + // UpdatedTimestamp: to.Ptr("2019-09-08T09:43:59.0573145Z"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/HyperVCollectors_Delete.json +func ExampleHyperVCollectorsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewHyperVCollectorsClient().Delete(ctx, "contosoithyperv", "migrateprojectce73project", "migrateprojectce73collector", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_importcollectors_client.go b/sdk/resourcemanager/migrate/armmigrate/importcollectors_client.go similarity index 84% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_importcollectors_client.go rename to sdk/resourcemanager/migrate/armmigrate/importcollectors_client.go index c4d04f98cbfc..6604f5b3882e 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_importcollectors_client.go +++ b/sdk/resourcemanager/migrate/armmigrate/importcollectors_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 armmigrate @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // ImportCollectorsClient contains the methods for the ImportCollectors group. // Don't use this type directly, use NewImportCollectorsClient() instead. type ImportCollectorsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewImportCollectorsClient creates a new instance of ImportCollectorsClient with the specified values. -// subscriptionID - Azure Subscription Id in which project was created. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription Id in which project was created. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewImportCollectorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ImportCollectorsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ImportCollectorsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ImportCollectorsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Create or Update Import collector // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// importCollectorName - Unique name of a Import collector within a project. -// options - ImportCollectorsClientCreateOptions contains the optional parameters for the ImportCollectorsClient.Create method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - importCollectorName - Unique name of a Import collector within a project. +// - options - ImportCollectorsClientCreateOptions contains the optional parameters for the ImportCollectorsClient.Create method. func (client *ImportCollectorsClient) Create(ctx context.Context, resourceGroupName string, projectName string, importCollectorName string, options *ImportCollectorsClientCreateOptions) (ImportCollectorsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, projectName, importCollectorName, options) if err != nil { return ImportCollectorsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ImportCollectorsClientCreateResponse{}, err } @@ -95,7 +86,7 @@ func (client *ImportCollectorsClient) createCreateRequest(ctx context.Context, r return nil, errors.New("parameter importCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{importCollectorName}", url.PathEscape(importCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -123,17 +114,18 @@ func (client *ImportCollectorsClient) createHandleResponse(resp *http.Response) // Delete - Delete a Import collector from the project. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// importCollectorName - Unique name of a Import collector within a project. -// options - ImportCollectorsClientDeleteOptions contains the optional parameters for the ImportCollectorsClient.Delete method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - importCollectorName - Unique name of a Import collector within a project. +// - options - ImportCollectorsClientDeleteOptions contains the optional parameters for the ImportCollectorsClient.Delete method. func (client *ImportCollectorsClient) Delete(ctx context.Context, resourceGroupName string, projectName string, importCollectorName string, options *ImportCollectorsClientDeleteOptions) (ImportCollectorsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, projectName, importCollectorName, options) if err != nil { return ImportCollectorsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ImportCollectorsClientDeleteResponse{}, err } @@ -162,7 +154,7 @@ func (client *ImportCollectorsClient) deleteCreateRequest(ctx context.Context, r return nil, errors.New("parameter importCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{importCollectorName}", url.PathEscape(importCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -184,17 +176,18 @@ func (client *ImportCollectorsClient) deleteHandleResponse(resp *http.Response) // Get - Get a Import collector. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// importCollectorName - Unique name of a Import collector within a project. -// options - ImportCollectorsClientGetOptions contains the optional parameters for the ImportCollectorsClient.Get method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - importCollectorName - Unique name of a Import collector within a project. +// - options - ImportCollectorsClientGetOptions contains the optional parameters for the ImportCollectorsClient.Get method. func (client *ImportCollectorsClient) Get(ctx context.Context, resourceGroupName string, projectName string, importCollectorName string, options *ImportCollectorsClientGetOptions) (ImportCollectorsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, projectName, importCollectorName, options) if err != nil { return ImportCollectorsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ImportCollectorsClientGetResponse{}, err } @@ -223,7 +216,7 @@ func (client *ImportCollectorsClient) getCreateRequest(ctx context.Context, reso return nil, errors.New("parameter importCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{importCollectorName}", url.PathEscape(importCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -247,12 +240,12 @@ func (client *ImportCollectorsClient) getHandleResponse(resp *http.Response) (Im } // NewListByProjectPager - Get a list of Import collector. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// options - ImportCollectorsClientListByProjectOptions contains the optional parameters for the ImportCollectorsClient.ListByProject -// method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - options - ImportCollectorsClientListByProjectOptions contains the optional parameters for the ImportCollectorsClient.NewListByProjectPager +// method. func (client *ImportCollectorsClient) NewListByProjectPager(resourceGroupName string, projectName string, options *ImportCollectorsClientListByProjectOptions) *runtime.Pager[ImportCollectorsClientListByProjectResponse] { return runtime.NewPager(runtime.PagingHandler[ImportCollectorsClientListByProjectResponse]{ More: func(page ImportCollectorsClientListByProjectResponse) bool { @@ -263,7 +256,7 @@ func (client *ImportCollectorsClient) NewListByProjectPager(resourceGroupName st if err != nil { return ImportCollectorsClientListByProjectResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ImportCollectorsClientListByProjectResponse{}, err } @@ -290,7 +283,7 @@ func (client *ImportCollectorsClient) listByProjectCreateRequest(ctx context.Con return nil, errors.New("parameter projectName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/migrate/armmigrate/importcollectors_client_example_test.go b/sdk/resourcemanager/migrate/armmigrate/importcollectors_client_example_test.go new file mode 100644 index 000000000000..d73f1848e233 --- /dev/null +++ b/sdk/resourcemanager/migrate/armmigrate/importcollectors_client_example_test.go @@ -0,0 +1,146 @@ +//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 armmigrate_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/migrate/armmigrate" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ImportCollectors_ListByProject.json +func ExampleImportCollectorsClient_NewListByProjectPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewImportCollectorsClient().NewListByProjectPager("markusavstestrg", "rajoshCCY9671project", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ImportCollectorList = armmigrate.ImportCollectorList{ + // Value: []*armmigrate.ImportCollector{ + // { + // Name: to.Ptr("importCollector2951"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/importcollectors"), + // ETag: to.Ptr("\"000098a2-0000-3300-0000-605995620000\""), + // ID: to.Ptr("/subscriptions/31be0ff4-c932-4cb3-8efc-efa411d79280/resourceGroups/markusavstestrg/providers/Microsoft.Migrate/assessmentprojects/rajoshCCY9671project/importcollectors/importCollector2951"), + // Properties: &armmigrate.ImportCollectorProperties{ + // CreatedTimestamp: to.Ptr("2021-02-11T04:46:54.9582099Z"), + // DiscoverySiteID: to.Ptr("/subscriptions/31be0ff4-c932-4cb3-8efc-efa411d79280/resourcegroups/MarkusAVStestRG/providers/microsoft.offazure/importsites/rajoshCCY54cbimportSite"), + // UpdatedTimestamp: to.Ptr("2021-03-23T07:14:42.9238657Z"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ImportCollectors_Get.json +func ExampleImportCollectorsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewImportCollectorsClient().Get(ctx, "markusavstestrg", "rajoshCCY9671project", "importCollector2951", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ImportCollector = armmigrate.ImportCollector{ + // Name: to.Ptr("importCollector2951"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/importcollectors"), + // ETag: to.Ptr("\"000064a2-0000-3300-0000-605994800000\""), + // ID: to.Ptr("/subscriptions/31be0ff4-c932-4cb3-8efc-efa411d79280/resourceGroups/markusavstestrg/providers/Microsoft.Migrate/assessmentprojects/rajoshCCY9671project/importcollectors/importCollector2951"), + // Properties: &armmigrate.ImportCollectorProperties{ + // CreatedTimestamp: to.Ptr("2021-02-11T04:46:54.9582099Z"), + // DiscoverySiteID: to.Ptr("/subscriptions/31be0ff4-c932-4cb3-8efc-efa411d79280/resourcegroups/MarkusAVStestRG/providers/microsoft.offazure/importsites/rajoshCCY54cbimportSite"), + // UpdatedTimestamp: to.Ptr("2021-03-23T07:10:56.3588497Z"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ImportCollectors_Create.json +func ExampleImportCollectorsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewImportCollectorsClient().Create(ctx, "markusavstestrg", "rajoshCCY9671project", "importCollector2952", &armmigrate.ImportCollectorsClientCreateOptions{CollectorBody: &armmigrate.ImportCollector{ + Name: to.Ptr("importCollector2951"), + Type: to.Ptr("Microsoft.Migrate/assessmentprojects/importcollectors"), + ETag: to.Ptr("\"000064a2-0000-3300-0000-605994800000\""), + ID: to.Ptr("/subscriptions/31be0ff4-c932-4cb3-8efc-efa411d79280/resourceGroups/markusavstestrg/providers/Microsoft.Migrate/assessmentprojects/rajoshCCY9671project/importcollectors/importCollector2951"), + Properties: &armmigrate.ImportCollectorProperties{ + DiscoverySiteID: to.Ptr("/subscriptions/31be0ff4-c932-4cb3-8efc-efa411d79280/resourcegroups/MarkusAVStestRG/providers/microsoft.offazure/importsites/rajoshCCY54cbimportSite"), + }, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ImportCollector = armmigrate.ImportCollector{ + // Name: to.Ptr("importCollector2952"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/importcollectors"), + // ETag: to.Ptr("\"0000a7a2-0000-3300-0000-6059964d0000\""), + // ID: to.Ptr("/subscriptions/31be0ff4-c932-4cb3-8efc-efa411d79280/resourceGroups/markusavstestrg/providers/Microsoft.Migrate/assessmentprojects/rajoshCCY9671project/importcollectors/importCollector2952"), + // Properties: &armmigrate.ImportCollectorProperties{ + // CreatedTimestamp: to.Ptr("2021-03-23T07:18:37.2247735Z"), + // DiscoverySiteID: to.Ptr("/subscriptions/31be0ff4-c932-4cb3-8efc-efa411d79280/resourcegroups/MarkusAVStestRG/providers/microsoft.offazure/importsites/rajoshCCY54cbimportSite"), + // UpdatedTimestamp: to.Ptr("2021-03-23T07:18:37.2247735Z"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ImportCollectors_Delete.json +func ExampleImportCollectorsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewImportCollectorsClient().Delete(ctx, "markusavstestrg", "rajoshCCY9671project", "importCollector2952", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_machines_client.go b/sdk/resourcemanager/migrate/armmigrate/machines_client.go similarity index 82% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_machines_client.go rename to sdk/resourcemanager/migrate/armmigrate/machines_client.go index 5cfe28717886..004098b49914 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_machines_client.go +++ b/sdk/resourcemanager/migrate/armmigrate/machines_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 armmigrate @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // MachinesClient contains the methods for the Machines group. // Don't use this type directly, use NewMachinesClient() instead. type MachinesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewMachinesClient creates a new instance of MachinesClient with the specified values. -// subscriptionID - Azure Subscription Id in which project was created. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription Id in which project was created. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewMachinesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MachinesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".MachinesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &MachinesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get the machine with the specified name. Returns a json object of type 'machine' defined in Models section. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// machineName - Unique name of a machine in private datacenter. -// options - MachinesClientGetOptions contains the optional parameters for the MachinesClient.Get method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - machineName - Unique name of a machine in private datacenter. +// - options - MachinesClientGetOptions contains the optional parameters for the MachinesClient.Get method. func (client *MachinesClient) Get(ctx context.Context, resourceGroupName string, projectName string, machineName string, options *MachinesClientGetOptions) (MachinesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, projectName, machineName, options) if err != nil { return MachinesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MachinesClientGetResponse{}, err } @@ -95,7 +86,7 @@ func (client *MachinesClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter machineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{machineName}", url.PathEscape(machineName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -120,11 +111,12 @@ func (client *MachinesClient) getHandleResponse(resp *http.Response) (MachinesCl // NewListByProjectPager - Get data of all the machines available in the project. Returns a json array of objects of type // 'machine' defined in Models section. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// options - MachinesClientListByProjectOptions contains the optional parameters for the MachinesClient.ListByProject method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - options - MachinesClientListByProjectOptions contains the optional parameters for the MachinesClient.NewListByProjectPager +// method. func (client *MachinesClient) NewListByProjectPager(resourceGroupName string, projectName string, options *MachinesClientListByProjectOptions) *runtime.Pager[MachinesClientListByProjectResponse] { return runtime.NewPager(runtime.PagingHandler[MachinesClientListByProjectResponse]{ More: func(page MachinesClientListByProjectResponse) bool { @@ -141,7 +133,7 @@ func (client *MachinesClient) NewListByProjectPager(resourceGroupName string, pr if err != nil { return MachinesClientListByProjectResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MachinesClientListByProjectResponse{}, err } @@ -168,7 +160,7 @@ func (client *MachinesClient) listByProjectCreateRequest(ctx context.Context, re return nil, errors.New("parameter projectName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/migrate/armmigrate/machines_client_example_test.go b/sdk/resourcemanager/migrate/armmigrate/machines_client_example_test.go new file mode 100644 index 000000000000..12d26e7ce72c --- /dev/null +++ b/sdk/resourcemanager/migrate/armmigrate/machines_client_example_test.go @@ -0,0 +1,174 @@ +//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 armmigrate_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/migrate/armmigrate" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Machines_ListByProject.json +func ExampleMachinesClient_NewListByProjectPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewMachinesClient().NewListByProjectPager("abgoyal-westEurope", "abgoyalWEselfhostb72bproject", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.MachineResultList = armmigrate.MachineResultList{ + // Value: []*armmigrate.Machine{ + // { + // Name: to.Ptr("269ef295-a38d-4f8f-9779-77ce79088311"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/machines"), + // ETag: to.Ptr("\"04006052-0000-0d00-0000-5cd4065a0000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/machines/269ef295-a38d-4f8f-9779-77ce79088311"), + // Properties: &armmigrate.MachineProperties{ + // Description: to.Ptr("Microsoft Azure Migration Image on Windows Server 2016"), + // BootType: to.Ptr(armmigrate.MachineBootTypeBIOS), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T09:58:22.1734149Z"); return t}()), + // DatacenterManagementServerArmID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.OffAzure/VMwareSites/PortalvCenterbc2fsite/vcenters/idclab-a360-fareast-corp-micros-86617dcf-effe-59ad-8c3a-cdd3ea7300d3"), + // DatacenterManagementServerName: to.Ptr("IDCLAB-A360.fareast.corp.microsoft.com"), + // DiscoveryMachineArmID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/abgoyal-westeurope/providers/microsoft.offazure/vmwaresites/portalvcenterbc2fsite/machines/idclab-a360-fareast-corp-micros-86617dcf-effe-59ad-8c3a-cdd3ea7300d3_52bd4eeb-faf4-7d95-4dd5-5524350ce2bb"), + // Disks: map[string]*armmigrate.Disk{ + // "6000C29f-9065-8fe0-ab83-7e58ff6ba442": &armmigrate.Disk{ + // DisplayName: to.Ptr("scsi0:0"), + // GigabytesAllocated: to.Ptr[float64](80), + // }, + // }, + // DisplayName: to.Ptr("ShubhamFirstAndThird"), + // Groups: []*string{ + // to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/test1")}, + // MegabytesOfMemory: to.Ptr[float32](16384), + // NetworkAdapters: map[string]*armmigrate.NetworkAdapter{ + // "4000": &armmigrate.NetworkAdapter{ + // DisplayName: to.Ptr("VM Network"), + // IPAddresses: []*string{ + // }, + // MacAddress: to.Ptr("00:0c:29:ac:e3:6d"), + // }, + // }, + // NumberOfCores: to.Ptr[int32](8), + // OperatingSystemName: to.Ptr("Microsoft Windows Server 2016 (64-bit)"), + // OperatingSystemType: to.Ptr("windowsGuest"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T09:58:22.2990529Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("3ad6c8b7-08d6-45dc-87f5-cd533501f553"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/machines"), + // ETag: to.Ptr("\"04005652-0000-0d00-0000-5cd4065a0000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/machines/3ad6c8b7-08d6-45dc-87f5-cd533501f553"), + // Properties: &armmigrate.MachineProperties{ + // Description: to.Ptr("Microsoft Azure Migration Image on Windows Server 2016"), + // BootType: to.Ptr(armmigrate.MachineBootTypeBIOS), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T09:58:22.1734149Z"); return t}()), + // DatacenterManagementServerArmID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.OffAzure/VMwareSites/PortalvCenterbc2fsite/vcenters/idclab-a360-fareast-corp-micros-86617dcf-effe-59ad-8c3a-cdd3ea7300d3"), + // DatacenterManagementServerName: to.Ptr("IDCLAB-A360.fareast.corp.microsoft.com"), + // DiscoveryMachineArmID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/abgoyal-westeurope/providers/microsoft.offazure/vmwaresites/portalvcenterbc2fsite/machines/idclab-a360-fareast-corp-micros-86617dcf-effe-59ad-8c3a-cdd3ea7300d3_52e5be9c-2758-a483-c252-eeef7919095c"), + // Disks: map[string]*armmigrate.Disk{ + // "6000C296-54c9-e29c-51be-125e76850958": &armmigrate.Disk{ + // DisplayName: to.Ptr("scsi0:0"), + // GigabytesAllocated: to.Ptr[float64](80), + // }, + // }, + // DisplayName: to.Ptr("shsinglaVM5"), + // Groups: []*string{ + // to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/test1")}, + // MegabytesOfMemory: to.Ptr[float32](16384), + // NetworkAdapters: map[string]*armmigrate.NetworkAdapter{ + // "4000": &armmigrate.NetworkAdapter{ + // DisplayName: to.Ptr("VM Network"), + // IPAddresses: []*string{ + // }, + // MacAddress: to.Ptr("00:0c:29:1f:ac:0a"), + // }, + // }, + // NumberOfCores: to.Ptr[int32](8), + // OperatingSystemName: to.Ptr("Microsoft Windows Server 2016 (64-bit)"), + // OperatingSystemType: to.Ptr("windowsGuest"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T09:58:22.3142054Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Machines_Get.json +func ExampleMachinesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMachinesClient().Get(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "269ef295-a38d-4f8f-9779-77ce79088311", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Machine = armmigrate.Machine{ + // Name: to.Ptr("269ef295-a38d-4f8f-9779-77ce79088311"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/machines"), + // ETag: to.Ptr("\"04006052-0000-0d00-0000-5cd4065a0000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/machines/269ef295-a38d-4f8f-9779-77ce79088311"), + // Properties: &armmigrate.MachineProperties{ + // Description: to.Ptr("Microsoft Azure Migration Image on Windows Server 2016"), + // BootType: to.Ptr(armmigrate.MachineBootTypeBIOS), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T09:58:22.1734149Z"); return t}()), + // DatacenterManagementServerArmID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.OffAzure/VMwareSites/PortalvCenterbc2fsite/vcenters/idclab-a360-fareast-corp-micros-86617dcf-effe-59ad-8c3a-cdd3ea7300d3"), + // DatacenterManagementServerName: to.Ptr("IDCLAB-A360.fareast.corp.microsoft.com"), + // DiscoveryMachineArmID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/abgoyal-westeurope/providers/microsoft.offazure/vmwaresites/portalvcenterbc2fsite/machines/idclab-a360-fareast-corp-micros-86617dcf-effe-59ad-8c3a-cdd3ea7300d3_52bd4eeb-faf4-7d95-4dd5-5524350ce2bb"), + // Disks: map[string]*armmigrate.Disk{ + // "6000C29f-9065-8fe0-ab83-7e58ff6ba442": &armmigrate.Disk{ + // DisplayName: to.Ptr("scsi0:0"), + // GigabytesAllocated: to.Ptr[float64](80), + // }, + // }, + // DisplayName: to.Ptr("ShubhamFirstAndThird"), + // Groups: []*string{ + // to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/groups/test1")}, + // MegabytesOfMemory: to.Ptr[float32](16384), + // NetworkAdapters: map[string]*armmigrate.NetworkAdapter{ + // "4000": &armmigrate.NetworkAdapter{ + // DisplayName: to.Ptr("VM Network"), + // IPAddresses: []*string{ + // }, + // MacAddress: to.Ptr("00:0c:29:ac:e3:6d"), + // }, + // }, + // NumberOfCores: to.Ptr[int32](8), + // OperatingSystemName: to.Ptr("Microsoft Windows Server 2016 (64-bit)"), + // OperatingSystemType: to.Ptr("windowsGuest"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T09:58:22.2990529Z"); return t}()), + // }, + // } +} diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_models.go b/sdk/resourcemanager/migrate/armmigrate/models.go similarity index 96% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_models.go rename to sdk/resourcemanager/migrate/armmigrate/models.go index 05cfec0f9f90..168c7efe9f03 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_models.go +++ b/sdk/resourcemanager/migrate/armmigrate/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 armmigrate @@ -186,7 +187,7 @@ type AssessedMachinesClientGetOptions struct { // placeholder for future optional parameters } -// AssessedMachinesClientListByAssessmentOptions contains the optional parameters for the AssessedMachinesClient.ListByAssessment +// AssessedMachinesClientListByAssessmentOptions contains the optional parameters for the AssessedMachinesClient.NewListByAssessmentPager // method. type AssessedMachinesClientListByAssessmentOptions struct { // placeholder for future optional parameters @@ -406,37 +407,17 @@ type AssessmentsClientGetReportDownloadURLOptions struct { // placeholder for future optional parameters } -// AssessmentsClientListByGroupOptions contains the optional parameters for the AssessmentsClient.ListByGroup method. +// AssessmentsClientListByGroupOptions contains the optional parameters for the AssessmentsClient.NewListByGroupPager method. type AssessmentsClientListByGroupOptions struct { // placeholder for future optional parameters } -// AssessmentsClientListByProjectOptions contains the optional parameters for the AssessmentsClient.ListByProject method. +// AssessmentsClientListByProjectOptions contains the optional parameters for the AssessmentsClient.NewListByProjectPager +// method. type AssessmentsClientListByProjectOptions struct { // placeholder for future optional parameters } -// CloudError - An error response from the Azure Migrate service. -type CloudError struct { - // An error response from the Azure Migrate service. - Error *CloudErrorBody `json:"error,omitempty"` -} - -// CloudErrorBody - An error response from the Azure Migrate service. -type CloudErrorBody struct { - // An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - Code *string `json:"code,omitempty"` - - // A list of additional details about the error. - Details []*CloudErrorBody `json:"details,omitempty"` - - // A message describing the error, intended to be suitable for display in a user interface. - Message *string `json:"message,omitempty"` - - // The target of the particular error. For example, the name of the property in error. - Target *string `json:"target,omitempty"` -} - type CollectorAgentProperties struct { SpnDetails *CollectorBodyAgentSpnProperties `json:"spnDetails,omitempty"` @@ -574,7 +555,7 @@ type GroupsClientGetOptions struct { // placeholder for future optional parameters } -// GroupsClientListByProjectOptions contains the optional parameters for the GroupsClient.ListByProject method. +// GroupsClientListByProjectOptions contains the optional parameters for the GroupsClient.NewListByProjectPager method. type GroupsClientListByProjectOptions struct { // placeholder for future optional parameters } @@ -621,7 +602,7 @@ type HyperVCollectorsClientGetOptions struct { // placeholder for future optional parameters } -// HyperVCollectorsClientListByProjectOptions contains the optional parameters for the HyperVCollectorsClient.ListByProject +// HyperVCollectorsClientListByProjectOptions contains the optional parameters for the HyperVCollectorsClient.NewListByProjectPager // method. type HyperVCollectorsClientListByProjectOptions struct { // placeholder for future optional parameters @@ -673,7 +654,7 @@ type ImportCollectorsClientGetOptions struct { // placeholder for future optional parameters } -// ImportCollectorsClientListByProjectOptions contains the optional parameters for the ImportCollectorsClient.ListByProject +// ImportCollectorsClientListByProjectOptions contains the optional parameters for the ImportCollectorsClient.NewListByProjectPager // method. type ImportCollectorsClientListByProjectOptions struct { // placeholder for future optional parameters @@ -763,7 +744,7 @@ type MachinesClientGetOptions struct { // placeholder for future optional parameters } -// MachinesClientListByProjectOptions contains the optional parameters for the MachinesClient.ListByProject method. +// MachinesClientListByProjectOptions contains the optional parameters for the MachinesClient.NewListByProjectPager method. type MachinesClientListByProjectOptions struct { // placeholder for future optional parameters } @@ -813,7 +794,7 @@ type OperationResultList struct { Value []*Operation `json:"value,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -955,7 +936,7 @@ type Project struct { Properties *ProjectProperties `json:"properties,omitempty"` // Tags provided by Azure Tagging service. - Tags interface{} `json:"tags,omitempty"` + Tags any `json:"tags,omitempty"` // READ-ONLY; Path reference to this project /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName} ID *string `json:"id,omitempty" azure:"ro"` @@ -1026,7 +1007,7 @@ type ProjectResultList struct { Value []*Project `json:"value,omitempty"` } -// ProjectsClientAssessmentOptionsListOptions contains the optional parameters for the ProjectsClient.AssessmentOptionsList +// ProjectsClientAssessmentOptionsListOptions contains the optional parameters for the ProjectsClient.NewAssessmentOptionsListPager // method. type ProjectsClientAssessmentOptionsListOptions struct { // placeholder for future optional parameters @@ -1053,12 +1034,13 @@ type ProjectsClientGetOptions struct { // placeholder for future optional parameters } -// ProjectsClientListBySubscriptionOptions contains the optional parameters for the ProjectsClient.ListBySubscription method. +// ProjectsClientListBySubscriptionOptions contains the optional parameters for the ProjectsClient.NewListBySubscriptionPager +// method. type ProjectsClientListBySubscriptionOptions struct { // placeholder for future optional parameters } -// ProjectsClientListOptions contains the optional parameters for the ProjectsClient.List method. +// ProjectsClientListOptions contains the optional parameters for the ProjectsClient.NewListPager method. type ProjectsClientListOptions struct { // placeholder for future optional parameters } @@ -1111,7 +1093,7 @@ type ServerCollectorsClientGetOptions struct { // placeholder for future optional parameters } -// ServerCollectorsClientListByProjectOptions contains the optional parameters for the ServerCollectorsClient.ListByProject +// ServerCollectorsClientListByProjectOptions contains the optional parameters for the ServerCollectorsClient.NewListByProjectPager // method. type ServerCollectorsClientListByProjectOptions struct { // placeholder for future optional parameters @@ -1182,7 +1164,7 @@ type VMwareCollectorsClientGetOptions struct { // placeholder for future optional parameters } -// VMwareCollectorsClientListByProjectOptions contains the optional parameters for the VMwareCollectorsClient.ListByProject +// VMwareCollectorsClientListByProjectOptions contains the optional parameters for the VMwareCollectorsClient.NewListByProjectPager // method. type VMwareCollectorsClientListByProjectOptions struct { // placeholder for future optional parameters diff --git a/sdk/resourcemanager/migrate/armmigrate/models_serde.go b/sdk/resourcemanager/migrate/armmigrate/models_serde.go new file mode 100644 index 000000000000..a178b0c98038 --- /dev/null +++ b/sdk/resourcemanager/migrate/armmigrate/models_serde.go @@ -0,0 +1,2195 @@ +//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 armmigrate + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AssessedDisk. +func (a AssessedDisk) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "gigabytesForRecommendedDiskSize", a.GigabytesForRecommendedDiskSize) + populate(objectMap, "gigabytesProvisioned", a.GigabytesProvisioned) + populate(objectMap, "megabytesPerSecondOfRead", a.MegabytesPerSecondOfRead) + populate(objectMap, "megabytesPerSecondOfWrite", a.MegabytesPerSecondOfWrite) + populate(objectMap, "monthlyStorageCost", a.MonthlyStorageCost) + populate(objectMap, "name", a.Name) + populate(objectMap, "numberOfReadOperationsPerSecond", a.NumberOfReadOperationsPerSecond) + populate(objectMap, "numberOfWriteOperationsPerSecond", a.NumberOfWriteOperationsPerSecond) + populate(objectMap, "recommendedDiskSize", a.RecommendedDiskSize) + populate(objectMap, "recommendedDiskType", a.RecommendedDiskType) + populate(objectMap, "suitability", a.Suitability) + populate(objectMap, "suitabilityDetail", a.SuitabilityDetail) + populate(objectMap, "suitabilityExplanation", a.SuitabilityExplanation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssessedDisk. +func (a *AssessedDisk) 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 "displayName": + err = unpopulate(val, "DisplayName", &a.DisplayName) + delete(rawMsg, key) + case "gigabytesForRecommendedDiskSize": + err = unpopulate(val, "GigabytesForRecommendedDiskSize", &a.GigabytesForRecommendedDiskSize) + delete(rawMsg, key) + case "gigabytesProvisioned": + err = unpopulate(val, "GigabytesProvisioned", &a.GigabytesProvisioned) + delete(rawMsg, key) + case "megabytesPerSecondOfRead": + err = unpopulate(val, "MegabytesPerSecondOfRead", &a.MegabytesPerSecondOfRead) + delete(rawMsg, key) + case "megabytesPerSecondOfWrite": + err = unpopulate(val, "MegabytesPerSecondOfWrite", &a.MegabytesPerSecondOfWrite) + delete(rawMsg, key) + case "monthlyStorageCost": + err = unpopulate(val, "MonthlyStorageCost", &a.MonthlyStorageCost) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "numberOfReadOperationsPerSecond": + err = unpopulate(val, "NumberOfReadOperationsPerSecond", &a.NumberOfReadOperationsPerSecond) + delete(rawMsg, key) + case "numberOfWriteOperationsPerSecond": + err = unpopulate(val, "NumberOfWriteOperationsPerSecond", &a.NumberOfWriteOperationsPerSecond) + delete(rawMsg, key) + case "recommendedDiskSize": + err = unpopulate(val, "RecommendedDiskSize", &a.RecommendedDiskSize) + delete(rawMsg, key) + case "recommendedDiskType": + err = unpopulate(val, "RecommendedDiskType", &a.RecommendedDiskType) + delete(rawMsg, key) + case "suitability": + err = unpopulate(val, "Suitability", &a.Suitability) + delete(rawMsg, key) + case "suitabilityDetail": + err = unpopulate(val, "SuitabilityDetail", &a.SuitabilityDetail) + delete(rawMsg, key) + case "suitabilityExplanation": + err = unpopulate(val, "SuitabilityExplanation", &a.SuitabilityExplanation) + 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 AssessedMachine. +func (a AssessedMachine) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", a.ETag) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssessedMachine. +func (a *AssessedMachine) 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 "eTag": + err = unpopulate(val, "ETag", &a.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "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 AssessedMachineProperties. +func (a AssessedMachineProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "bootType", a.BootType) + populate(objectMap, "confidenceRatingInPercentage", a.ConfidenceRatingInPercentage) + populateTimeRFC3339(objectMap, "createdTimestamp", a.CreatedTimestamp) + populate(objectMap, "datacenterMachineArmId", a.DatacenterMachineArmID) + populate(objectMap, "datacenterManagementServerArmId", a.DatacenterManagementServerArmID) + populate(objectMap, "datacenterManagementServerName", a.DatacenterManagementServerName) + populate(objectMap, "description", a.Description) + populate(objectMap, "disks", a.Disks) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "megabytesOfMemory", a.MegabytesOfMemory) + populate(objectMap, "megabytesOfMemoryForRecommendedSize", a.MegabytesOfMemoryForRecommendedSize) + populate(objectMap, "monthlyBandwidthCost", a.MonthlyBandwidthCost) + populate(objectMap, "monthlyComputeCostForRecommendedSize", a.MonthlyComputeCostForRecommendedSize) + populate(objectMap, "monthlyPremiumStorageCost", a.MonthlyPremiumStorageCost) + populate(objectMap, "monthlyStandardSSDStorageCost", a.MonthlyStandardSSDStorageCost) + populate(objectMap, "monthlyStorageCost", a.MonthlyStorageCost) + populate(objectMap, "networkAdapters", a.NetworkAdapters) + populate(objectMap, "numberOfCores", a.NumberOfCores) + populate(objectMap, "numberOfCoresForRecommendedSize", a.NumberOfCoresForRecommendedSize) + populate(objectMap, "operatingSystemName", a.OperatingSystemName) + populate(objectMap, "operatingSystemType", a.OperatingSystemType) + populate(objectMap, "operatingSystemVersion", a.OperatingSystemVersion) + populate(objectMap, "percentageCoresUtilization", a.PercentageCoresUtilization) + populate(objectMap, "percentageMemoryUtilization", a.PercentageMemoryUtilization) + populate(objectMap, "recommendedSize", a.RecommendedSize) + populate(objectMap, "suitability", a.Suitability) + populate(objectMap, "suitabilityDetail", a.SuitabilityDetail) + populate(objectMap, "suitabilityExplanation", a.SuitabilityExplanation) + populateTimeRFC3339(objectMap, "updatedTimestamp", a.UpdatedTimestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssessedMachineProperties. +func (a *AssessedMachineProperties) 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 "bootType": + err = unpopulate(val, "BootType", &a.BootType) + delete(rawMsg, key) + case "confidenceRatingInPercentage": + err = unpopulate(val, "ConfidenceRatingInPercentage", &a.ConfidenceRatingInPercentage) + delete(rawMsg, key) + case "createdTimestamp": + err = unpopulateTimeRFC3339(val, "CreatedTimestamp", &a.CreatedTimestamp) + delete(rawMsg, key) + case "datacenterMachineArmId": + err = unpopulate(val, "DatacenterMachineArmID", &a.DatacenterMachineArmID) + delete(rawMsg, key) + case "datacenterManagementServerArmId": + err = unpopulate(val, "DatacenterManagementServerArmID", &a.DatacenterManagementServerArmID) + delete(rawMsg, key) + case "datacenterManagementServerName": + err = unpopulate(val, "DatacenterManagementServerName", &a.DatacenterManagementServerName) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "disks": + err = unpopulate(val, "Disks", &a.Disks) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &a.DisplayName) + delete(rawMsg, key) + case "megabytesOfMemory": + err = unpopulate(val, "MegabytesOfMemory", &a.MegabytesOfMemory) + delete(rawMsg, key) + case "megabytesOfMemoryForRecommendedSize": + err = unpopulate(val, "MegabytesOfMemoryForRecommendedSize", &a.MegabytesOfMemoryForRecommendedSize) + delete(rawMsg, key) + case "monthlyBandwidthCost": + err = unpopulate(val, "MonthlyBandwidthCost", &a.MonthlyBandwidthCost) + delete(rawMsg, key) + case "monthlyComputeCostForRecommendedSize": + err = unpopulate(val, "MonthlyComputeCostForRecommendedSize", &a.MonthlyComputeCostForRecommendedSize) + delete(rawMsg, key) + case "monthlyPremiumStorageCost": + err = unpopulate(val, "MonthlyPremiumStorageCost", &a.MonthlyPremiumStorageCost) + delete(rawMsg, key) + case "monthlyStandardSSDStorageCost": + err = unpopulate(val, "MonthlyStandardSSDStorageCost", &a.MonthlyStandardSSDStorageCost) + delete(rawMsg, key) + case "monthlyStorageCost": + err = unpopulate(val, "MonthlyStorageCost", &a.MonthlyStorageCost) + delete(rawMsg, key) + case "networkAdapters": + err = unpopulate(val, "NetworkAdapters", &a.NetworkAdapters) + delete(rawMsg, key) + case "numberOfCores": + err = unpopulate(val, "NumberOfCores", &a.NumberOfCores) + delete(rawMsg, key) + case "numberOfCoresForRecommendedSize": + err = unpopulate(val, "NumberOfCoresForRecommendedSize", &a.NumberOfCoresForRecommendedSize) + delete(rawMsg, key) + case "operatingSystemName": + err = unpopulate(val, "OperatingSystemName", &a.OperatingSystemName) + delete(rawMsg, key) + case "operatingSystemType": + err = unpopulate(val, "OperatingSystemType", &a.OperatingSystemType) + delete(rawMsg, key) + case "operatingSystemVersion": + err = unpopulate(val, "OperatingSystemVersion", &a.OperatingSystemVersion) + delete(rawMsg, key) + case "percentageCoresUtilization": + err = unpopulate(val, "PercentageCoresUtilization", &a.PercentageCoresUtilization) + delete(rawMsg, key) + case "percentageMemoryUtilization": + err = unpopulate(val, "PercentageMemoryUtilization", &a.PercentageMemoryUtilization) + delete(rawMsg, key) + case "recommendedSize": + err = unpopulate(val, "RecommendedSize", &a.RecommendedSize) + delete(rawMsg, key) + case "suitability": + err = unpopulate(val, "Suitability", &a.Suitability) + delete(rawMsg, key) + case "suitabilityDetail": + err = unpopulate(val, "SuitabilityDetail", &a.SuitabilityDetail) + delete(rawMsg, key) + case "suitabilityExplanation": + err = unpopulate(val, "SuitabilityExplanation", &a.SuitabilityExplanation) + delete(rawMsg, key) + case "updatedTimestamp": + err = unpopulateTimeRFC3339(val, "UpdatedTimestamp", &a.UpdatedTimestamp) + 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 AssessedMachineResultList. +func (a AssessedMachineResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssessedMachineResultList. +func (a *AssessedMachineResultList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AssessedNetworkAdapter. +func (a AssessedNetworkAdapter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "ipAddresses", a.IPAddresses) + populate(objectMap, "macAddress", a.MacAddress) + populate(objectMap, "megabytesPerSecondReceived", a.MegabytesPerSecondReceived) + populate(objectMap, "megabytesPerSecondTransmitted", a.MegabytesPerSecondTransmitted) + populate(objectMap, "monthlyBandwidthCosts", a.MonthlyBandwidthCosts) + populate(objectMap, "netGigabytesTransmittedPerMonth", a.NetGigabytesTransmittedPerMonth) + populate(objectMap, "suitability", a.Suitability) + populate(objectMap, "suitabilityDetail", a.SuitabilityDetail) + populate(objectMap, "suitabilityExplanation", a.SuitabilityExplanation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssessedNetworkAdapter. +func (a *AssessedNetworkAdapter) 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 "displayName": + err = unpopulate(val, "DisplayName", &a.DisplayName) + delete(rawMsg, key) + case "ipAddresses": + err = unpopulate(val, "IPAddresses", &a.IPAddresses) + delete(rawMsg, key) + case "macAddress": + err = unpopulate(val, "MacAddress", &a.MacAddress) + delete(rawMsg, key) + case "megabytesPerSecondReceived": + err = unpopulate(val, "MegabytesPerSecondReceived", &a.MegabytesPerSecondReceived) + delete(rawMsg, key) + case "megabytesPerSecondTransmitted": + err = unpopulate(val, "MegabytesPerSecondTransmitted", &a.MegabytesPerSecondTransmitted) + delete(rawMsg, key) + case "monthlyBandwidthCosts": + err = unpopulate(val, "MonthlyBandwidthCosts", &a.MonthlyBandwidthCosts) + delete(rawMsg, key) + case "netGigabytesTransmittedPerMonth": + err = unpopulate(val, "NetGigabytesTransmittedPerMonth", &a.NetGigabytesTransmittedPerMonth) + delete(rawMsg, key) + case "suitability": + err = unpopulate(val, "Suitability", &a.Suitability) + delete(rawMsg, key) + case "suitabilityDetail": + err = unpopulate(val, "SuitabilityDetail", &a.SuitabilityDetail) + delete(rawMsg, key) + case "suitabilityExplanation": + err = unpopulate(val, "SuitabilityExplanation", &a.SuitabilityExplanation) + 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 Assessment. +func (a Assessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", a.ETag) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Assessment. +func (a *Assessment) 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 "eTag": + err = unpopulate(val, "ETag", &a.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "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 AssessmentOptions. +func (a AssessmentOptions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssessmentOptions. +func (a *AssessmentOptions) 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 "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AssessmentOptionsProperties. +func (a AssessmentOptionsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "reservedInstanceSupportedCurrencies", a.ReservedInstanceSupportedCurrencies) + populate(objectMap, "reservedInstanceSupportedLocations", a.ReservedInstanceSupportedLocations) + populate(objectMap, "reservedInstanceSupportedOffers", a.ReservedInstanceSupportedOffers) + populate(objectMap, "reservedInstanceVmFamilies", a.ReservedInstanceVMFamilies) + populate(objectMap, "vmFamilies", a.VMFamilies) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssessmentOptionsProperties. +func (a *AssessmentOptionsProperties) 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 "reservedInstanceSupportedCurrencies": + err = unpopulate(val, "ReservedInstanceSupportedCurrencies", &a.ReservedInstanceSupportedCurrencies) + delete(rawMsg, key) + case "reservedInstanceSupportedLocations": + err = unpopulate(val, "ReservedInstanceSupportedLocations", &a.ReservedInstanceSupportedLocations) + delete(rawMsg, key) + case "reservedInstanceSupportedOffers": + err = unpopulate(val, "ReservedInstanceSupportedOffers", &a.ReservedInstanceSupportedOffers) + delete(rawMsg, key) + case "reservedInstanceVmFamilies": + err = unpopulate(val, "ReservedInstanceVMFamilies", &a.ReservedInstanceVMFamilies) + delete(rawMsg, key) + case "vmFamilies": + err = unpopulate(val, "VMFamilies", &a.VMFamilies) + 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 AssessmentOptionsResultList. +func (a AssessmentOptionsResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssessmentOptionsResultList. +func (a *AssessmentOptionsResultList) 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 "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AssessmentProperties. +func (a AssessmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureDiskType", a.AzureDiskType) + populate(objectMap, "azureHybridUseBenefit", a.AzureHybridUseBenefit) + populate(objectMap, "azureLocation", a.AzureLocation) + populate(objectMap, "azureOfferCode", a.AzureOfferCode) + populate(objectMap, "azurePricingTier", a.AzurePricingTier) + populate(objectMap, "azureStorageRedundancy", a.AzureStorageRedundancy) + populate(objectMap, "azureVmFamilies", a.AzureVMFamilies) + populate(objectMap, "confidenceRatingInPercentage", a.ConfidenceRatingInPercentage) + populateTimeRFC3339(objectMap, "createdTimestamp", a.CreatedTimestamp) + populate(objectMap, "currency", a.Currency) + populate(objectMap, "discountPercentage", a.DiscountPercentage) + populate(objectMap, "eaSubscriptionId", a.EaSubscriptionID) + populate(objectMap, "monthlyBandwidthCost", a.MonthlyBandwidthCost) + populate(objectMap, "monthlyComputeCost", a.MonthlyComputeCost) + populate(objectMap, "monthlyPremiumStorageCost", a.MonthlyPremiumStorageCost) + populate(objectMap, "monthlyStandardSSDStorageCost", a.MonthlyStandardSSDStorageCost) + populate(objectMap, "monthlyStorageCost", a.MonthlyStorageCost) + populate(objectMap, "numberOfMachines", a.NumberOfMachines) + populate(objectMap, "percentile", a.Percentile) + populateTimeRFC3339(objectMap, "perfDataEndTime", a.PerfDataEndTime) + populateTimeRFC3339(objectMap, "perfDataStartTime", a.PerfDataStartTime) + populateTimeRFC3339(objectMap, "pricesTimestamp", a.PricesTimestamp) + populate(objectMap, "reservedInstance", a.ReservedInstance) + populate(objectMap, "scalingFactor", a.ScalingFactor) + populate(objectMap, "sizingCriterion", a.SizingCriterion) + populate(objectMap, "stage", a.Stage) + populate(objectMap, "status", a.Status) + populate(objectMap, "timeRange", a.TimeRange) + populateTimeRFC3339(objectMap, "updatedTimestamp", a.UpdatedTimestamp) + populate(objectMap, "vmUptime", a.VMUptime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssessmentProperties. +func (a *AssessmentProperties) 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 "azureDiskType": + err = unpopulate(val, "AzureDiskType", &a.AzureDiskType) + delete(rawMsg, key) + case "azureHybridUseBenefit": + err = unpopulate(val, "AzureHybridUseBenefit", &a.AzureHybridUseBenefit) + delete(rawMsg, key) + case "azureLocation": + err = unpopulate(val, "AzureLocation", &a.AzureLocation) + delete(rawMsg, key) + case "azureOfferCode": + err = unpopulate(val, "AzureOfferCode", &a.AzureOfferCode) + delete(rawMsg, key) + case "azurePricingTier": + err = unpopulate(val, "AzurePricingTier", &a.AzurePricingTier) + delete(rawMsg, key) + case "azureStorageRedundancy": + err = unpopulate(val, "AzureStorageRedundancy", &a.AzureStorageRedundancy) + delete(rawMsg, key) + case "azureVmFamilies": + err = unpopulate(val, "AzureVMFamilies", &a.AzureVMFamilies) + delete(rawMsg, key) + case "confidenceRatingInPercentage": + err = unpopulate(val, "ConfidenceRatingInPercentage", &a.ConfidenceRatingInPercentage) + delete(rawMsg, key) + case "createdTimestamp": + err = unpopulateTimeRFC3339(val, "CreatedTimestamp", &a.CreatedTimestamp) + delete(rawMsg, key) + case "currency": + err = unpopulate(val, "Currency", &a.Currency) + delete(rawMsg, key) + case "discountPercentage": + err = unpopulate(val, "DiscountPercentage", &a.DiscountPercentage) + delete(rawMsg, key) + case "eaSubscriptionId": + err = unpopulate(val, "EaSubscriptionID", &a.EaSubscriptionID) + delete(rawMsg, key) + case "monthlyBandwidthCost": + err = unpopulate(val, "MonthlyBandwidthCost", &a.MonthlyBandwidthCost) + delete(rawMsg, key) + case "monthlyComputeCost": + err = unpopulate(val, "MonthlyComputeCost", &a.MonthlyComputeCost) + delete(rawMsg, key) + case "monthlyPremiumStorageCost": + err = unpopulate(val, "MonthlyPremiumStorageCost", &a.MonthlyPremiumStorageCost) + delete(rawMsg, key) + case "monthlyStandardSSDStorageCost": + err = unpopulate(val, "MonthlyStandardSSDStorageCost", &a.MonthlyStandardSSDStorageCost) + delete(rawMsg, key) + case "monthlyStorageCost": + err = unpopulate(val, "MonthlyStorageCost", &a.MonthlyStorageCost) + delete(rawMsg, key) + case "numberOfMachines": + err = unpopulate(val, "NumberOfMachines", &a.NumberOfMachines) + delete(rawMsg, key) + case "percentile": + err = unpopulate(val, "Percentile", &a.Percentile) + delete(rawMsg, key) + case "perfDataEndTime": + err = unpopulateTimeRFC3339(val, "PerfDataEndTime", &a.PerfDataEndTime) + delete(rawMsg, key) + case "perfDataStartTime": + err = unpopulateTimeRFC3339(val, "PerfDataStartTime", &a.PerfDataStartTime) + delete(rawMsg, key) + case "pricesTimestamp": + err = unpopulateTimeRFC3339(val, "PricesTimestamp", &a.PricesTimestamp) + delete(rawMsg, key) + case "reservedInstance": + err = unpopulate(val, "ReservedInstance", &a.ReservedInstance) + delete(rawMsg, key) + case "scalingFactor": + err = unpopulate(val, "ScalingFactor", &a.ScalingFactor) + delete(rawMsg, key) + case "sizingCriterion": + err = unpopulate(val, "SizingCriterion", &a.SizingCriterion) + delete(rawMsg, key) + case "stage": + err = unpopulate(val, "Stage", &a.Stage) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + case "timeRange": + err = unpopulate(val, "TimeRange", &a.TimeRange) + delete(rawMsg, key) + case "updatedTimestamp": + err = unpopulateTimeRFC3339(val, "UpdatedTimestamp", &a.UpdatedTimestamp) + delete(rawMsg, key) + case "vmUptime": + err = unpopulate(val, "VMUptime", &a.VMUptime) + 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 AssessmentResultList. +func (a AssessmentResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssessmentResultList. +func (a *AssessmentResultList) 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 "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CollectorAgentProperties. +func (c CollectorAgentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populateTimeRFC3339(objectMap, "lastHeartbeatUtc", c.LastHeartbeatUTC) + populate(objectMap, "spnDetails", c.SpnDetails) + populate(objectMap, "version", c.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CollectorAgentProperties. +func (c *CollectorAgentProperties) 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 "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "lastHeartbeatUtc": + err = unpopulateTimeRFC3339(val, "LastHeartbeatUTC", &c.LastHeartbeatUTC) + delete(rawMsg, key) + case "spnDetails": + err = unpopulate(val, "SpnDetails", &c.SpnDetails) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &c.Version) + 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 CollectorBodyAgentSpnProperties. +func (c CollectorBodyAgentSpnProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applicationId", c.ApplicationID) + populate(objectMap, "audience", c.Audience) + populate(objectMap, "authority", c.Authority) + populate(objectMap, "objectId", c.ObjectID) + populate(objectMap, "tenantId", c.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CollectorBodyAgentSpnProperties. +func (c *CollectorBodyAgentSpnProperties) 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 "applicationId": + err = unpopulate(val, "ApplicationID", &c.ApplicationID) + delete(rawMsg, key) + case "audience": + err = unpopulate(val, "Audience", &c.Audience) + delete(rawMsg, key) + case "authority": + err = unpopulate(val, "Authority", &c.Authority) + delete(rawMsg, key) + case "objectId": + err = unpopulate(val, "ObjectID", &c.ObjectID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &c.TenantID) + 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 CollectorProperties. +func (c CollectorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "agentProperties", c.AgentProperties) + populate(objectMap, "createdTimestamp", c.CreatedTimestamp) + populate(objectMap, "discoverySiteId", c.DiscoverySiteID) + populate(objectMap, "updatedTimestamp", c.UpdatedTimestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CollectorProperties. +func (c *CollectorProperties) 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 "agentProperties": + err = unpopulate(val, "AgentProperties", &c.AgentProperties) + delete(rawMsg, key) + case "createdTimestamp": + err = unpopulate(val, "CreatedTimestamp", &c.CreatedTimestamp) + delete(rawMsg, key) + case "discoverySiteId": + err = unpopulate(val, "DiscoverySiteID", &c.DiscoverySiteID) + delete(rawMsg, key) + case "updatedTimestamp": + err = unpopulate(val, "UpdatedTimestamp", &c.UpdatedTimestamp) + 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 Disk. +func (d Disk) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", d.DisplayName) + populate(objectMap, "gigabytesAllocated", d.GigabytesAllocated) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Disk. +func (d *Disk) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &d.DisplayName) + delete(rawMsg, key) + case "gigabytesAllocated": + err = unpopulate(val, "GigabytesAllocated", &d.GigabytesAllocated) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DownloadURL. +func (d DownloadURL) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assessmentReportUrl", d.AssessmentReportURL) + populateTimeRFC3339(objectMap, "expirationTime", d.ExpirationTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DownloadURL. +func (d *DownloadURL) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "assessmentReportUrl": + err = unpopulate(val, "AssessmentReportURL", &d.AssessmentReportURL) + delete(rawMsg, key) + case "expirationTime": + err = unpopulateTimeRFC3339(val, "ExpirationTime", &d.ExpirationTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Group. +func (g Group) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", g.ETag) + populate(objectMap, "id", g.ID) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Group. +func (g *Group) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &g.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &g.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &g.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GroupBodyProperties. +func (g GroupBodyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "machines", g.Machines) + populate(objectMap, "operationType", g.OperationType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GroupBodyProperties. +func (g *GroupBodyProperties) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "machines": + err = unpopulate(val, "Machines", &g.Machines) + delete(rawMsg, key) + case "operationType": + err = unpopulate(val, "OperationType", &g.OperationType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GroupProperties. +func (g GroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "areAssessmentsRunning", g.AreAssessmentsRunning) + populate(objectMap, "assessments", g.Assessments) + populateTimeRFC3339(objectMap, "createdTimestamp", g.CreatedTimestamp) + populate(objectMap, "groupStatus", g.GroupStatus) + populate(objectMap, "groupType", g.GroupType) + populate(objectMap, "machineCount", g.MachineCount) + populateTimeRFC3339(objectMap, "updatedTimestamp", g.UpdatedTimestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GroupProperties. +func (g *GroupProperties) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "areAssessmentsRunning": + err = unpopulate(val, "AreAssessmentsRunning", &g.AreAssessmentsRunning) + delete(rawMsg, key) + case "assessments": + err = unpopulate(val, "Assessments", &g.Assessments) + delete(rawMsg, key) + case "createdTimestamp": + err = unpopulateTimeRFC3339(val, "CreatedTimestamp", &g.CreatedTimestamp) + delete(rawMsg, key) + case "groupStatus": + err = unpopulate(val, "GroupStatus", &g.GroupStatus) + delete(rawMsg, key) + case "groupType": + err = unpopulate(val, "GroupType", &g.GroupType) + delete(rawMsg, key) + case "machineCount": + err = unpopulate(val, "MachineCount", &g.MachineCount) + delete(rawMsg, key) + case "updatedTimestamp": + err = unpopulateTimeRFC3339(val, "UpdatedTimestamp", &g.UpdatedTimestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GroupResultList. +func (g GroupResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GroupResultList. +func (g *GroupResultList) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &g.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HyperVCollector. +func (h HyperVCollector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", h.ETag) + populate(objectMap, "id", h.ID) + populate(objectMap, "name", h.Name) + populate(objectMap, "properties", h.Properties) + populate(objectMap, "type", h.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HyperVCollector. +func (h *HyperVCollector) 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", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &h.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &h.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &h.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &h.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &h.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HyperVCollectorList. +func (h HyperVCollectorList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", h.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HyperVCollectorList. +func (h *HyperVCollectorList) 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", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &h.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImportCollector. +func (i ImportCollector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", i.ETag) + populate(objectMap, "id", i.ID) + populate(objectMap, "name", i.Name) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImportCollector. +func (i *ImportCollector) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &i.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &i.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImportCollectorList. +func (i ImportCollectorList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImportCollectorList. +func (i *ImportCollectorList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &i.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImportCollectorProperties. +func (i ImportCollectorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "createdTimestamp", i.CreatedTimestamp) + populate(objectMap, "discoverySiteId", i.DiscoverySiteID) + populate(objectMap, "updatedTimestamp", i.UpdatedTimestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImportCollectorProperties. +func (i *ImportCollectorProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdTimestamp": + err = unpopulate(val, "CreatedTimestamp", &i.CreatedTimestamp) + delete(rawMsg, key) + case "discoverySiteId": + err = unpopulate(val, "DiscoverySiteID", &i.DiscoverySiteID) + delete(rawMsg, key) + case "updatedTimestamp": + err = unpopulate(val, "UpdatedTimestamp", &i.UpdatedTimestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Machine. +func (m Machine) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", m.ETag) + populate(objectMap, "id", m.ID) + populate(objectMap, "name", m.Name) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "type", m.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Machine. +func (m *Machine) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &m.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &m.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &m.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MachineProperties. +func (m MachineProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "bootType", m.BootType) + populateTimeRFC3339(objectMap, "createdTimestamp", m.CreatedTimestamp) + populate(objectMap, "datacenterManagementServerArmId", m.DatacenterManagementServerArmID) + populate(objectMap, "datacenterManagementServerName", m.DatacenterManagementServerName) + populate(objectMap, "description", m.Description) + populate(objectMap, "discoveryMachineArmId", m.DiscoveryMachineArmID) + populate(objectMap, "disks", m.Disks) + populate(objectMap, "displayName", m.DisplayName) + populate(objectMap, "groups", m.Groups) + populate(objectMap, "megabytesOfMemory", m.MegabytesOfMemory) + populate(objectMap, "networkAdapters", m.NetworkAdapters) + populate(objectMap, "numberOfCores", m.NumberOfCores) + populate(objectMap, "operatingSystemName", m.OperatingSystemName) + populate(objectMap, "operatingSystemType", m.OperatingSystemType) + populate(objectMap, "operatingSystemVersion", m.OperatingSystemVersion) + populateTimeRFC3339(objectMap, "updatedTimestamp", m.UpdatedTimestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MachineProperties. +func (m *MachineProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "bootType": + err = unpopulate(val, "BootType", &m.BootType) + delete(rawMsg, key) + case "createdTimestamp": + err = unpopulateTimeRFC3339(val, "CreatedTimestamp", &m.CreatedTimestamp) + delete(rawMsg, key) + case "datacenterManagementServerArmId": + err = unpopulate(val, "DatacenterManagementServerArmID", &m.DatacenterManagementServerArmID) + delete(rawMsg, key) + case "datacenterManagementServerName": + err = unpopulate(val, "DatacenterManagementServerName", &m.DatacenterManagementServerName) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &m.Description) + delete(rawMsg, key) + case "discoveryMachineArmId": + err = unpopulate(val, "DiscoveryMachineArmID", &m.DiscoveryMachineArmID) + delete(rawMsg, key) + case "disks": + err = unpopulate(val, "Disks", &m.Disks) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &m.DisplayName) + delete(rawMsg, key) + case "groups": + err = unpopulate(val, "Groups", &m.Groups) + delete(rawMsg, key) + case "megabytesOfMemory": + err = unpopulate(val, "MegabytesOfMemory", &m.MegabytesOfMemory) + delete(rawMsg, key) + case "networkAdapters": + err = unpopulate(val, "NetworkAdapters", &m.NetworkAdapters) + delete(rawMsg, key) + case "numberOfCores": + err = unpopulate(val, "NumberOfCores", &m.NumberOfCores) + delete(rawMsg, key) + case "operatingSystemName": + err = unpopulate(val, "OperatingSystemName", &m.OperatingSystemName) + delete(rawMsg, key) + case "operatingSystemType": + err = unpopulate(val, "OperatingSystemType", &m.OperatingSystemType) + delete(rawMsg, key) + case "operatingSystemVersion": + err = unpopulate(val, "OperatingSystemVersion", &m.OperatingSystemVersion) + delete(rawMsg, key) + case "updatedTimestamp": + err = unpopulateTimeRFC3339(val, "UpdatedTimestamp", &m.UpdatedTimestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MachineResultList. +func (m MachineResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MachineResultList. +func (m *MachineResultList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &m.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &m.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkAdapter. +func (n NetworkAdapter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", n.DisplayName) + populate(objectMap, "ipAddresses", n.IPAddresses) + populate(objectMap, "macAddress", n.MacAddress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkAdapter. +func (n *NetworkAdapter) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &n.DisplayName) + delete(rawMsg, key) + case "ipAddresses": + err = unpopulate(val, "IPAddresses", &n.IPAddresses) + delete(rawMsg, key) + case "macAddress": + err = unpopulate(val, "MacAddress", &n.MacAddress) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + 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 "display": + err = unpopulate(val, "Display", &o.Display) + 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]any) + 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 OperationResultList. +func (o OperationResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationResultList. +func (o *OperationResultList) 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 "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 PrivateEndpointConnection. +func (p PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", p.ETag) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnection. +func (p *PrivateEndpointConnection) 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 "eTag": + err = unpopulate(val, "ETag", &p.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + 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 PrivateEndpointConnectionCollection. +func (p PrivateEndpointConnectionCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnectionCollection. +func (p *PrivateEndpointConnectionCollection) 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 "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionProperties. +func (p PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "privateEndpoint", p.PrivateEndpoint) + populate(objectMap, "privateLinkServiceConnectionState", p.PrivateLinkServiceConnectionState) + populate(objectMap, "provisioningState", p.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnectionProperties. +func (p *PrivateEndpointConnectionProperties) 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 "privateEndpoint": + err = unpopulate(val, "PrivateEndpoint", &p.PrivateEndpoint) + delete(rawMsg, key) + case "privateLinkServiceConnectionState": + err = unpopulate(val, "PrivateLinkServiceConnectionState", &p.PrivateLinkServiceConnectionState) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + 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 PrivateLinkResource. +func (p PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResource. +func (p *PrivateLinkResource) 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 "properties": + err = unpopulate(val, "Properties", &p.Properties) + 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 PrivateLinkResourceCollection. +func (p PrivateLinkResourceCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceCollection. +func (p *PrivateLinkResourceCollection) 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 "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. +func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "groupId", p.GroupID) + populate(objectMap, "requiredMembers", p.RequiredMembers) + populate(objectMap, "requiredZoneNames", p.RequiredZoneNames) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceProperties. +func (p *PrivateLinkResourceProperties) 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 "groupId": + err = unpopulate(val, "GroupID", &p.GroupID) + delete(rawMsg, key) + case "requiredMembers": + err = unpopulate(val, "RequiredMembers", &p.RequiredMembers) + delete(rawMsg, key) + case "requiredZoneNames": + err = unpopulate(val, "RequiredZoneNames", &p.RequiredZoneNames) + 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 PrivateLinkServiceConnectionState. +func (p PrivateLinkServiceConnectionState) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionsRequired", p.ActionsRequired) + populate(objectMap, "description", p.Description) + populate(objectMap, "status", p.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkServiceConnectionState. +func (p *PrivateLinkServiceConnectionState) 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 "actionsRequired": + err = unpopulate(val, "ActionsRequired", &p.ActionsRequired) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + 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 Project. +func (p Project) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", p.ETag) + populate(objectMap, "id", p.ID) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", &p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Project. +func (p *Project) 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 "eTag": + err = unpopulate(val, "ETag", &p.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + 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 ProjectProperties. +func (p ProjectProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assessmentSolutionId", p.AssessmentSolutionID) + populateTimeRFC3339(objectMap, "createdTimestamp", p.CreatedTimestamp) + populate(objectMap, "customerStorageAccountArmId", p.CustomerStorageAccountArmID) + populate(objectMap, "customerWorkspaceId", p.CustomerWorkspaceID) + populate(objectMap, "customerWorkspaceLocation", p.CustomerWorkspaceLocation) + populateTimeRFC3339(objectMap, "lastAssessmentTimestamp", p.LastAssessmentTimestamp) + populate(objectMap, "numberOfAssessments", p.NumberOfAssessments) + populate(objectMap, "numberOfGroups", p.NumberOfGroups) + populate(objectMap, "numberOfMachines", p.NumberOfMachines) + populate(objectMap, "privateEndpointConnections", p.PrivateEndpointConnections) + populate(objectMap, "projectStatus", p.ProjectStatus) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "publicNetworkAccess", p.PublicNetworkAccess) + populate(objectMap, "serviceEndpoint", p.ServiceEndpoint) + populateTimeRFC3339(objectMap, "updatedTimestamp", p.UpdatedTimestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectProperties. +func (p *ProjectProperties) 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 "assessmentSolutionId": + err = unpopulate(val, "AssessmentSolutionID", &p.AssessmentSolutionID) + delete(rawMsg, key) + case "createdTimestamp": + err = unpopulateTimeRFC3339(val, "CreatedTimestamp", &p.CreatedTimestamp) + delete(rawMsg, key) + case "customerStorageAccountArmId": + err = unpopulate(val, "CustomerStorageAccountArmID", &p.CustomerStorageAccountArmID) + delete(rawMsg, key) + case "customerWorkspaceId": + err = unpopulate(val, "CustomerWorkspaceID", &p.CustomerWorkspaceID) + delete(rawMsg, key) + case "customerWorkspaceLocation": + err = unpopulate(val, "CustomerWorkspaceLocation", &p.CustomerWorkspaceLocation) + delete(rawMsg, key) + case "lastAssessmentTimestamp": + err = unpopulateTimeRFC3339(val, "LastAssessmentTimestamp", &p.LastAssessmentTimestamp) + delete(rawMsg, key) + case "numberOfAssessments": + err = unpopulate(val, "NumberOfAssessments", &p.NumberOfAssessments) + delete(rawMsg, key) + case "numberOfGroups": + err = unpopulate(val, "NumberOfGroups", &p.NumberOfGroups) + delete(rawMsg, key) + case "numberOfMachines": + err = unpopulate(val, "NumberOfMachines", &p.NumberOfMachines) + delete(rawMsg, key) + case "privateEndpointConnections": + err = unpopulate(val, "PrivateEndpointConnections", &p.PrivateEndpointConnections) + delete(rawMsg, key) + case "projectStatus": + err = unpopulate(val, "ProjectStatus", &p.ProjectStatus) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &p.PublicNetworkAccess) + delete(rawMsg, key) + case "serviceEndpoint": + err = unpopulate(val, "ServiceEndpoint", &p.ServiceEndpoint) + delete(rawMsg, key) + case "updatedTimestamp": + err = unpopulateTimeRFC3339(val, "UpdatedTimestamp", &p.UpdatedTimestamp) + 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 ProjectResultList. +func (p ProjectResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectResultList. +func (p *ProjectResultList) 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 "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceID. +func (r ResourceID) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceID. +func (r *ResourceID) 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) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerCollector. +func (s ServerCollector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", s.ETag) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerCollector. +func (s *ServerCollector) 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 "eTag": + err = unpopulate(val, "ETag", &s.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerCollectorList. +func (s ServerCollectorList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerCollectorList. +func (s *ServerCollectorList) 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 "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 UpdateGroupBody. +func (u UpdateGroupBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", u.ETag) + populate(objectMap, "properties", u.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateGroupBody. +func (u *UpdateGroupBody) 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 "eTag": + err = unpopulate(val, "ETag", &u.ETag) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &u.Properties) + 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 VMFamily. +func (v VMFamily) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "category", v.Category) + populate(objectMap, "familyName", v.FamilyName) + populate(objectMap, "targetLocations", v.TargetLocations) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMFamily. +func (v *VMFamily) 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 "category": + err = unpopulate(val, "Category", &v.Category) + delete(rawMsg, key) + case "familyName": + err = unpopulate(val, "FamilyName", &v.FamilyName) + delete(rawMsg, key) + case "targetLocations": + err = unpopulate(val, "TargetLocations", &v.TargetLocations) + 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 VMUptime. +func (v VMUptime) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "daysPerMonth", v.DaysPerMonth) + populate(objectMap, "hoursPerDay", v.HoursPerDay) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMUptime. +func (v *VMUptime) 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 "daysPerMonth": + err = unpopulate(val, "DaysPerMonth", &v.DaysPerMonth) + delete(rawMsg, key) + case "hoursPerDay": + err = unpopulate(val, "HoursPerDay", &v.HoursPerDay) + 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 VMwareCollector. +func (v VMwareCollector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", v.ETag) + populate(objectMap, "id", v.ID) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMwareCollector. +func (v *VMwareCollector) 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 "eTag": + err = unpopulate(val, "ETag", &v.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &v.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + case "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 VMwareCollectorList. +func (v VMwareCollectorList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMwareCollectorList. +func (v *VMwareCollectorList) 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 "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]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_operations_client.go b/sdk/resourcemanager/migrate/armmigrate/operations_client.go similarity index 75% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_operations_client.go rename to sdk/resourcemanager/migrate/armmigrate/operations_client.go index ba699d475c79..1c98b4ad592c 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_operations_client.go +++ b/sdk/resourcemanager/migrate/armmigrate/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 armmigrate @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,36 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Get a list of REST API supported by Microsoft.Migrate provider. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -62,7 +52,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -77,7 +67,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Migrate/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/migrate/armmigrate/operations_client_example_test.go b/sdk/resourcemanager/migrate/armmigrate/operations_client_example_test.go new file mode 100644 index 000000000000..010dbea04578 --- /dev/null +++ b/sdk/resourcemanager/migrate/armmigrate/operations_client_example_test.go @@ -0,0 +1,66 @@ +//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 armmigrate_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/migrate/armmigrate" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Operations_List.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationResultList = armmigrate.OperationResultList{ + // Value: []*armmigrate.Operation{ + // { + // Name: to.Ptr("Read"), + // Display: &armmigrate.OperationDisplay{ + // Description: to.Ptr("Reads a project"), + // Operation: to.Ptr("Read"), + // Provider: to.Ptr("Microsoft.Migrate"), + // Resource: to.Ptr("Microsoft.Migrate/assessmentProjects"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Write"), + // Display: &armmigrate.OperationDisplay{ + // Description: to.Ptr("Creates or updates a project"), + // Operation: to.Ptr("Write"), + // Provider: to.Ptr("Microsoft.Migrate"), + // Resource: to.Ptr("Microsoft.Migrate/assessmentProjects"), + // }, + // Origin: to.Ptr("user,system"), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_privateendpointconnection_client.go b/sdk/resourcemanager/migrate/armmigrate/privateendpointconnection_client.go similarity index 84% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_privateendpointconnection_client.go rename to sdk/resourcemanager/migrate/armmigrate/privateendpointconnection_client.go index 48ce4467d735..58df0c9b354c 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_privateendpointconnection_client.go +++ b/sdk/resourcemanager/migrate/armmigrate/privateendpointconnection_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 armmigrate @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,49 +24,41 @@ import ( // PrivateEndpointConnectionClient contains the methods for the PrivateEndpointConnection group. // Don't use this type directly, use NewPrivateEndpointConnectionClient() instead. type PrivateEndpointConnectionClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPrivateEndpointConnectionClient creates a new instance of PrivateEndpointConnectionClient with the specified values. -// subscriptionID - Azure Subscription Id in which project was created. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription Id in which project was created. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPrivateEndpointConnectionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PrivateEndpointConnectionClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PrivateEndpointConnectionClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Delete - Delete the private endpoint connection from the project. T. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// privateEndpointConnectionName - Unique name of a private endpoint connection within a project. -// options - PrivateEndpointConnectionClientDeleteOptions contains the optional parameters for the PrivateEndpointConnectionClient.Delete -// method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - privateEndpointConnectionName - Unique name of a private endpoint connection within a project. +// - options - PrivateEndpointConnectionClientDeleteOptions contains the optional parameters for the PrivateEndpointConnectionClient.Delete +// method. func (client *PrivateEndpointConnectionClient) Delete(ctx context.Context, resourceGroupName string, projectName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionClientDeleteOptions) (PrivateEndpointConnectionClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, projectName, privateEndpointConnectionName, options) if err != nil { return PrivateEndpointConnectionClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionClientDeleteResponse{}, err } @@ -96,7 +87,7 @@ func (client *PrivateEndpointConnectionClient) deleteCreateRequest(ctx context.C return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -119,18 +110,19 @@ func (client *PrivateEndpointConnectionClient) deleteHandleResponse(resp *http.R // Get - Get information related to a specific private endpoint connection in the project. Returns a json object of type 'privateEndpointConnections' // as specified in the models section. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// privateEndpointConnectionName - Unique name of a private endpoint connection within a project. -// options - PrivateEndpointConnectionClientGetOptions contains the optional parameters for the PrivateEndpointConnectionClient.Get -// method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - privateEndpointConnectionName - Unique name of a private endpoint connection within a project. +// - options - PrivateEndpointConnectionClientGetOptions contains the optional parameters for the PrivateEndpointConnectionClient.Get +// method. func (client *PrivateEndpointConnectionClient) Get(ctx context.Context, resourceGroupName string, projectName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionClientGetOptions) (PrivateEndpointConnectionClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, projectName, privateEndpointConnectionName, options) if err != nil { return PrivateEndpointConnectionClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionClientGetResponse{}, err } @@ -159,7 +151,7 @@ func (client *PrivateEndpointConnectionClient) getCreateRequest(ctx context.Cont return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -185,17 +177,18 @@ func (client *PrivateEndpointConnectionClient) getHandleResponse(resp *http.Resp // ListByProject - Get all private endpoint connections in the project. Returns a json array of objects of type 'privateEndpointConnections' // as specified in the Models section. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// options - PrivateEndpointConnectionClientListByProjectOptions contains the optional parameters for the PrivateEndpointConnectionClient.ListByProject -// method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - options - PrivateEndpointConnectionClientListByProjectOptions contains the optional parameters for the PrivateEndpointConnectionClient.ListByProject +// method. func (client *PrivateEndpointConnectionClient) ListByProject(ctx context.Context, resourceGroupName string, projectName string, options *PrivateEndpointConnectionClientListByProjectOptions) (PrivateEndpointConnectionClientListByProjectResponse, error) { req, err := client.listByProjectCreateRequest(ctx, resourceGroupName, projectName, options) if err != nil { return PrivateEndpointConnectionClientListByProjectResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionClientListByProjectResponse{}, err } @@ -220,7 +213,7 @@ func (client *PrivateEndpointConnectionClient) listByProjectCreateRequest(ctx co return nil, errors.New("parameter projectName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -245,18 +238,19 @@ func (client *PrivateEndpointConnectionClient) listByProjectHandleResponse(resp // Update - Update a specific private endpoint connection in the project. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// privateEndpointConnectionName - Unique name of a private endpoint connection within a project. -// options - PrivateEndpointConnectionClientUpdateOptions contains the optional parameters for the PrivateEndpointConnectionClient.Update -// method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - privateEndpointConnectionName - Unique name of a private endpoint connection within a project. +// - options - PrivateEndpointConnectionClientUpdateOptions contains the optional parameters for the PrivateEndpointConnectionClient.Update +// method. func (client *PrivateEndpointConnectionClient) Update(ctx context.Context, resourceGroupName string, projectName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionClientUpdateOptions) (PrivateEndpointConnectionClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, projectName, privateEndpointConnectionName, options) if err != nil { return PrivateEndpointConnectionClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionClientUpdateResponse{}, err } @@ -285,7 +279,7 @@ func (client *PrivateEndpointConnectionClient) updateCreateRequest(ctx context.C return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/migrate/armmigrate/privateendpointconnection_client_example_test.go b/sdk/resourcemanager/migrate/armmigrate/privateendpointconnection_client_example_test.go new file mode 100644 index 000000000000..9d5406ed8d4c --- /dev/null +++ b/sdk/resourcemanager/migrate/armmigrate/privateendpointconnection_client_example_test.go @@ -0,0 +1,156 @@ +//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 armmigrate_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/migrate/armmigrate" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/PrivateEndpointConnections_ListByProject.json +func ExamplePrivateEndpointConnectionClient_ListByProject() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPrivateEndpointConnectionClient().ListByProject(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateEndpointConnectionCollection = armmigrate.PrivateEndpointConnectionCollection{ + // Value: []*armmigrate.PrivateEndpointConnection{ + // { + // Name: to.Ptr("custestpece80project3980pe.7e35576b-3df4-478e-9759-f64351cf4f43"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/privateEndpointConnections"), + // ETag: to.Ptr("\"00009300-0000-0300-0000-602b967b0000\""), + // ID: to.Ptr("/subscriptions/4bd2aa0f-2bd2-4d67-91a8-5a4533d58600/resourceGroups/madhavicus/providers/Microsoft.Migrate/assessmentprojects/custestpece80project/privateEndpointConnections/custestpece80project3980pe.7e35576b-3df4-478e-9759-f64351cf4f43"), + // Properties: &armmigrate.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmigrate.ResourceID{ + // ID: to.Ptr("/subscriptions/31be0ff4-c932-4cb3-8efc-efa411d79280/resourceGroups/PrivLink-SelfHost/providers/Microsoft.Network/privateEndpoints/custestpece80project3980pe"), + // }, + // PrivateLinkServiceConnectionState: &armmigrate.PrivateLinkServiceConnectionState{ + // ActionsRequired: to.Ptr(""), + // Status: to.Ptr(armmigrate.PrivateLinkServiceConnectionStateStatusApproved), + // }, + // ProvisioningState: to.Ptr(armmigrate.PrivateEndpointConnectionPropertiesProvisioningStateSucceeded), + // }, + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/PrivateEndpointConnections_Get.json +func ExamplePrivateEndpointConnectionClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPrivateEndpointConnectionClient().Get(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "custestpece80project3980pe.7e35576b-3df4-478e-9759-f64351cf4f43", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateEndpointConnection = armmigrate.PrivateEndpointConnection{ + // Name: to.Ptr("custestpece80project3980pe.7e35576b-3df4-478e-9759-f64351cf4f43"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/privateEndpointConnections"), + // ETag: to.Ptr("\"00009300-0000-0300-0000-602b967b0000\""), + // ID: to.Ptr("/subscriptions/4bd2aa0f-2bd2-4d67-91a8-5a4533d58600/resourceGroups/madhavicus/providers/Microsoft.Migrate/assessmentprojects/custestpece80project/privateEndpointConnections/custestpece80project3980pe.7e35576b-3df4-478e-9759-f64351cf4f43"), + // Properties: &armmigrate.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmigrate.ResourceID{ + // ID: to.Ptr("/subscriptions/31be0ff4-c932-4cb3-8efc-efa411d79280/resourceGroups/PrivLink-SelfHost/providers/Microsoft.Network/privateEndpoints/custestpece80project3980pe"), + // }, + // PrivateLinkServiceConnectionState: &armmigrate.PrivateLinkServiceConnectionState{ + // ActionsRequired: to.Ptr(""), + // Status: to.Ptr(armmigrate.PrivateLinkServiceConnectionStateStatusApproved), + // }, + // ProvisioningState: to.Ptr(armmigrate.PrivateEndpointConnectionPropertiesProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/PrivateEndpointConnections_Create.json +func ExamplePrivateEndpointConnectionClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPrivateEndpointConnectionClient().Update(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "custestpece80project3980pe.7e35576b-3df4-478e-9759-f64351cf4f43", &armmigrate.PrivateEndpointConnectionClientUpdateOptions{PrivateEndpointConnectionBody: &armmigrate.PrivateEndpointConnection{ + ETag: to.Ptr("\"00009300-0000-0300-0000-602b967b0000\""), + Properties: &armmigrate.PrivateEndpointConnectionProperties{ + PrivateLinkServiceConnectionState: &armmigrate.PrivateLinkServiceConnectionState{ + ActionsRequired: to.Ptr(""), + Status: to.Ptr(armmigrate.PrivateLinkServiceConnectionStateStatusApproved), + }, + }, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateEndpointConnection = armmigrate.PrivateEndpointConnection{ + // Name: to.Ptr("custestpece80project3980pe.7e35576b-3df4-478e-9759-f64351cf4f43"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/privateEndpointConnections"), + // ETag: to.Ptr("\"00009300-0000-0300-0000-602b967b0000\""), + // ID: to.Ptr("/subscriptions/4bd2aa0f-2bd2-4d67-91a8-5a4533d58600/resourceGroups/madhavicus/providers/Microsoft.Migrate/assessmentprojects/custestpece80project/privateEndpointConnections/custestpece80project3980pe.7e35576b-3df4-478e-9759-f64351cf4f43"), + // Properties: &armmigrate.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmigrate.ResourceID{ + // ID: to.Ptr("/subscriptions/31be0ff4-c932-4cb3-8efc-efa411d79280/resourceGroups/PrivLink-SelfHost/providers/Microsoft.Network/privateEndpoints/custestpece80project3980pe"), + // }, + // PrivateLinkServiceConnectionState: &armmigrate.PrivateLinkServiceConnectionState{ + // ActionsRequired: to.Ptr(""), + // Status: to.Ptr(armmigrate.PrivateLinkServiceConnectionStateStatusPending), + // }, + // ProvisioningState: to.Ptr(armmigrate.PrivateEndpointConnectionPropertiesProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/PrivateEndpointConnections_Delete.json +func ExamplePrivateEndpointConnectionClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewPrivateEndpointConnectionClient().Delete(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "custestpece80project3980pe.7e35576b-3df4-478e-9759-f64351cf4f43", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_privatelinkresource_client.go b/sdk/resourcemanager/migrate/armmigrate/privatelinkresource_client.go similarity index 82% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_privatelinkresource_client.go rename to sdk/resourcemanager/migrate/armmigrate/privatelinkresource_client.go index 947fa6996651..6cb641652821 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_privatelinkresource_client.go +++ b/sdk/resourcemanager/migrate/armmigrate/privatelinkresource_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 armmigrate @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,31 +24,22 @@ import ( // PrivateLinkResourceClient contains the methods for the PrivateLinkResource group. // Don't use this type directly, use NewPrivateLinkResourceClient() instead. type PrivateLinkResourceClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPrivateLinkResourceClient creates a new instance of PrivateLinkResourceClient with the specified values. -// subscriptionID - Azure Subscription Id in which project was created. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription Id in which project was created. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPrivateLinkResourceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkResourceClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PrivateLinkResourceClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PrivateLinkResourceClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -57,17 +47,18 @@ func NewPrivateLinkResourceClient(subscriptionID string, credential azcore.Token // Get - Get information related to a specific private Link Resource in the project. Returns a json object of type 'privateLinkResources' // as specified in the models section. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// privateLinkResourceName - Unique name of a private link resource within a project. -// options - PrivateLinkResourceClientGetOptions contains the optional parameters for the PrivateLinkResourceClient.Get method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - privateLinkResourceName - Unique name of a private link resource within a project. +// - options - PrivateLinkResourceClientGetOptions contains the optional parameters for the PrivateLinkResourceClient.Get method. func (client *PrivateLinkResourceClient) Get(ctx context.Context, resourceGroupName string, projectName string, privateLinkResourceName string, options *PrivateLinkResourceClientGetOptions) (PrivateLinkResourceClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, projectName, privateLinkResourceName, options) if err != nil { return PrivateLinkResourceClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkResourceClientGetResponse{}, err } @@ -96,7 +87,7 @@ func (client *PrivateLinkResourceClient) getCreateRequest(ctx context.Context, r return nil, errors.New("parameter privateLinkResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateLinkResourceName}", url.PathEscape(privateLinkResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -122,17 +113,18 @@ func (client *PrivateLinkResourceClient) getHandleResponse(resp *http.Response) // ListByProject - Get all private link resources created in the project. Returns a json array of objects of type 'privateLinkResources' // as specified in the Models section. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// options - PrivateLinkResourceClientListByProjectOptions contains the optional parameters for the PrivateLinkResourceClient.ListByProject -// method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - options - PrivateLinkResourceClientListByProjectOptions contains the optional parameters for the PrivateLinkResourceClient.ListByProject +// method. func (client *PrivateLinkResourceClient) ListByProject(ctx context.Context, resourceGroupName string, projectName string, options *PrivateLinkResourceClientListByProjectOptions) (PrivateLinkResourceClientListByProjectResponse, error) { req, err := client.listByProjectCreateRequest(ctx, resourceGroupName, projectName, options) if err != nil { return PrivateLinkResourceClientListByProjectResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkResourceClientListByProjectResponse{}, err } @@ -157,7 +149,7 @@ func (client *PrivateLinkResourceClient) listByProjectCreateRequest(ctx context. return nil, errors.New("parameter projectName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/migrate/armmigrate/privatelinkresource_client_example_test.go b/sdk/resourcemanager/migrate/armmigrate/privatelinkresource_client_example_test.go new file mode 100644 index 000000000000..b4db883810ed --- /dev/null +++ b/sdk/resourcemanager/migrate/armmigrate/privatelinkresource_client_example_test.go @@ -0,0 +1,85 @@ +//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 armmigrate_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/migrate/armmigrate" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/PrivateLinkResources_Get.json +func ExamplePrivateLinkResourceClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPrivateLinkResourceClient().Get(ctx, "madhavicus", "custestpece80project", "Default", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateLinkResource = armmigrate.PrivateLinkResource{ + // Name: to.Ptr("Default"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/privateLinkResources"), + // ID: to.Ptr("/subscriptions/4bd2aa0f-2bd2-4d67-91a8-5a4533d58600/resourceGroups/madhavicus/providers/Microsoft.Migrate/assessmentprojects/custestpece80project/privateLinkResources/Default"), + // Properties: &armmigrate.PrivateLinkResourceProperties{ + // GroupID: to.Ptr("Default"), + // RequiredMembers: []*string{ + // to.Ptr("CollectorAgent")}, + // RequiredZoneNames: []*string{ + // to.Ptr("privatelink.prod.migration.windowsazure.com")}, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/PrivateLinkResources_ListByProject.json +func ExamplePrivateLinkResourceClient_ListByProject() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPrivateLinkResourceClient().ListByProject(ctx, "madhavicus", "custestpece80project", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateLinkResourceCollection = armmigrate.PrivateLinkResourceCollection{ + // Value: []*armmigrate.PrivateLinkResource{ + // { + // Name: to.Ptr("Default"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/privateLinkResources"), + // ID: to.Ptr("/subscriptions/4bd2aa0f-2bd2-4d67-91a8-5a4533d58600/resourceGroups/madhavicus/providers/Microsoft.Migrate/assessmentprojects/custestpece80project/privateLinkResources/Default"), + // Properties: &armmigrate.PrivateLinkResourceProperties{ + // GroupID: to.Ptr("Default"), + // RequiredMembers: []*string{ + // to.Ptr("CollectorAgent")}, + // RequiredZoneNames: []*string{ + // to.Ptr("privatelink.prod.migration.windowsazure.com")}, + // }, + // }}, + // } +} diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_projects_client.go b/sdk/resourcemanager/migrate/armmigrate/projects_client.go similarity index 87% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_projects_client.go rename to sdk/resourcemanager/migrate/armmigrate/projects_client.go index 36f51b6e1348..3f4356b67d29 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_projects_client.go +++ b/sdk/resourcemanager/migrate/armmigrate/projects_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 armmigrate @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,49 +24,41 @@ import ( // ProjectsClient contains the methods for the Projects group. // Don't use this type directly, use NewProjectsClient() instead. type ProjectsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewProjectsClient creates a new instance of ProjectsClient with the specified values. -// subscriptionID - Azure Subscription Id in which project was created. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription Id in which project was created. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewProjectsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProjectsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ProjectsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ProjectsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // AssessmentOptions - Get all available options for the properties of an assessment on a project. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// assessmentOptionsName - Name of the assessment options. The only name accepted in default. -// options - ProjectsClientAssessmentOptionsOptions contains the optional parameters for the ProjectsClient.AssessmentOptions -// method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - assessmentOptionsName - Name of the assessment options. The only name accepted in default. +// - options - ProjectsClientAssessmentOptionsOptions contains the optional parameters for the ProjectsClient.AssessmentOptions +// method. func (client *ProjectsClient) AssessmentOptions(ctx context.Context, resourceGroupName string, projectName string, assessmentOptionsName string, options *ProjectsClientAssessmentOptionsOptions) (ProjectsClientAssessmentOptionsResponse, error) { req, err := client.assessmentOptionsCreateRequest(ctx, resourceGroupName, projectName, assessmentOptionsName, options) if err != nil { return ProjectsClientAssessmentOptionsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProjectsClientAssessmentOptionsResponse{}, err } @@ -96,7 +87,7 @@ func (client *ProjectsClient) assessmentOptionsCreateRequest(ctx context.Context return nil, errors.New("parameter assessmentOptionsName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assessmentOptionsName}", url.PathEscape(assessmentOptionsName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -120,12 +111,12 @@ func (client *ProjectsClient) assessmentOptionsHandleResponse(resp *http.Respons } // NewAssessmentOptionsListPager - Gets list of all available options for the properties of an assessment on a project. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// options - ProjectsClientAssessmentOptionsListOptions contains the optional parameters for the ProjectsClient.AssessmentOptionsList -// method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - options - ProjectsClientAssessmentOptionsListOptions contains the optional parameters for the ProjectsClient.NewAssessmentOptionsListPager +// method. func (client *ProjectsClient) NewAssessmentOptionsListPager(resourceGroupName string, projectName string, options *ProjectsClientAssessmentOptionsListOptions) *runtime.Pager[ProjectsClientAssessmentOptionsListResponse] { return runtime.NewPager(runtime.PagingHandler[ProjectsClientAssessmentOptionsListResponse]{ More: func(page ProjectsClientAssessmentOptionsListResponse) bool { @@ -136,7 +127,7 @@ func (client *ProjectsClient) NewAssessmentOptionsListPager(resourceGroupName st if err != nil { return ProjectsClientAssessmentOptionsListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProjectsClientAssessmentOptionsListResponse{}, err } @@ -163,7 +154,7 @@ func (client *ProjectsClient) assessmentOptionsListCreateRequest(ctx context.Con return nil, errors.New("parameter projectName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -188,16 +179,17 @@ func (client *ProjectsClient) assessmentOptionsListHandleResponse(resp *http.Res // Create - Create a project with specified name. If a project already exists, update it. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// options - ProjectsClientCreateOptions contains the optional parameters for the ProjectsClient.Create method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - options - ProjectsClientCreateOptions contains the optional parameters for the ProjectsClient.Create method. func (client *ProjectsClient) Create(ctx context.Context, resourceGroupName string, projectName string, options *ProjectsClientCreateOptions) (ProjectsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, projectName, options) if err != nil { return ProjectsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProjectsClientCreateResponse{}, err } @@ -222,7 +214,7 @@ func (client *ProjectsClient) createCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter projectName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -250,16 +242,17 @@ func (client *ProjectsClient) createHandleResponse(resp *http.Response) (Project // Delete - Delete the project. Deleting non-existent project is a no-operation. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// options - ProjectsClientDeleteOptions contains the optional parameters for the ProjectsClient.Delete method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - options - ProjectsClientDeleteOptions contains the optional parameters for the ProjectsClient.Delete method. func (client *ProjectsClient) Delete(ctx context.Context, resourceGroupName string, projectName string, options *ProjectsClientDeleteOptions) (ProjectsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, projectName, options) if err != nil { return ProjectsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProjectsClientDeleteResponse{}, err } @@ -284,7 +277,7 @@ func (client *ProjectsClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter projectName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -306,16 +299,17 @@ func (client *ProjectsClient) deleteHandleResponse(resp *http.Response) (Project // Get - Get the project with the specified name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// options - ProjectsClientGetOptions contains the optional parameters for the ProjectsClient.Get method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - options - ProjectsClientGetOptions contains the optional parameters for the ProjectsClient.Get method. func (client *ProjectsClient) Get(ctx context.Context, resourceGroupName string, projectName string, options *ProjectsClientGetOptions) (ProjectsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, projectName, options) if err != nil { return ProjectsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProjectsClientGetResponse{}, err } @@ -340,7 +334,7 @@ func (client *ProjectsClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter projectName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -364,10 +358,10 @@ func (client *ProjectsClient) getHandleResponse(resp *http.Response) (ProjectsCl } // NewListPager - Get all the projects in the resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// options - ProjectsClientListOptions contains the optional parameters for the ProjectsClient.List method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - options - ProjectsClientListOptions contains the optional parameters for the ProjectsClient.NewListPager method. func (client *ProjectsClient) NewListPager(resourceGroupName string, options *ProjectsClientListOptions) *runtime.Pager[ProjectsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ProjectsClientListResponse]{ More: func(page ProjectsClientListResponse) bool { @@ -384,7 +378,7 @@ func (client *ProjectsClient) NewListPager(resourceGroupName string, options *Pr if err != nil { return ProjectsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProjectsClientListResponse{}, err } @@ -407,7 +401,7 @@ func (client *ProjectsClient) listCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -431,10 +425,10 @@ func (client *ProjectsClient) listHandleResponse(resp *http.Response) (ProjectsC } // NewListBySubscriptionPager - Get all the projects in the subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// options - ProjectsClientListBySubscriptionOptions contains the optional parameters for the ProjectsClient.ListBySubscription -// method. +// - options - ProjectsClientListBySubscriptionOptions contains the optional parameters for the ProjectsClient.NewListBySubscriptionPager +// method. func (client *ProjectsClient) NewListBySubscriptionPager(options *ProjectsClientListBySubscriptionOptions) *runtime.Pager[ProjectsClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[ProjectsClientListBySubscriptionResponse]{ More: func(page ProjectsClientListBySubscriptionResponse) bool { @@ -451,7 +445,7 @@ func (client *ProjectsClient) NewListBySubscriptionPager(options *ProjectsClient if err != nil { return ProjectsClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProjectsClientListBySubscriptionResponse{}, err } @@ -470,7 +464,7 @@ func (client *ProjectsClient) listBySubscriptionCreateRequest(ctx context.Contex return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -495,16 +489,17 @@ func (client *ProjectsClient) listBySubscriptionHandleResponse(resp *http.Respon // Update - Update a project with specified name. Supports partial updates, for example only tags can be provided. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// options - ProjectsClientUpdateOptions contains the optional parameters for the ProjectsClient.Update method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - options - ProjectsClientUpdateOptions contains the optional parameters for the ProjectsClient.Update method. func (client *ProjectsClient) Update(ctx context.Context, resourceGroupName string, projectName string, options *ProjectsClientUpdateOptions) (ProjectsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, projectName, options) if err != nil { return ProjectsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProjectsClientUpdateResponse{}, err } @@ -529,7 +524,7 @@ func (client *ProjectsClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter projectName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/migrate/armmigrate/projects_client_example_test.go b/sdk/resourcemanager/migrate/armmigrate/projects_client_example_test.go new file mode 100644 index 000000000000..98c179bb54dd --- /dev/null +++ b/sdk/resourcemanager/migrate/armmigrate/projects_client_example_test.go @@ -0,0 +1,1968 @@ +//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 armmigrate_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/migrate/armmigrate" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ProjectsInSubscription_List.json +func ExampleProjectsClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewProjectsClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ProjectResultList = armmigrate.ProjectResultList{ + // Value: []*armmigrate.Project{ + // { + // Name: to.Ptr("site1493ae9ea68project"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects"), + // ETag: to.Ptr("\"0500be57-0000-0300-0000-5cb893f70000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/SMSValidations/providers/Microsoft.Migrate/assessmentprojects/site1493ae9ea68project"), + // Location: to.Ptr("centralus"), + // Properties: &armmigrate.ProjectProperties{ + // AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/SMSValidations/providers/Microsoft.Migrate/MigrateProjects/SMSValidations-MigrateProject/Solutions/Servers-Assessment-ServerAssessment"), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-02-15T09:18:02.572288Z"); return t}()), + // CustomerWorkspaceID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/SMSValidations/providers/Microsoft.OperationalInsights/workspaces/test-haili-01"), + // CustomerWorkspaceLocation: to.Ptr("southeastasia"), + // LastAssessmentTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-18T15:12:55.2386626Z"); return t}()), + // NumberOfAssessments: to.Ptr[int32](12), + // NumberOfGroups: to.Ptr[int32](8), + // NumberOfMachines: to.Ptr[int32](26), + // ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + // ProvisioningState: to.Ptr(armmigrate.ProvisioningStateSucceeded), + // ServiceEndpoint: to.Ptr("https://asmsrvprodcus.prod.migration.windowsazure.com/"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-18T03:31:20.8362646Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("site1ad5aa6cc09project"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects"), + // ETag: to.Ptr("\"8300bdec-0000-0300-0000-5cd678410000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/ppValidation/providers/Microsoft.Migrate/assessmentprojects/site1ad5aa6cc09project"), + // Location: to.Ptr("centralus"), + // Properties: &armmigrate.ProjectProperties{ + // AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/ppValidation/providers/Microsoft.Migrate/MigrateProjects/ppValidation-MigrateProject/Solutions/Servers-Assessment-ServerAssessment"), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-02-18T16:46:46.0843984Z"); return t}()), + // LastAssessmentTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-11T07:22:41.5553328Z"); return t}()), + // NumberOfAssessments: to.Ptr[int32](12), + // NumberOfGroups: to.Ptr[int32](7), + // NumberOfMachines: to.Ptr[int32](29), + // ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + // ProvisioningState: to.Ptr(armmigrate.ProvisioningStateSucceeded), + // ServiceEndpoint: to.Ptr("https://asmsrvprodcus.prod.migration.windowsazure.com/"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-02-18T16:46:46.0843984Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("migrateproject0720project"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects"), + // ETag: to.Ptr("\"0d00efcf-0000-0300-0000-5d6fdac70000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/SDKUpgradeValidations/providers/Microsoft.Migrate/assessmentprojects/migrateproject0720project"), + // Location: to.Ptr("centralus"), + // Properties: &armmigrate.ProjectProperties{ + // AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/SDKUpgradeValidations/providers/Microsoft.Migrate/MigrateProjects/SDKUpgradeValidations-MigrateProject/Solutions/Servers-Assessment-ServerAssessment"), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-22T07:06:04.9725546Z"); return t}()), + // LastAssessmentTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-04T15:39:51.3046884Z"); return t}()), + // NumberOfAssessments: to.Ptr[int32](2), + // NumberOfGroups: to.Ptr[int32](1), + // NumberOfMachines: to.Ptr[int32](24), + // ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + // ProvisioningState: to.Ptr(armmigrate.ProvisioningStateSucceeded), + // ServiceEndpoint: to.Ptr("https://asmsrvprodcus.prod.migration.windowsazure.com/"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-22T07:06:04.9725546Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("migrateproject03acproject"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects"), + // ETag: to.Ptr("\"00004d14-0000-0300-0000-5cb820290000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/AccessibilityTesting/providers/Microsoft.Migrate/assessmentprojects/migrateproject03acproject"), + // Location: to.Ptr("centralus"), + // Properties: &armmigrate.ProjectProperties{ + // AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/AccessibilityTesting/providers/Microsoft.Migrate/MigrateProjects/AccessibilityTesting-MigrateProject/Solutions/Servers-Assessment-ServerAssessment"), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-18T06:53:59.4191419Z"); return t}()), + // NumberOfAssessments: to.Ptr[int32](0), + // NumberOfGroups: to.Ptr[int32](0), + // NumberOfMachines: to.Ptr[int32](16), + // ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + // ProvisioningState: to.Ptr(armmigrate.ProvisioningStateSucceeded), + // ServiceEndpoint: to.Ptr("https://asmsrvprodcus.prod.migration.windowsazure.com/"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-18T06:53:59.4191419Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("migrateprojecta961project"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects"), + // ETag: to.Ptr("\"1300df9f-0000-0300-0000-5d6e6d860000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/vmwaretesting/providers/Microsoft.Migrate/assessmentprojects/migrateprojecta961project"), + // Location: to.Ptr("centralus"), + // Properties: &armmigrate.ProjectProperties{ + // AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/vmwaretesting/providers/Microsoft.Migrate/MigrateProjects/vmwaretesting-MigrateProject/Solutions/Servers-Assessment-ServerAssessment"), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-20T11:59:42.7355994Z"); return t}()), + // CustomerWorkspaceID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/vmwaretesting/providers/Microsoft.OperationalInsights/workspaces/mahpar324211"), + // CustomerWorkspaceLocation: to.Ptr("westeurope"), + // NumberOfAssessments: to.Ptr[int32](0), + // NumberOfGroups: to.Ptr[int32](1), + // NumberOfMachines: to.Ptr[int32](47), + // ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + // ProvisioningState: to.Ptr(armmigrate.ProvisioningStateSucceeded), + // ServiceEndpoint: to.Ptr("https://asmsrvprodcus.prod.migration.windowsazure.com/"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-03T13:41:26.6775107Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("PortalGAValidations43bbproject"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects"), + // ETag: to.Ptr("\"02006b1f-0000-0300-0000-5d24a44a0000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/GARegressionTesting/providers/Microsoft.Migrate/assessmentprojects/PortalGAValidations43bbproject"), + // Location: to.Ptr("centralus"), + // Properties: &armmigrate.ProjectProperties{ + // AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/GARegressionTesting/providers/Microsoft.Migrate/MigrateProjects/PortalGAValidations/Solutions/Servers-Assessment-ServerAssessment"), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-04T03:56:50.853542Z"); return t}()), + // LastAssessmentTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-09T14:27:22.8856571Z"); return t}()), + // NumberOfAssessments: to.Ptr[int32](4), + // NumberOfGroups: to.Ptr[int32](4), + // NumberOfMachines: to.Ptr[int32](49), + // ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + // ProvisioningState: to.Ptr(armmigrate.ProvisioningStateSucceeded), + // ServiceEndpoint: to.Ptr("https://asmsrvprodcus.prod.migration.windowsazure.com/"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-04T03:56:50.853542Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("vaindana-pre-ga120dproject"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects"), + // ETag: to.Ptr("\"0400d98a-0000-0d00-0000-5cd3ff790000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/vaindana-migrate-ga-rg/providers/Microsoft.Migrate/assessmentprojects/vaindana-pre-ga120dproject"), + // Location: to.Ptr("westeurope"), + // Properties: &armmigrate.ProjectProperties{ + // AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/vaindana-migrate-ga-rg/providers/Microsoft.Migrate/MigrateProjects/vaindana-pre-ga/Solutions/Servers-Assessment-ServerAssessment"), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-08T15:09:37.8565484Z"); return t}()), + // CustomerWorkspaceID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/vaindana-migrate-ga-rg/providers/Microsoft.OperationalInsights/workspaces/vaindana-pre-ga-oms"), + // CustomerWorkspaceLocation: to.Ptr("westeurope"), + // LastAssessmentTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:22:48.9730444Z"); return t}()), + // NumberOfAssessments: to.Ptr[int32](2), + // NumberOfGroups: to.Ptr[int32](2), + // NumberOfMachines: to.Ptr[int32](14), + // ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + // ProvisioningState: to.Ptr(armmigrate.ProvisioningStateSucceeded), + // ServiceEndpoint: to.Ptr("https://asmsrvprodwe.prod.migration.windowsazure.com/"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-08T17:12:42.1788728Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("Mahesh-V2-Europe-Bugbash181eproject"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects"), + // ETag: to.Ptr("\"0b00349d-0000-0d00-0000-5d22eb5b0000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/Mahesh-RG-Eurpe-Bugbash/providers/Microsoft.Migrate/assessmentprojects/Mahesh-V2-Europe-Bugbash181eproject"), + // Location: to.Ptr("westeurope"), + // Properties: &armmigrate.ProjectProperties{ + // AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/Mahesh-RG-Eurpe-Bugbash/providers/Microsoft.Migrate/MigrateProjects/Mahesh-V2-Europe-Bugbash/Solutions/Servers-Assessment-ServerAssessment"), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T07:38:23.0345615Z"); return t}()), + // LastAssessmentTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-02T06:38:34.2815102Z"); return t}()), + // NumberOfAssessments: to.Ptr[int32](6), + // NumberOfGroups: to.Ptr[int32](3), + // NumberOfMachines: to.Ptr[int32](36), + // ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + // ProvisioningState: to.Ptr(armmigrate.ProvisioningStateSucceeded), + // ServiceEndpoint: to.Ptr("https://asmsrvprodwe.prod.migration.windowsazure.com/"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T07:38:23.0345615Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("abgoyalWEselfhostb72bproject"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects"), + // ETag: to.Ptr("\"0600c777-0000-0d00-0000-5cdaa4170000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject"), + // Location: to.Ptr("westeurope"), + // Properties: &armmigrate.ProjectProperties{ + // AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/abgoyal-westeurope/providers/microsoft.migrate/migrateprojects/abgoyalweselfhost/Solutions/Servers-Assessment-ServerAssessment"), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T08:28:53.3305058Z"); return t}()), + // LastAssessmentTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-14T11:18:47.7893715Z"); return t}()), + // NumberOfAssessments: to.Ptr[int32](3), + // NumberOfGroups: to.Ptr[int32](2), + // NumberOfMachines: to.Ptr[int32](28), + // ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + // ProvisioningState: to.Ptr(armmigrate.ProvisioningStateSucceeded), + // ServiceEndpoint: to.Ptr("https://asmsrvprodwe.prod.migration.windowsazure.com/"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:11:16.0228967Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("vaindana-pre-ga-10180project"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects"), + // ETag: to.Ptr("\"01003c88-0000-0d00-0000-5d41601b0000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/vaindana-migrate-ga-rg/providers/Microsoft.Migrate/assessmentprojects/vaindana-pre-ga-10180project"), + // Location: to.Ptr("westeurope"), + // Properties: &armmigrate.ProjectProperties{ + // AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/vaindana-migrate-ga-rg/providers/Microsoft.Migrate/MigrateProjects/vaindana-pre-ga-1/Solutions/Servers-Assessment-ServerAssessment"), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T11:58:13.0218178Z"); return t}()), + // LastAssessmentTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-31T09:32:11.4963946Z"); return t}()), + // NumberOfAssessments: to.Ptr[int32](4), + // NumberOfGroups: to.Ptr[int32](2), + // NumberOfMachines: to.Ptr[int32](101), + // ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + // ProvisioningState: to.Ptr(armmigrate.ProvisioningStateSucceeded), + // ServiceEndpoint: to.Ptr("https://asmsrvprodwe.prod.migration.windowsazure.com/"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-15T16:52:08.9189309Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Projects_List.json +func ExampleProjectsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewProjectsClient().NewListPager("abgoyal-westEurope", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ProjectResultList = armmigrate.ProjectResultList{ + // Value: []*armmigrate.Project{ + // { + // Name: to.Ptr("abgoyalWEselfhostb72bproject"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects"), + // ETag: to.Ptr("\"0600c777-0000-0d00-0000-5cdaa4170000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject"), + // Location: to.Ptr("westeurope"), + // Properties: &armmigrate.ProjectProperties{ + // AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/abgoyal-westeurope/providers/microsoft.migrate/migrateprojects/abgoyalweselfhost/Solutions/Servers-Assessment-ServerAssessment"), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T08:28:53.3305058Z"); return t}()), + // LastAssessmentTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-14T11:18:47.7893715Z"); return t}()), + // NumberOfAssessments: to.Ptr[int32](3), + // NumberOfGroups: to.Ptr[int32](2), + // NumberOfMachines: to.Ptr[int32](28), + // ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + // ProvisioningState: to.Ptr(armmigrate.ProvisioningStateSucceeded), + // ServiceEndpoint: to.Ptr("https://asmsrvprodwe.prod.migration.windowsazure.com/"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:11:16.0228967Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Projects_Get.json +func ExampleProjectsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewProjectsClient().Get(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Project = armmigrate.Project{ + // Name: to.Ptr("abgoyalWEselfhostb72bproject"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects"), + // ETag: to.Ptr("\"0600c777-0000-0d00-0000-5cdaa4170000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject"), + // Location: to.Ptr("westeurope"), + // Properties: &armmigrate.ProjectProperties{ + // AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/abgoyal-westeurope/providers/microsoft.migrate/migrateprojects/abgoyalweselfhost/Solutions/Servers-Assessment-ServerAssessment"), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T08:28:53.3305058Z"); return t}()), + // LastAssessmentTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-14T11:18:47.7893715Z"); return t}()), + // NumberOfAssessments: to.Ptr[int32](3), + // NumberOfGroups: to.Ptr[int32](2), + // NumberOfMachines: to.Ptr[int32](28), + // ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + // ProvisioningState: to.Ptr(armmigrate.ProvisioningStateSucceeded), + // ServiceEndpoint: to.Ptr("https://asmsrvprodwe.prod.migration.windowsazure.com/"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-09T10:11:16.0228967Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Projects_Create.json +func ExampleProjectsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewProjectsClient().Create(ctx, "abgoyal-westEurope", "abGoyalProject2", &armmigrate.ProjectsClientCreateOptions{Project: &armmigrate.Project{ + ETag: to.Ptr(""), + Location: to.Ptr("West Europe"), + Properties: &armmigrate.ProjectProperties{ + AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/abgoyal-westeurope/providers/microsoft.migrate/migrateprojects/abgoyalweselfhost/Solutions/Servers-Assessment-ServerAssessment"), + ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + }, + Tags: map[string]any{}, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Project = armmigrate.Project{ + // Name: to.Ptr("abGoyalProject2"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects"), + // ETag: to.Ptr(""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abGoyalProject2"), + // Location: to.Ptr("West Europe"), + // Properties: &armmigrate.ProjectProperties{ + // AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.Migrate/assessmentprojects/abGoyalProject2"), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-26T05:56:58.7521828Z"); return t}()), + // NumberOfAssessments: to.Ptr[int32](0), + // NumberOfGroups: to.Ptr[int32](0), + // NumberOfMachines: to.Ptr[int32](0), + // ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + // ServiceEndpoint: to.Ptr("https://localhost/"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-26T05:56:58.7990948Z"); return t}()), + // }, + // Tags: map[string]any{ + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Projects_Update.json +func ExampleProjectsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewProjectsClient().Update(ctx, "abgoyal-westEurope", "abGoyalProject2", &armmigrate.ProjectsClientUpdateOptions{Project: &armmigrate.Project{ + ETag: to.Ptr(""), + Location: to.Ptr("West Europe"), + Properties: &armmigrate.ProjectProperties{ + AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/abgoyal-westeurope/providers/microsoft.migrate/migrateprojects/abgoyalweselfhost/Solutions/Servers-Assessment-ServerAssessment"), + ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + }, + Tags: map[string]any{}, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Project = armmigrate.Project{ + // Name: to.Ptr("abGoyalProject2"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects"), + // ETag: to.Ptr(""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abGoyalProject2"), + // Location: to.Ptr("West Europe"), + // Properties: &armmigrate.ProjectProperties{ + // AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.Migrate/assessmentprojects/abGoyalProject2"), + // CreatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-26T05:56:58.7521828Z"); return t}()), + // NumberOfAssessments: to.Ptr[int32](0), + // NumberOfGroups: to.Ptr[int32](0), + // NumberOfMachines: to.Ptr[int32](0), + // ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), + // ServiceEndpoint: to.Ptr("https://localhost/"), + // UpdatedTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-26T05:56:58.7990948Z"); return t}()), + // }, + // Tags: map[string]any{ + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Projects_Delete.json +func ExampleProjectsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewProjectsClient().Delete(ctx, "abgoyal-westEurope", "abGoyalProject2", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/AssessmentOptions_Get.json +func ExampleProjectsClient_AssessmentOptions() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewProjectsClient().AssessmentOptions(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "default", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AssessmentOptions = armmigrate.AssessmentOptions{ + // Name: to.Ptr("default"), + // ID: to.Ptr("/subscriptions/5cbd71ba-5a65-4f0c-aea2-33dadde87b4e/resourceGroups/shsinglarg/providers/Microsoft.Migrate/assessmentprojects/shProject/assessmentOptions/default"), + // Properties: &armmigrate.AssessmentOptionsProperties{ + // ReservedInstanceSupportedCurrencies: []*string{ + // to.Ptr("USD"), + // to.Ptr("DKK"), + // to.Ptr("CAD"), + // to.Ptr("JPY"), + // to.Ptr("KRW"), + // to.Ptr("NZD"), + // to.Ptr("NOK"), + // to.Ptr("RUB"), + // to.Ptr("SEK"), + // to.Ptr("GBP"), + // to.Ptr("INR"), + // to.Ptr("BRL"), + // to.Ptr("TWD"), + // to.Ptr("EUR"), + // to.Ptr("CHF"), + // to.Ptr("AUD")}, + // ReservedInstanceSupportedLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs")}, + // ReservedInstanceSupportedOffers: []*string{ + // to.Ptr("MSAZR0003P")}, + // ReservedInstanceVMFamilies: []*string{ + // to.Ptr("Dv2_series"), + // to.Ptr("F_series"), + // to.Ptr("Dv3_series"), + // to.Ptr("DS_series"), + // to.Ptr("DSv2_series"), + // to.Ptr("Fs_series"), + // to.Ptr("Dsv3_series"), + // to.Ptr("Ev3_series"), + // to.Ptr("Esv3_series"), + // to.Ptr("D_series"), + // to.Ptr("Fsv2_series"), + // to.Ptr("M_series"), + // to.Ptr("Ls_series"), + // to.Ptr("H_series")}, + // VMFamilies: []*armmigrate.VMFamily{ + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose")}, + // FamilyName: to.Ptr("Standard_A0_A7"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovIowa"), + // to.Ptr("USGovVirginia"), + // to.Ptr("USDoDCentral"), + // to.Ptr("USDoDEast"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose")}, + // FamilyName: to.Ptr("Basic_A0_A4"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovIowa"), + // to.Ptr("USGovVirginia"), + // to.Ptr("USDoDCentral"), + // to.Ptr("USDoDEast"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose"), + // to.Ptr("MemoryOptimized")}, + // FamilyName: to.Ptr("Dv2_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovIowa"), + // to.Ptr("USGovVirginia"), + // to.Ptr("USDoDCentral"), + // to.Ptr("USDoDEast"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("ComputeOptimized")}, + // FamilyName: to.Ptr("F_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovIowa"), + // to.Ptr("USGovVirginia"), + // to.Ptr("USDoDCentral"), + // to.Ptr("USDoDEast"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose")}, + // FamilyName: to.Ptr("Av2_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovIowa"), + // to.Ptr("USGovVirginia"), + // to.Ptr("USDoDCentral"), + // to.Ptr("USDoDEast"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose")}, + // FamilyName: to.Ptr("Dv3_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovIowa"), + // to.Ptr("USGovVirginia"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose"), + // to.Ptr("MemoryOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("DS_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("EastUs"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("USGovVirginia"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose"), + // to.Ptr("MemoryOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("DSv2_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovVirginia"), + // to.Ptr("USDoDCentral"), + // to.Ptr("USDoDEast"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("ComputeOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("Fs_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovVirginia"), + // to.Ptr("USDoDCentral"), + // to.Ptr("USDoDEast"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("Dsv3_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovVirginia")}, + // }, + // { + // Category: []*string{ + // to.Ptr("MemoryOptimized")}, + // FamilyName: to.Ptr("Ev3_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovIowa"), + // to.Ptr("USGovVirginia"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("MemoryOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("Esv3_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovVirginia")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose")}, + // FamilyName: to.Ptr("D_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("USGovVirginia"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("ComputeOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("Fsv2_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovVirginia")}, + // }, + // { + // Category: []*string{ + // to.Ptr("MemoryOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("M_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovVirginia")}, + // }, + // { + // Category: []*string{ + // to.Ptr("MemoryOptimized")}, + // FamilyName: to.Ptr("G_series"), + // TargetLocations: []*string{ + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("JapanEast"), + // to.Ptr("UkSouth"), + // to.Ptr("WestUs2"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovVirginia")}, + // }, + // { + // Category: []*string{ + // to.Ptr("MemoryOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("GS_series"), + // TargetLocations: []*string{ + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("JapanEast"), + // to.Ptr("UkSouth"), + // to.Ptr("WestUs2"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovVirginia")}, + // }, + // { + // Category: []*string{ + // to.Ptr("StorageOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("Ls_series"), + // TargetLocations: []*string{ + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("JapanEast"), + // to.Ptr("UkSouth"), + // to.Ptr("WestUs2"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovVirginia")}, + // }, + // { + // Category: []*string{ + // to.Ptr("HighPerformanceCompute")}, + // FamilyName: to.Ptr("H_series"), + // TargetLocations: []*string{ + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("WestUs"), + // to.Ptr("USGovArizona")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose"), + // to.Ptr("SupportsPremiumStorage"), + // to.Ptr("Confidential")}, + // FamilyName: to.Ptr("DC_Series"), + // TargetLocations: []*string{ + // to.Ptr("WestEurope"), + // to.Ptr("EastUs")}, + // }, + // { + // Category: []*string{ + // to.Ptr("HighPerformanceCompute")}, + // FamilyName: to.Ptr("Standard_A8_A11"), + // TargetLocations: []*string{ + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("WestUs")}, + // }}, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/AssessmentOptions_List.json +func ExampleProjectsClient_NewAssessmentOptionsListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewProjectsClient().NewAssessmentOptionsListPager("abgoyal-westEurope", "abgoyalWEselfhostb72bproject", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AssessmentOptionsResultList = armmigrate.AssessmentOptionsResultList{ + // Value: []*armmigrate.AssessmentOptions{ + // { + // Name: to.Ptr("default"), + // ID: to.Ptr("/subscriptions/5cbd71ba-5a65-4f0c-aea2-33dadde87b4e/resourceGroups/shsinglarg/providers/Microsoft.Migrate/assessmentprojects/shProject/assessmentOptions/default"), + // Properties: &armmigrate.AssessmentOptionsProperties{ + // ReservedInstanceSupportedCurrencies: []*string{ + // to.Ptr("USD"), + // to.Ptr("DKK"), + // to.Ptr("CAD"), + // to.Ptr("JPY"), + // to.Ptr("KRW"), + // to.Ptr("NZD"), + // to.Ptr("NOK"), + // to.Ptr("RUB"), + // to.Ptr("SEK"), + // to.Ptr("GBP"), + // to.Ptr("INR"), + // to.Ptr("BRL"), + // to.Ptr("TWD"), + // to.Ptr("EUR"), + // to.Ptr("CHF"), + // to.Ptr("AUD")}, + // ReservedInstanceSupportedLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs")}, + // ReservedInstanceSupportedOffers: []*string{ + // to.Ptr("MSAZR0003P")}, + // ReservedInstanceVMFamilies: []*string{ + // to.Ptr("Dv2_series"), + // to.Ptr("F_series"), + // to.Ptr("Dv3_series"), + // to.Ptr("DS_series"), + // to.Ptr("DSv2_series"), + // to.Ptr("Fs_series"), + // to.Ptr("Dsv3_series"), + // to.Ptr("Ev3_series"), + // to.Ptr("Esv3_series"), + // to.Ptr("D_series"), + // to.Ptr("Fsv2_series"), + // to.Ptr("M_series"), + // to.Ptr("Ls_series"), + // to.Ptr("H_series")}, + // VMFamilies: []*armmigrate.VMFamily{ + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose")}, + // FamilyName: to.Ptr("Standard_A0_A7"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovIowa"), + // to.Ptr("USGovVirginia"), + // to.Ptr("USDoDCentral"), + // to.Ptr("USDoDEast"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose")}, + // FamilyName: to.Ptr("Basic_A0_A4"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovIowa"), + // to.Ptr("USGovVirginia"), + // to.Ptr("USDoDCentral"), + // to.Ptr("USDoDEast"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose"), + // to.Ptr("MemoryOptimized")}, + // FamilyName: to.Ptr("Dv2_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovIowa"), + // to.Ptr("USGovVirginia"), + // to.Ptr("USDoDCentral"), + // to.Ptr("USDoDEast"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("ComputeOptimized")}, + // FamilyName: to.Ptr("F_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovIowa"), + // to.Ptr("USGovVirginia"), + // to.Ptr("USDoDCentral"), + // to.Ptr("USDoDEast"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose")}, + // FamilyName: to.Ptr("Av2_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovIowa"), + // to.Ptr("USGovVirginia"), + // to.Ptr("USDoDCentral"), + // to.Ptr("USDoDEast"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose")}, + // FamilyName: to.Ptr("Dv3_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovIowa"), + // to.Ptr("USGovVirginia"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose"), + // to.Ptr("MemoryOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("DS_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("EastUs"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("USGovVirginia"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose"), + // to.Ptr("MemoryOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("DSv2_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovVirginia"), + // to.Ptr("USDoDCentral"), + // to.Ptr("USDoDEast"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("ComputeOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("Fs_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovVirginia"), + // to.Ptr("USDoDCentral"), + // to.Ptr("USDoDEast"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("Dsv3_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovVirginia")}, + // }, + // { + // Category: []*string{ + // to.Ptr("MemoryOptimized")}, + // FamilyName: to.Ptr("Ev3_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovIowa"), + // to.Ptr("USGovVirginia"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("MemoryOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("Esv3_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("WestCentralUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("GermanyNortheast"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovTexas"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovVirginia")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose")}, + // FamilyName: to.Ptr("D_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("USGovVirginia"), + // to.Ptr("ChinaNorth"), + // to.Ptr("ChinaEast")}, + // }, + // { + // Category: []*string{ + // to.Ptr("ComputeOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("Fsv2_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("WestIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("CentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("FranceCentral"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovVirginia")}, + // }, + // { + // Category: []*string{ + // to.Ptr("MemoryOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("M_series"), + // TargetLocations: []*string{ + // to.Ptr("EastAsia"), + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("AustraliaSoutheast"), + // to.Ptr("BrazilSouth"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("SouthIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("JapanWest"), + // to.Ptr("KoreaCentral"), + // to.Ptr("KoreaSouth"), + // to.Ptr("UkWest"), + // to.Ptr("UkSouth"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("EastUs2"), + // to.Ptr("USGovArizona"), + // to.Ptr("USGovVirginia")}, + // }, + // { + // Category: []*string{ + // to.Ptr("MemoryOptimized")}, + // FamilyName: to.Ptr("G_series"), + // TargetLocations: []*string{ + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("JapanEast"), + // to.Ptr("UkSouth"), + // to.Ptr("WestUs2"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovVirginia")}, + // }, + // { + // Category: []*string{ + // to.Ptr("MemoryOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("GS_series"), + // TargetLocations: []*string{ + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("JapanEast"), + // to.Ptr("UkSouth"), + // to.Ptr("WestUs2"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovVirginia")}, + // }, + // { + // Category: []*string{ + // to.Ptr("StorageOptimized"), + // to.Ptr("SupportsPremiumStorage")}, + // FamilyName: to.Ptr("Ls_series"), + // TargetLocations: []*string{ + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("CanadaCentral"), + // to.Ptr("CanadaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("JapanEast"), + // to.Ptr("UkSouth"), + // to.Ptr("WestUs2"), + // to.Ptr("EastUs2"), + // to.Ptr("WestUs"), + // to.Ptr("GermanyCentral"), + // to.Ptr("USGovVirginia")}, + // }, + // { + // Category: []*string{ + // to.Ptr("HighPerformanceCompute")}, + // FamilyName: to.Ptr("H_series"), + // TargetLocations: []*string{ + // to.Ptr("SoutheastAsia"), + // to.Ptr("AustraliaEast"), + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("CentralIndia"), + // to.Ptr("JapanEast"), + // to.Ptr("UkSouth"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("WestUs2"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("WestUs"), + // to.Ptr("USGovArizona")}, + // }, + // { + // Category: []*string{ + // to.Ptr("GeneralPurpose"), + // to.Ptr("SupportsPremiumStorage"), + // to.Ptr("Confidential")}, + // FamilyName: to.Ptr("DC_Series"), + // TargetLocations: []*string{ + // to.Ptr("WestEurope"), + // to.Ptr("EastUs")}, + // }, + // { + // Category: []*string{ + // to.Ptr("HighPerformanceCompute")}, + // FamilyName: to.Ptr("Standard_A8_A11"), + // TargetLocations: []*string{ + // to.Ptr("WestEurope"), + // to.Ptr("NorthEurope"), + // to.Ptr("NorthCentralUs"), + // to.Ptr("EastUs"), + // to.Ptr("SouthCentralUs"), + // to.Ptr("WestUs")}, + // }}, + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_response_types.go b/sdk/resourcemanager/migrate/armmigrate/response_types.go similarity index 94% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_response_types.go rename to sdk/resourcemanager/migrate/armmigrate/response_types.go index 624d24faa931..e0d99e5a6887 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_response_types.go +++ b/sdk/resourcemanager/migrate/armmigrate/response_types.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armmigrate @@ -15,7 +16,7 @@ type AssessedMachinesClientGetResponse struct { XMSRequestID *string } -// AssessedMachinesClientListByAssessmentResponse contains the response from method AssessedMachinesClient.ListByAssessment. +// AssessedMachinesClientListByAssessmentResponse contains the response from method AssessedMachinesClient.NewListByAssessmentPager. type AssessedMachinesClientListByAssessmentResponse struct { AssessedMachineResultList // XMSRequestID contains the information returned from the x-ms-request-id header response. @@ -49,14 +50,14 @@ type AssessmentsClientGetResponse struct { XMSRequestID *string } -// AssessmentsClientListByGroupResponse contains the response from method AssessmentsClient.ListByGroup. +// AssessmentsClientListByGroupResponse contains the response from method AssessmentsClient.NewListByGroupPager. type AssessmentsClientListByGroupResponse struct { AssessmentResultList // XMSRequestID contains the information returned from the x-ms-request-id header response. XMSRequestID *string } -// AssessmentsClientListByProjectResponse contains the response from method AssessmentsClient.ListByProject. +// AssessmentsClientListByProjectResponse contains the response from method AssessmentsClient.NewListByProjectPager. type AssessmentsClientListByProjectResponse struct { AssessmentResultList // XMSRequestID contains the information returned from the x-ms-request-id header response. @@ -83,7 +84,7 @@ type GroupsClientGetResponse struct { XMSRequestID *string } -// GroupsClientListByProjectResponse contains the response from method GroupsClient.ListByProject. +// GroupsClientListByProjectResponse contains the response from method GroupsClient.NewListByProjectPager. type GroupsClientListByProjectResponse struct { GroupResultList // XMSRequestID contains the information returned from the x-ms-request-id header response. @@ -117,7 +118,7 @@ type HyperVCollectorsClientGetResponse struct { XMSRequestID *string } -// HyperVCollectorsClientListByProjectResponse contains the response from method HyperVCollectorsClient.ListByProject. +// HyperVCollectorsClientListByProjectResponse contains the response from method HyperVCollectorsClient.NewListByProjectPager. type HyperVCollectorsClientListByProjectResponse struct { HyperVCollectorList // XMSRequestID contains the information returned from the x-ms-request-id header response. @@ -144,7 +145,7 @@ type ImportCollectorsClientGetResponse struct { XMSRequestID *string } -// ImportCollectorsClientListByProjectResponse contains the response from method ImportCollectorsClient.ListByProject. +// ImportCollectorsClientListByProjectResponse contains the response from method ImportCollectorsClient.NewListByProjectPager. type ImportCollectorsClientListByProjectResponse struct { ImportCollectorList // XMSRequestID contains the information returned from the x-ms-request-id header response. @@ -158,14 +159,14 @@ type MachinesClientGetResponse struct { XMSRequestID *string } -// MachinesClientListByProjectResponse contains the response from method MachinesClient.ListByProject. +// MachinesClientListByProjectResponse contains the response from method MachinesClient.NewListByProjectPager. type MachinesClientListByProjectResponse struct { MachineResultList // XMSRequestID contains the information returned from the x-ms-request-id header response. XMSRequestID *string } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationResultList } @@ -211,7 +212,7 @@ type PrivateLinkResourceClientListByProjectResponse struct { XMSRequestID *string } -// ProjectsClientAssessmentOptionsListResponse contains the response from method ProjectsClient.AssessmentOptionsList. +// ProjectsClientAssessmentOptionsListResponse contains the response from method ProjectsClient.NewAssessmentOptionsListPager. type ProjectsClientAssessmentOptionsListResponse struct { AssessmentOptionsResultList // XMSRequestID contains the information returned from the x-ms-request-id header response. @@ -245,14 +246,14 @@ type ProjectsClientGetResponse struct { XMSRequestID *string } -// ProjectsClientListBySubscriptionResponse contains the response from method ProjectsClient.ListBySubscription. +// ProjectsClientListBySubscriptionResponse contains the response from method ProjectsClient.NewListBySubscriptionPager. type ProjectsClientListBySubscriptionResponse struct { ProjectResultList // XMSRequestID contains the information returned from the x-ms-request-id header response. XMSRequestID *string } -// ProjectsClientListResponse contains the response from method ProjectsClient.List. +// ProjectsClientListResponse contains the response from method ProjectsClient.NewListPager. type ProjectsClientListResponse struct { ProjectResultList // XMSRequestID contains the information returned from the x-ms-request-id header response. @@ -286,7 +287,7 @@ type ServerCollectorsClientGetResponse struct { XMSRequestID *string } -// ServerCollectorsClientListByProjectResponse contains the response from method ServerCollectorsClient.ListByProject. +// ServerCollectorsClientListByProjectResponse contains the response from method ServerCollectorsClient.NewListByProjectPager. type ServerCollectorsClientListByProjectResponse struct { ServerCollectorList // XMSRequestID contains the information returned from the x-ms-request-id header response. @@ -313,7 +314,7 @@ type VMwareCollectorsClientGetResponse struct { XMSRequestID *string } -// VMwareCollectorsClientListByProjectResponse contains the response from method VMwareCollectorsClient.ListByProject. +// VMwareCollectorsClientListByProjectResponse contains the response from method VMwareCollectorsClient.NewListByProjectPager. type VMwareCollectorsClientListByProjectResponse struct { VMwareCollectorList // XMSRequestID contains the information returned from the x-ms-request-id header response. diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_servercollectors_client.go b/sdk/resourcemanager/migrate/armmigrate/servercollectors_client.go similarity index 84% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_servercollectors_client.go rename to sdk/resourcemanager/migrate/armmigrate/servercollectors_client.go index 05cf50a13829..05df4217cad0 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_servercollectors_client.go +++ b/sdk/resourcemanager/migrate/armmigrate/servercollectors_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 armmigrate @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // ServerCollectorsClient contains the methods for the ServerCollectors group. // Don't use this type directly, use NewServerCollectorsClient() instead. type ServerCollectorsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServerCollectorsClient creates a new instance of ServerCollectorsClient with the specified values. -// subscriptionID - Azure Subscription Id in which project was created. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription Id in which project was created. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServerCollectorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServerCollectorsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ServerCollectorsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServerCollectorsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Create or Update Server collector // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// serverCollectorName - Unique name of a Server collector within a project. -// options - ServerCollectorsClientCreateOptions contains the optional parameters for the ServerCollectorsClient.Create method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - serverCollectorName - Unique name of a Server collector within a project. +// - options - ServerCollectorsClientCreateOptions contains the optional parameters for the ServerCollectorsClient.Create method. func (client *ServerCollectorsClient) Create(ctx context.Context, resourceGroupName string, projectName string, serverCollectorName string, options *ServerCollectorsClientCreateOptions) (ServerCollectorsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, projectName, serverCollectorName, options) if err != nil { return ServerCollectorsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServerCollectorsClientCreateResponse{}, err } @@ -95,7 +86,7 @@ func (client *ServerCollectorsClient) createCreateRequest(ctx context.Context, r return nil, errors.New("parameter serverCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverCollectorName}", url.PathEscape(serverCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -123,17 +114,18 @@ func (client *ServerCollectorsClient) createHandleResponse(resp *http.Response) // Delete - Delete a Server collector from the project. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// serverCollectorName - Unique name of a Server collector within a project. -// options - ServerCollectorsClientDeleteOptions contains the optional parameters for the ServerCollectorsClient.Delete method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - serverCollectorName - Unique name of a Server collector within a project. +// - options - ServerCollectorsClientDeleteOptions contains the optional parameters for the ServerCollectorsClient.Delete method. func (client *ServerCollectorsClient) Delete(ctx context.Context, resourceGroupName string, projectName string, serverCollectorName string, options *ServerCollectorsClientDeleteOptions) (ServerCollectorsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, projectName, serverCollectorName, options) if err != nil { return ServerCollectorsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServerCollectorsClientDeleteResponse{}, err } @@ -162,7 +154,7 @@ func (client *ServerCollectorsClient) deleteCreateRequest(ctx context.Context, r return nil, errors.New("parameter serverCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverCollectorName}", url.PathEscape(serverCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -184,17 +176,18 @@ func (client *ServerCollectorsClient) deleteHandleResponse(resp *http.Response) // Get - Get a Server collector. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// serverCollectorName - Unique name of a Server collector within a project. -// options - ServerCollectorsClientGetOptions contains the optional parameters for the ServerCollectorsClient.Get method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - serverCollectorName - Unique name of a Server collector within a project. +// - options - ServerCollectorsClientGetOptions contains the optional parameters for the ServerCollectorsClient.Get method. func (client *ServerCollectorsClient) Get(ctx context.Context, resourceGroupName string, projectName string, serverCollectorName string, options *ServerCollectorsClientGetOptions) (ServerCollectorsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, projectName, serverCollectorName, options) if err != nil { return ServerCollectorsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServerCollectorsClientGetResponse{}, err } @@ -223,7 +216,7 @@ func (client *ServerCollectorsClient) getCreateRequest(ctx context.Context, reso return nil, errors.New("parameter serverCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverCollectorName}", url.PathEscape(serverCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -247,12 +240,12 @@ func (client *ServerCollectorsClient) getHandleResponse(resp *http.Response) (Se } // NewListByProjectPager - Get a list of Server collector. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// options - ServerCollectorsClientListByProjectOptions contains the optional parameters for the ServerCollectorsClient.ListByProject -// method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - options - ServerCollectorsClientListByProjectOptions contains the optional parameters for the ServerCollectorsClient.NewListByProjectPager +// method. func (client *ServerCollectorsClient) NewListByProjectPager(resourceGroupName string, projectName string, options *ServerCollectorsClientListByProjectOptions) *runtime.Pager[ServerCollectorsClientListByProjectResponse] { return runtime.NewPager(runtime.PagingHandler[ServerCollectorsClientListByProjectResponse]{ More: func(page ServerCollectorsClientListByProjectResponse) bool { @@ -263,7 +256,7 @@ func (client *ServerCollectorsClient) NewListByProjectPager(resourceGroupName st if err != nil { return ServerCollectorsClientListByProjectResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServerCollectorsClientListByProjectResponse{}, err } @@ -290,7 +283,7 @@ func (client *ServerCollectorsClient) listByProjectCreateRequest(ctx context.Con return nil, errors.New("parameter projectName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/migrate/armmigrate/servercollectors_client_example_test.go b/sdk/resourcemanager/migrate/armmigrate/servercollectors_client_example_test.go new file mode 100644 index 000000000000..057541e126a1 --- /dev/null +++ b/sdk/resourcemanager/migrate/armmigrate/servercollectors_client_example_test.go @@ -0,0 +1,188 @@ +//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 armmigrate_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/migrate/armmigrate" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ServerCollectors_ListByProject.json +func ExampleServerCollectorsClient_NewListByProjectPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServerCollectorsClient().NewListByProjectPager("pajindtest", "app11141project", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ServerCollectorList = armmigrate.ServerCollectorList{ + // Value: []*armmigrate.ServerCollector{ + // { + // Name: to.Ptr("app23df4collector"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/servercollectors"), + // ETag: to.Ptr("\"00000606-0000-0d00-0000-605999bf0000\""), + // ID: to.Ptr("/subscriptions/4bd2aa0f-2bd2-4d67-91a8-5a4533d58600/resourceGroups/pajindtest/providers/Microsoft.Migrate/assessmentprojects/app11141project/servercollectors/app23df4collector"), + // Properties: &armmigrate.CollectorProperties{ + // AgentProperties: &armmigrate.CollectorAgentProperties{ + // ID: to.Ptr("dc984f5a-58a3-4f84-818c-a19febefa66a"), + // LastHeartbeatUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-17T03:51:30.2069337Z"); return t}()), + // SpnDetails: &armmigrate.CollectorBodyAgentSpnProperties{ + // ApplicationID: to.Ptr("ad9f701a-cc08-4421-b51f-b5762d58e9ba"), + // Audience: to.Ptr("https://72f988bf-86f1-41af-91ab-2d7cd011db47/app23df4authandaccessaadapp"), + // Authority: to.Ptr("https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47"), + // ObjectID: to.Ptr("b4975e42-9248-4a36-b99f-37eca377ea00"), + // TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), + // }, + // Version: to.Ptr("1.0.8.393"), + // }, + // CreatedTimestamp: to.Ptr("2020-09-11T07:15:52.4361521Z"), + // DiscoverySiteID: to.Ptr("/subscriptions/4bd2aa0f-2bd2-4d67-91a8-5a4533d58600/resourceGroups/pajindTest/providers/Microsoft.OffAzure/ServerSites/app21141site"), + // UpdatedTimestamp: to.Ptr("2021-03-23T07:33:19.697297Z"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ServerCollectors_Get.json +func ExampleServerCollectorsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServerCollectorsClient().Get(ctx, "pajindtest", "app11141project", "app23df4collector", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ServerCollector = armmigrate.ServerCollector{ + // Name: to.Ptr("app23df4collector"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/servercollectors"), + // ETag: to.Ptr("\"00000606-0000-0d00-0000-605999bf0000\""), + // ID: to.Ptr("/subscriptions/4bd2aa0f-2bd2-4d67-91a8-5a4533d58600/resourceGroups/pajindtest/providers/Microsoft.Migrate/assessmentprojects/app11141project/servercollectors/app23df4collector"), + // Properties: &armmigrate.CollectorProperties{ + // AgentProperties: &armmigrate.CollectorAgentProperties{ + // ID: to.Ptr("dc984f5a-58a3-4f84-818c-a19febefa66a"), + // LastHeartbeatUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-17T03:51:30.2069337Z"); return t}()), + // SpnDetails: &armmigrate.CollectorBodyAgentSpnProperties{ + // ApplicationID: to.Ptr("ad9f701a-cc08-4421-b51f-b5762d58e9ba"), + // Audience: to.Ptr("https://72f988bf-86f1-41af-91ab-2d7cd011db47/app23df4authandaccessaadapp"), + // Authority: to.Ptr("https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47"), + // ObjectID: to.Ptr("b4975e42-9248-4a36-b99f-37eca377ea00"), + // TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), + // }, + // Version: to.Ptr("1.0.8.393"), + // }, + // CreatedTimestamp: to.Ptr("2020-09-11T07:15:52.4361521Z"), + // DiscoverySiteID: to.Ptr("/subscriptions/4bd2aa0f-2bd2-4d67-91a8-5a4533d58600/resourceGroups/pajindTest/providers/Microsoft.OffAzure/ServerSites/app21141site"), + // UpdatedTimestamp: to.Ptr("2021-03-23T07:33:19.697297Z"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ServerCollectors_Create.json +func ExampleServerCollectorsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServerCollectorsClient().Create(ctx, "pajindtest", "app11141project", "app23df4collector", &armmigrate.ServerCollectorsClientCreateOptions{CollectorBody: &armmigrate.ServerCollector{ + ETag: to.Ptr("\"00000606-0000-0d00-0000-605999bf0000\""), + Properties: &armmigrate.CollectorProperties{ + AgentProperties: &armmigrate.CollectorAgentProperties{ + SpnDetails: &armmigrate.CollectorBodyAgentSpnProperties{ + ApplicationID: to.Ptr("ad9f701a-cc08-4421-b51f-b5762d58e9ba"), + Audience: to.Ptr("https://72f988bf-86f1-41af-91ab-2d7cd011db47/app23df4authandaccessaadapp"), + Authority: to.Ptr("https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47"), + ObjectID: to.Ptr("b4975e42-9248-4a36-b99f-37eca377ea00"), + TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), + }, + }, + DiscoverySiteID: to.Ptr("/subscriptions/4bd2aa0f-2bd2-4d67-91a8-5a4533d58600/resourceGroups/pajindTest/providers/Microsoft.OffAzure/ServerSites/app21141site"), + }, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ServerCollector = armmigrate.ServerCollector{ + // Name: to.Ptr("app23df4collector"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/servercollectors"), + // ETag: to.Ptr("\"00000606-0000-0d00-0000-605999bf0000\""), + // ID: to.Ptr("/subscriptions/4bd2aa0f-2bd2-4d67-91a8-5a4533d58600/resourceGroups/pajindtest/providers/Microsoft.Migrate/assessmentprojects/app11141project/servercollectors/app23df4collector"), + // Properties: &armmigrate.CollectorProperties{ + // AgentProperties: &armmigrate.CollectorAgentProperties{ + // ID: to.Ptr("dc984f5a-58a3-4f84-818c-a19febefa66a"), + // LastHeartbeatUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-17T03:51:30.2069337Z"); return t}()), + // SpnDetails: &armmigrate.CollectorBodyAgentSpnProperties{ + // ApplicationID: to.Ptr("ad9f701a-cc08-4421-b51f-b5762d58e9ba"), + // Audience: to.Ptr("https://72f988bf-86f1-41af-91ab-2d7cd011db47/app23df4authandaccessaadapp"), + // Authority: to.Ptr("https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47"), + // ObjectID: to.Ptr("b4975e42-9248-4a36-b99f-37eca377ea00"), + // TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), + // }, + // Version: to.Ptr("1.0.8.393"), + // }, + // CreatedTimestamp: to.Ptr("2020-09-11T07:15:52.4361521Z"), + // DiscoverySiteID: to.Ptr("/subscriptions/4bd2aa0f-2bd2-4d67-91a8-5a4533d58600/resourceGroups/pajindTest/providers/Microsoft.OffAzure/ServerSites/app21141site"), + // UpdatedTimestamp: to.Ptr("2021-03-23T07:33:19.697297Z"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ServerCollectors_Delete.json +func ExampleServerCollectorsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewServerCollectorsClient().Delete(ctx, "pajindtest", "app11141project", "app23df4collector", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_time_rfc3339.go b/sdk/resourcemanager/migrate/armmigrate/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/migrate/armmigrate/time_rfc3339.go index c95bd4b4f714..b6035979d8e0 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/migrate/armmigrate/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 armmigrate @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_vmwarecollectors_client.go b/sdk/resourcemanager/migrate/armmigrate/vmwarecollectors_client.go similarity index 84% rename from sdk/resourcemanager/migrate/armmigrate/zz_generated_vmwarecollectors_client.go rename to sdk/resourcemanager/migrate/armmigrate/vmwarecollectors_client.go index 735b03e20d36..dcc66b5a9eb5 100644 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_vmwarecollectors_client.go +++ b/sdk/resourcemanager/migrate/armmigrate/vmwarecollectors_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 armmigrate @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // VMwareCollectorsClient contains the methods for the VMwareCollectors group. // Don't use this type directly, use NewVMwareCollectorsClient() instead. type VMwareCollectorsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVMwareCollectorsClient creates a new instance of VMwareCollectorsClient with the specified values. -// subscriptionID - Azure Subscription Id in which project was created. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription Id in which project was created. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewVMwareCollectorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VMwareCollectorsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".VMwareCollectorsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VMwareCollectorsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Create or Update VMware collector // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// vmWareCollectorName - Unique name of a VMware collector within a project. -// options - VMwareCollectorsClientCreateOptions contains the optional parameters for the VMwareCollectorsClient.Create method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - vmWareCollectorName - Unique name of a VMware collector within a project. +// - options - VMwareCollectorsClientCreateOptions contains the optional parameters for the VMwareCollectorsClient.Create method. func (client *VMwareCollectorsClient) Create(ctx context.Context, resourceGroupName string, projectName string, vmWareCollectorName string, options *VMwareCollectorsClientCreateOptions) (VMwareCollectorsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, projectName, vmWareCollectorName, options) if err != nil { return VMwareCollectorsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VMwareCollectorsClientCreateResponse{}, err } @@ -95,7 +86,7 @@ func (client *VMwareCollectorsClient) createCreateRequest(ctx context.Context, r return nil, errors.New("parameter vmWareCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vmWareCollectorName}", url.PathEscape(vmWareCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -123,17 +114,18 @@ func (client *VMwareCollectorsClient) createHandleResponse(resp *http.Response) // Delete - Delete a VMware collector from the project. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// vmWareCollectorName - Unique name of a VMware collector within a project. -// options - VMwareCollectorsClientDeleteOptions contains the optional parameters for the VMwareCollectorsClient.Delete method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - vmWareCollectorName - Unique name of a VMware collector within a project. +// - options - VMwareCollectorsClientDeleteOptions contains the optional parameters for the VMwareCollectorsClient.Delete method. func (client *VMwareCollectorsClient) Delete(ctx context.Context, resourceGroupName string, projectName string, vmWareCollectorName string, options *VMwareCollectorsClientDeleteOptions) (VMwareCollectorsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, projectName, vmWareCollectorName, options) if err != nil { return VMwareCollectorsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VMwareCollectorsClientDeleteResponse{}, err } @@ -162,7 +154,7 @@ func (client *VMwareCollectorsClient) deleteCreateRequest(ctx context.Context, r return nil, errors.New("parameter vmWareCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vmWareCollectorName}", url.PathEscape(vmWareCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -184,17 +176,18 @@ func (client *VMwareCollectorsClient) deleteHandleResponse(resp *http.Response) // Get - Get a VMware collector. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// vmWareCollectorName - Unique name of a VMware collector within a project. -// options - VMwareCollectorsClientGetOptions contains the optional parameters for the VMwareCollectorsClient.Get method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - vmWareCollectorName - Unique name of a VMware collector within a project. +// - options - VMwareCollectorsClientGetOptions contains the optional parameters for the VMwareCollectorsClient.Get method. func (client *VMwareCollectorsClient) Get(ctx context.Context, resourceGroupName string, projectName string, vmWareCollectorName string, options *VMwareCollectorsClientGetOptions) (VMwareCollectorsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, projectName, vmWareCollectorName, options) if err != nil { return VMwareCollectorsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VMwareCollectorsClientGetResponse{}, err } @@ -223,7 +216,7 @@ func (client *VMwareCollectorsClient) getCreateRequest(ctx context.Context, reso return nil, errors.New("parameter vmWareCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vmWareCollectorName}", url.PathEscape(vmWareCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -247,12 +240,12 @@ func (client *VMwareCollectorsClient) getHandleResponse(resp *http.Response) (VM } // NewListByProjectPager - Get a list of VMware collector. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-10-01 -// resourceGroupName - Name of the Azure Resource Group that project is part of. -// projectName - Name of the Azure Migrate project. -// options - VMwareCollectorsClientListByProjectOptions contains the optional parameters for the VMwareCollectorsClient.ListByProject -// method. +// - resourceGroupName - Name of the Azure Resource Group that project is part of. +// - projectName - Name of the Azure Migrate project. +// - options - VMwareCollectorsClientListByProjectOptions contains the optional parameters for the VMwareCollectorsClient.NewListByProjectPager +// method. func (client *VMwareCollectorsClient) NewListByProjectPager(resourceGroupName string, projectName string, options *VMwareCollectorsClientListByProjectOptions) *runtime.Pager[VMwareCollectorsClientListByProjectResponse] { return runtime.NewPager(runtime.PagingHandler[VMwareCollectorsClientListByProjectResponse]{ More: func(page VMwareCollectorsClientListByProjectResponse) bool { @@ -263,7 +256,7 @@ func (client *VMwareCollectorsClient) NewListByProjectPager(resourceGroupName st if err != nil { return VMwareCollectorsClientListByProjectResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VMwareCollectorsClientListByProjectResponse{}, err } @@ -290,7 +283,7 @@ func (client *VMwareCollectorsClient) listByProjectCreateRequest(ctx context.Con return nil, errors.New("parameter projectName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/migrate/armmigrate/vmwarecollectors_client_example_test.go b/sdk/resourcemanager/migrate/armmigrate/vmwarecollectors_client_example_test.go new file mode 100644 index 000000000000..f5103fb741c8 --- /dev/null +++ b/sdk/resourcemanager/migrate/armmigrate/vmwarecollectors_client_example_test.go @@ -0,0 +1,188 @@ +//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 armmigrate_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/migrate/armmigrate" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/VMwareCollectors_ListByProject.json +func ExampleVMwareCollectorsClient_NewListByProjectPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewVMwareCollectorsClient().NewListByProjectPager("abgoyal-westEurope", "abgoyalWEselfhostb72bproject", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.VMwareCollectorList = armmigrate.VMwareCollectorList{ + // Value: []*armmigrate.VMwareCollector{ + // { + // Name: to.Ptr("PortalvCenterbc2fcollector"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/vmwarecollectors"), + // ETag: to.Ptr("\"01003d32-0000-0d00-0000-5d74d2e50000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/vmwarecollectors/PortalvCenterbc2fcollector"), + // Properties: &armmigrate.CollectorProperties{ + // AgentProperties: &armmigrate.CollectorAgentProperties{ + // ID: to.Ptr("75b0f71e-1272-4f29-a801-29cfa4b34a6e"), + // LastHeartbeatUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-28T06:21:28.7794661Z"); return t}()), + // SpnDetails: &armmigrate.CollectorBodyAgentSpnProperties{ + // ApplicationID: to.Ptr("fc717575-8173-4b21-92a5-658b655e613e"), + // Audience: to.Ptr("https://72f988bf-86f1-41af-91ab-2d7cd011db47/PortalvCenterbc2fagentauthaadapp"), + // Authority: to.Ptr("https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47"), + // ObjectID: to.Ptr("29d94f38-db94-4980-aec0-0cfd55ab1cd0"), + // TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), + // }, + // Version: to.Ptr("1.0.8.227"), + // }, + // CreatedTimestamp: to.Ptr("2019-05-09T09:58:21.4988104Z"), + // DiscoverySiteID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.OffAzure/VMwareSites/PortalvCenterbc2fsite"), + // UpdatedTimestamp: to.Ptr("2019-09-08T10:07:33.1996006Z"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/VMwareCollectors_Get.json +func ExampleVMwareCollectorsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVMwareCollectorsClient().Get(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "PortalvCenterbc2fcollector", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VMwareCollector = armmigrate.VMwareCollector{ + // Name: to.Ptr("PortalvCenterbc2fcollector"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/vmwarecollectors"), + // ETag: to.Ptr("\"01003d32-0000-0d00-0000-5d74d2e50000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/vmwarecollectors/PortalvCenterbc2fcollector"), + // Properties: &armmigrate.CollectorProperties{ + // AgentProperties: &armmigrate.CollectorAgentProperties{ + // ID: to.Ptr("75b0f71e-1272-4f29-a801-29cfa4b34a6e"), + // LastHeartbeatUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-28T06:21:28.7794661Z"); return t}()), + // SpnDetails: &armmigrate.CollectorBodyAgentSpnProperties{ + // ApplicationID: to.Ptr("fc717575-8173-4b21-92a5-658b655e613e"), + // Audience: to.Ptr("https://72f988bf-86f1-41af-91ab-2d7cd011db47/PortalvCenterbc2fagentauthaadapp"), + // Authority: to.Ptr("https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47"), + // ObjectID: to.Ptr("29d94f38-db94-4980-aec0-0cfd55ab1cd0"), + // TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), + // }, + // Version: to.Ptr("1.0.8.227"), + // }, + // CreatedTimestamp: to.Ptr("2019-05-09T09:58:21.4988104Z"), + // DiscoverySiteID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.OffAzure/VMwareSites/PortalvCenterbc2fsite"), + // UpdatedTimestamp: to.Ptr("2019-09-08T10:07:33.1996006Z"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/VMwareCollectors_Create.json +func ExampleVMwareCollectorsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVMwareCollectorsClient().Create(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "PortalvCenterbc2fcollector", &armmigrate.VMwareCollectorsClientCreateOptions{CollectorBody: &armmigrate.VMwareCollector{ + ETag: to.Ptr("\"01003d32-0000-0d00-0000-5d74d2e50000\""), + Properties: &armmigrate.CollectorProperties{ + AgentProperties: &armmigrate.CollectorAgentProperties{ + SpnDetails: &armmigrate.CollectorBodyAgentSpnProperties{ + ApplicationID: to.Ptr("fc717575-8173-4b21-92a5-658b655e613e"), + Audience: to.Ptr("https://72f988bf-86f1-41af-91ab-2d7cd011db47/PortalvCenterbc2fagentauthaadapp"), + Authority: to.Ptr("https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47"), + ObjectID: to.Ptr("29d94f38-db94-4980-aec0-0cfd55ab1cd0"), + TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), + }, + }, + DiscoverySiteID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.OffAzure/VMwareSites/PortalvCenterbc2fsite"), + }, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VMwareCollector = armmigrate.VMwareCollector{ + // Name: to.Ptr("PortalvCenterbc2fcollector"), + // Type: to.Ptr("Microsoft.Migrate/assessmentprojects/vmwarecollectors"), + // ETag: to.Ptr("\"01003d32-0000-0d00-0000-5d74d2e50000\""), + // ID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westeurope/providers/Microsoft.Migrate/assessmentprojects/abgoyalWEselfhostb72bproject/vmwarecollectors/PortalvCenterbc2fcollector"), + // Properties: &armmigrate.CollectorProperties{ + // AgentProperties: &armmigrate.CollectorAgentProperties{ + // ID: to.Ptr("75b0f71e-1272-4f29-a801-29cfa4b34a6e"), + // LastHeartbeatUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-28T06:21:28.7794661Z"); return t}()), + // SpnDetails: &armmigrate.CollectorBodyAgentSpnProperties{ + // ApplicationID: to.Ptr("fc717575-8173-4b21-92a5-658b655e613e"), + // Audience: to.Ptr("https://72f988bf-86f1-41af-91ab-2d7cd011db47/PortalvCenterbc2fagentauthaadapp"), + // Authority: to.Ptr("https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47"), + // ObjectID: to.Ptr("29d94f38-db94-4980-aec0-0cfd55ab1cd0"), + // TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), + // }, + // Version: to.Ptr("1.0.8.227"), + // }, + // CreatedTimestamp: to.Ptr("2019-05-09T09:58:21.4988104Z"), + // DiscoverySiteID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.OffAzure/VMwareSites/PortalvCenterbc2fsite"), + // UpdatedTimestamp: to.Ptr("2019-09-08T10:07:33.1996006Z"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/VMwareCollectors_Delete.json +func ExampleVMwareCollectorsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmigrate.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewVMwareCollectorsClient().Delete(ctx, "abgoyal-westEurope", "abgoyalWEselfhostb72bproject", "PortalvCenterbc2fcollector", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_assessedmachines_client_test.go b/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_assessedmachines_client_test.go deleted file mode 100644 index 7c946e013395..000000000000 --- a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_assessedmachines_client_test.go +++ /dev/null @@ -1,70 +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 armmigrate_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/migrate/armmigrate" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/AssessedMachines_ListByAssessment.json -func ExampleAssessedMachinesClient_NewListByAssessmentPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewAssessedMachinesClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByAssessmentPager("abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "Test1", - "assessment_5_9_2019_16_22_14", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/AssessedMachines_Get.json -func ExampleAssessedMachinesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewAssessedMachinesClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "Test1", - "assessment_5_9_2019_16_22_14", - "f57fe432-3bd2-486a-a83a-6f4d99f1a952", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_assessments_client_test.go b/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_assessments_client_test.go deleted file mode 100644 index b5f1cd126e8b..000000000000 --- a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_assessments_client_test.go +++ /dev/null @@ -1,178 +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 armmigrate_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/migrate/armmigrate" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Assessments_ListByGroup.json -func ExampleAssessmentsClient_NewListByGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewAssessmentsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByGroupPager("abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "Test1", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Assessments_ListByProject.json -func ExampleAssessmentsClient_NewListByProjectPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewAssessmentsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByProjectPager("abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Assessments_Get.json -func ExampleAssessmentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewAssessmentsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "Test1", - "assessment_5_9_2019_16_22_14", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Assessments_Create.json -func ExampleAssessmentsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewAssessmentsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "Group2", - "assessment_5_14_2019_16_48_47", - &armmigrate.AssessmentsClientCreateOptions{Assessment: &armmigrate.Assessment{ - ETag: to.Ptr("\"1e000c2c-0000-0d00-0000-5cdaa4190000\""), - Properties: &armmigrate.AssessmentProperties{ - AzureDiskType: to.Ptr(armmigrate.AzureDiskTypeStandardOrPremium), - AzureHybridUseBenefit: to.Ptr(armmigrate.AzureHybridUseBenefitYes), - AzureLocation: to.Ptr(armmigrate.AzureLocationNorthEurope), - AzureOfferCode: to.Ptr(armmigrate.AzureOfferCodeMSAZR0003P), - AzurePricingTier: to.Ptr(armmigrate.AzurePricingTierStandard), - AzureStorageRedundancy: to.Ptr(armmigrate.AzureStorageRedundancyLocallyRedundant), - AzureVMFamilies: []*armmigrate.AzureVMFamily{ - to.Ptr(armmigrate.AzureVMFamilyDv2Series), - to.Ptr(armmigrate.AzureVMFamilyFSeries), - to.Ptr(armmigrate.AzureVMFamilyDv3Series), - to.Ptr(armmigrate.AzureVMFamilyDSSeries), - to.Ptr(armmigrate.AzureVMFamilyDSv2Series), - to.Ptr(armmigrate.AzureVMFamilyFsSeries), - to.Ptr(armmigrate.AzureVMFamilyDsv3Series), - to.Ptr(armmigrate.AzureVMFamilyEv3Series), - to.Ptr(armmigrate.AzureVMFamilyEsv3Series), - to.Ptr(armmigrate.AzureVMFamilyDSeries), - to.Ptr(armmigrate.AzureVMFamilyMSeries), - to.Ptr(armmigrate.AzureVMFamilyFsv2Series), - to.Ptr(armmigrate.AzureVMFamilyHSeries)}, - Currency: to.Ptr(armmigrate.CurrencyUSD), - DiscountPercentage: to.Ptr[float64](100), - Percentile: to.Ptr(armmigrate.PercentilePercentile95), - ReservedInstance: to.Ptr(armmigrate.ReservedInstanceRI3Year), - ScalingFactor: to.Ptr[float64](1), - SizingCriterion: to.Ptr(armmigrate.AssessmentSizingCriterionPerformanceBased), - Stage: to.Ptr(armmigrate.AssessmentStageInProgress), - TimeRange: to.Ptr(armmigrate.TimeRangeDay), - VMUptime: &armmigrate.VMUptime{ - DaysPerMonth: to.Ptr[int32](31), - HoursPerDay: to.Ptr[int32](24), - }, - }, - }, - }) - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Assessments_Delete.json -func ExampleAssessmentsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewAssessmentsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "Test1", - "assessment_5_9_2019_16_22_14", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_groups_client_test.go b/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_groups_client_test.go deleted file mode 100644 index d305c9f8030e..000000000000 --- a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_groups_client_test.go +++ /dev/null @@ -1,138 +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 armmigrate_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/migrate/armmigrate" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Groups_ListByProject.json -func ExampleGroupsClient_NewListByProjectPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewGroupsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByProjectPager("abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Groups_Get.json -func ExampleGroupsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewGroupsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "Test1", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Groups_Create.json -func ExampleGroupsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewGroupsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "Group2", - &armmigrate.GroupsClientCreateOptions{Group: &armmigrate.Group{ - ETag: to.Ptr("\"1e000c2c-0000-0d00-0000-5cdaa4190000\""), - Properties: &armmigrate.GroupProperties{}, - }, - }) - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Groups_Delete.json -func ExampleGroupsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewGroupsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "Test1", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Groups_UpdateMachines.json -func ExampleGroupsClient_UpdateMachines() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewGroupsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.UpdateMachines(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "Group2", - &armmigrate.GroupsClientUpdateMachinesOptions{GroupUpdateProperties: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_hypervcollectors_client_test.go b/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_hypervcollectors_client_test.go deleted file mode 100644 index 530c5418ff03..000000000000 --- a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_hypervcollectors_client_test.go +++ /dev/null @@ -1,126 +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 armmigrate_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/migrate/armmigrate" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/HyperVCollectors_ListByProject.json -func ExampleHyperVCollectorsClient_NewListByProjectPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewHyperVCollectorsClient("8c3c936a-c09b-4de3-830b-3f5f244d72e9", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByProjectPager("contosoithyperv", - "migrateprojectce73project", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/HyperVCollectors_Get.json -func ExampleHyperVCollectorsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewHyperVCollectorsClient("8c3c936a-c09b-4de3-830b-3f5f244d72e9", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "contosoithyperv", - "migrateprojectce73project", - "migrateprojectce73collector", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/HyperVCollectors_Create.json -func ExampleHyperVCollectorsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewHyperVCollectorsClient("8c3c936a-c09b-4de3-830b-3f5f244d72e9", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, - "contosoithyperv", - "migrateprojectce73project", - "migrateprojectce73collector", - &armmigrate.HyperVCollectorsClientCreateOptions{CollectorBody: &armmigrate.HyperVCollector{ - ETag: to.Ptr("\"00000981-0000-0300-0000-5d74cd5f0000\""), - Properties: &armmigrate.CollectorProperties{ - AgentProperties: &armmigrate.CollectorAgentProperties{ - SpnDetails: &armmigrate.CollectorBodyAgentSpnProperties{ - ApplicationID: to.Ptr("827f1053-44dc-439f-b832-05416dcce12b"), - Audience: to.Ptr("https://72f988bf-86f1-41af-91ab-2d7cd011db47/migrateprojectce73agentauthaadapp"), - Authority: to.Ptr("https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47"), - ObjectID: to.Ptr("be75098e-c0fc-4ac4-98c7-282ebbcf8370"), - TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), - }, - }, - DiscoverySiteID: to.Ptr("/subscriptions/8c3c936a-c09b-4de3-830b-3f5f244d72e9/resourceGroups/ContosoITHyperV/providers/Microsoft.OffAzure/HyperVSites/migrateprojectce73site"), - }, - }, - }) - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/HyperVCollectors_Delete.json -func ExampleHyperVCollectorsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewHyperVCollectorsClient("8c3c936a-c09b-4de3-830b-3f5f244d72e9", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "contosoithyperv", - "migrateprojectce73project", - "migrateprojectce73collector", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_importcollectors_client_test.go b/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_importcollectors_client_test.go deleted file mode 100644 index 04bc940a2f41..000000000000 --- a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_importcollectors_client_test.go +++ /dev/null @@ -1,120 +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 armmigrate_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/migrate/armmigrate" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ImportCollectors_ListByProject.json -func ExampleImportCollectorsClient_NewListByProjectPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewImportCollectorsClient("31be0ff4-c932-4cb3-8efc-efa411d79280", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByProjectPager("markusavstestrg", - "rajoshCCY9671project", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ImportCollectors_Get.json -func ExampleImportCollectorsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewImportCollectorsClient("31be0ff4-c932-4cb3-8efc-efa411d79280", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "markusavstestrg", - "rajoshCCY9671project", - "importCollector2951", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ImportCollectors_Create.json -func ExampleImportCollectorsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewImportCollectorsClient("31be0ff4-c932-4cb3-8efc-efa411d79280", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, - "markusavstestrg", - "rajoshCCY9671project", - "importCollector2952", - &armmigrate.ImportCollectorsClientCreateOptions{CollectorBody: &armmigrate.ImportCollector{ - Name: to.Ptr("importCollector2951"), - Type: to.Ptr("Microsoft.Migrate/assessmentprojects/importcollectors"), - ETag: to.Ptr("\"000064a2-0000-3300-0000-605994800000\""), - ID: to.Ptr("/subscriptions/31be0ff4-c932-4cb3-8efc-efa411d79280/resourceGroups/markusavstestrg/providers/Microsoft.Migrate/assessmentprojects/rajoshCCY9671project/importcollectors/importCollector2951"), - Properties: &armmigrate.ImportCollectorProperties{ - DiscoverySiteID: to.Ptr("/subscriptions/31be0ff4-c932-4cb3-8efc-efa411d79280/resourcegroups/MarkusAVStestRG/providers/microsoft.offazure/importsites/rajoshCCY54cbimportSite"), - }, - }, - }) - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ImportCollectors_Delete.json -func ExampleImportCollectorsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewImportCollectorsClient("31be0ff4-c932-4cb3-8efc-efa411d79280", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "markusavstestrg", - "rajoshCCY9671project", - "importCollector2952", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_machines_client_test.go b/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_machines_client_test.go deleted file mode 100644 index cc8144fbb99d..000000000000 --- a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_machines_client_test.go +++ /dev/null @@ -1,66 +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 armmigrate_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/migrate/armmigrate" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Machines_ListByProject.json -func ExampleMachinesClient_NewListByProjectPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewMachinesClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByProjectPager("abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Machines_Get.json -func ExampleMachinesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewMachinesClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "269ef295-a38d-4f8f-9779-77ce79088311", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_operations_client_test.go deleted file mode 100644 index 8ed5316887e2..000000000000 --- a/sdk/resourcemanager/migrate/armmigrate/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 armmigrate_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/migrate/armmigrate" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Operations_List.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 := armmigrate.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/migrate/armmigrate/ze_generated_example_privateendpointconnection_client_test.go b/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_privateendpointconnection_client_test.go deleted file mode 100644 index 3b519df34ed9..000000000000 --- a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_privateendpointconnection_client_test.go +++ /dev/null @@ -1,116 +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 armmigrate_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/migrate/armmigrate" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/PrivateEndpointConnections_ListByProject.json -func ExamplePrivateEndpointConnectionClient_ListByProject() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewPrivateEndpointConnectionClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListByProject(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/PrivateEndpointConnections_Get.json -func ExamplePrivateEndpointConnectionClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewPrivateEndpointConnectionClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "custestpece80project3980pe.7e35576b-3df4-478e-9759-f64351cf4f43", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/PrivateEndpointConnections_Create.json -func ExamplePrivateEndpointConnectionClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewPrivateEndpointConnectionClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "custestpece80project3980pe.7e35576b-3df4-478e-9759-f64351cf4f43", - &armmigrate.PrivateEndpointConnectionClientUpdateOptions{PrivateEndpointConnectionBody: &armmigrate.PrivateEndpointConnection{ - ETag: to.Ptr("\"00009300-0000-0300-0000-602b967b0000\""), - Properties: &armmigrate.PrivateEndpointConnectionProperties{ - PrivateLinkServiceConnectionState: &armmigrate.PrivateLinkServiceConnectionState{ - ActionsRequired: to.Ptr(""), - Status: to.Ptr(armmigrate.PrivateLinkServiceConnectionStateStatusApproved), - }, - }, - }, - }) - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/PrivateEndpointConnections_Delete.json -func ExamplePrivateEndpointConnectionClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewPrivateEndpointConnectionClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "custestpece80project3980pe.7e35576b-3df4-478e-9759-f64351cf4f43", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_privatelinkresource_client_test.go b/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_privatelinkresource_client_test.go deleted file mode 100644 index e3980ce8c5bb..000000000000 --- a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_privatelinkresource_client_test.go +++ /dev/null @@ -1,62 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armmigrate_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/migrate/armmigrate" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/PrivateLinkResources_Get.json -func ExamplePrivateLinkResourceClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewPrivateLinkResourceClient("4bd2aa0f-2bd2-4d67-91a8-5a4533d58600", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "madhavicus", - "custestpece80project", - "Default", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/PrivateLinkResources_ListByProject.json -func ExamplePrivateLinkResourceClient_ListByProject() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewPrivateLinkResourceClient("4bd2aa0f-2bd2-4d67-91a8-5a4533d58600", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListByProject(ctx, - "madhavicus", - "custestpece80project", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_projects_client_test.go b/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_projects_client_test.go deleted file mode 100644 index 90fb1ddc2eff..000000000000 --- a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_projects_client_test.go +++ /dev/null @@ -1,220 +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 armmigrate_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/migrate/armmigrate" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ProjectsInSubscription_List.json -func ExampleProjectsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewProjectsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Projects_List.json -func ExampleProjectsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewProjectsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("abgoyal-westEurope", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Projects_Get.json -func ExampleProjectsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewProjectsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Projects_Create.json -func ExampleProjectsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewProjectsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, - "abgoyal-westEurope", - "abGoyalProject2", - &armmigrate.ProjectsClientCreateOptions{Project: &armmigrate.Project{ - ETag: to.Ptr(""), - Location: to.Ptr("West Europe"), - Properties: &armmigrate.ProjectProperties{ - AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/abgoyal-westeurope/providers/microsoft.migrate/migrateprojects/abgoyalweselfhost/Solutions/Servers-Assessment-ServerAssessment"), - ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), - }, - Tags: map[string]interface{}{}, - }, - }) - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Projects_Update.json -func ExampleProjectsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewProjectsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "abgoyal-westEurope", - "abGoyalProject2", - &armmigrate.ProjectsClientUpdateOptions{Project: &armmigrate.Project{ - ETag: to.Ptr(""), - Location: to.Ptr("West Europe"), - Properties: &armmigrate.ProjectProperties{ - AssessmentSolutionID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourcegroups/abgoyal-westeurope/providers/microsoft.migrate/migrateprojects/abgoyalweselfhost/Solutions/Servers-Assessment-ServerAssessment"), - ProjectStatus: to.Ptr(armmigrate.ProjectStatusActive), - }, - Tags: map[string]interface{}{}, - }, - }) - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/Projects_Delete.json -func ExampleProjectsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewProjectsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "abgoyal-westEurope", - "abGoyalProject2", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/AssessmentOptions_Get.json -func ExampleProjectsClient_AssessmentOptions() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewProjectsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.AssessmentOptions(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "default", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/AssessmentOptions_List.json -func ExampleProjectsClient_NewAssessmentOptionsListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewProjectsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewAssessmentOptionsListPager("abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - 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/migrate/armmigrate/ze_generated_example_servercollectors_client_test.go b/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_servercollectors_client_test.go deleted file mode 100644 index fc9767c91fe3..000000000000 --- a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_servercollectors_client_test.go +++ /dev/null @@ -1,126 +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 armmigrate_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/migrate/armmigrate" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ServerCollectors_ListByProject.json -func ExampleServerCollectorsClient_NewListByProjectPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewServerCollectorsClient("4bd2aa0f-2bd2-4d67-91a8-5a4533d58600", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByProjectPager("pajindtest", - "app11141project", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ServerCollectors_Get.json -func ExampleServerCollectorsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewServerCollectorsClient("4bd2aa0f-2bd2-4d67-91a8-5a4533d58600", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "pajindtest", - "app11141project", - "app23df4collector", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ServerCollectors_Create.json -func ExampleServerCollectorsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewServerCollectorsClient("4bd2aa0f-2bd2-4d67-91a8-5a4533d58600", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, - "pajindtest", - "app11141project", - "app23df4collector", - &armmigrate.ServerCollectorsClientCreateOptions{CollectorBody: &armmigrate.ServerCollector{ - ETag: to.Ptr("\"00000606-0000-0d00-0000-605999bf0000\""), - Properties: &armmigrate.CollectorProperties{ - AgentProperties: &armmigrate.CollectorAgentProperties{ - SpnDetails: &armmigrate.CollectorBodyAgentSpnProperties{ - ApplicationID: to.Ptr("ad9f701a-cc08-4421-b51f-b5762d58e9ba"), - Audience: to.Ptr("https://72f988bf-86f1-41af-91ab-2d7cd011db47/app23df4authandaccessaadapp"), - Authority: to.Ptr("https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47"), - ObjectID: to.Ptr("b4975e42-9248-4a36-b99f-37eca377ea00"), - TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), - }, - }, - DiscoverySiteID: to.Ptr("/subscriptions/4bd2aa0f-2bd2-4d67-91a8-5a4533d58600/resourceGroups/pajindTest/providers/Microsoft.OffAzure/ServerSites/app21141site"), - }, - }, - }) - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/ServerCollectors_Delete.json -func ExampleServerCollectorsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewServerCollectorsClient("4bd2aa0f-2bd2-4d67-91a8-5a4533d58600", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "pajindtest", - "app11141project", - "app23df4collector", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_vmwarecollectors_client_test.go b/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_vmwarecollectors_client_test.go deleted file mode 100644 index 41e488f8d8a2..000000000000 --- a/sdk/resourcemanager/migrate/armmigrate/ze_generated_example_vmwarecollectors_client_test.go +++ /dev/null @@ -1,126 +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 armmigrate_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/migrate/armmigrate" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/VMwareCollectors_ListByProject.json -func ExampleVMwareCollectorsClient_NewListByProjectPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewVMwareCollectorsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByProjectPager("abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/VMwareCollectors_Get.json -func ExampleVMwareCollectorsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewVMwareCollectorsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "PortalvCenterbc2fcollector", - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/VMwareCollectors_Create.json -func ExampleVMwareCollectorsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewVMwareCollectorsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "PortalvCenterbc2fcollector", - &armmigrate.VMwareCollectorsClientCreateOptions{CollectorBody: &armmigrate.VMwareCollector{ - ETag: to.Ptr("\"01003d32-0000-0d00-0000-5d74d2e50000\""), - Properties: &armmigrate.CollectorProperties{ - AgentProperties: &armmigrate.CollectorAgentProperties{ - SpnDetails: &armmigrate.CollectorBodyAgentSpnProperties{ - ApplicationID: to.Ptr("fc717575-8173-4b21-92a5-658b655e613e"), - Audience: to.Ptr("https://72f988bf-86f1-41af-91ab-2d7cd011db47/PortalvCenterbc2fagentauthaadapp"), - Authority: to.Ptr("https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47"), - ObjectID: to.Ptr("29d94f38-db94-4980-aec0-0cfd55ab1cd0"), - TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), - }, - }, - DiscoverySiteID: to.Ptr("/subscriptions/6393a73f-8d55-47ef-b6dd-179b3e0c7910/resourceGroups/abgoyal-westEurope/providers/Microsoft.OffAzure/VMwareSites/PortalvCenterbc2fsite"), - }, - }, - }) - 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/migrate/resource-manager/Microsoft.Migrate/stable/2019-10-01/examples/VMwareCollectors_Delete.json -func ExampleVMwareCollectorsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmigrate.NewVMwareCollectorsClient("6393a73f-8d55-47ef-b6dd-179b3e0c7910", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "abgoyal-westEurope", - "abgoyalWEselfhostb72bproject", - "PortalvCenterbc2fcollector", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/migrate/armmigrate/zz_generated_models_serde.go b/sdk/resourcemanager/migrate/armmigrate/zz_generated_models_serde.go deleted file mode 100644 index 305914f99872..000000000000 --- a/sdk/resourcemanager/migrate/armmigrate/zz_generated_models_serde.go +++ /dev/null @@ -1,565 +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 armmigrate - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// UnmarshalJSON implements the json.Unmarshaller interface for type AssessedMachineProperties. -func (a *AssessedMachineProperties) 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 "bootType": - err = unpopulate(val, "BootType", &a.BootType) - delete(rawMsg, key) - case "confidenceRatingInPercentage": - err = unpopulate(val, "ConfidenceRatingInPercentage", &a.ConfidenceRatingInPercentage) - delete(rawMsg, key) - case "createdTimestamp": - err = unpopulateTimeRFC3339(val, "CreatedTimestamp", &a.CreatedTimestamp) - delete(rawMsg, key) - case "datacenterMachineArmId": - err = unpopulate(val, "DatacenterMachineArmID", &a.DatacenterMachineArmID) - delete(rawMsg, key) - case "datacenterManagementServerArmId": - err = unpopulate(val, "DatacenterManagementServerArmID", &a.DatacenterManagementServerArmID) - delete(rawMsg, key) - case "datacenterManagementServerName": - err = unpopulate(val, "DatacenterManagementServerName", &a.DatacenterManagementServerName) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &a.Description) - delete(rawMsg, key) - case "disks": - err = unpopulate(val, "Disks", &a.Disks) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &a.DisplayName) - delete(rawMsg, key) - case "megabytesOfMemory": - err = unpopulate(val, "MegabytesOfMemory", &a.MegabytesOfMemory) - delete(rawMsg, key) - case "megabytesOfMemoryForRecommendedSize": - err = unpopulate(val, "MegabytesOfMemoryForRecommendedSize", &a.MegabytesOfMemoryForRecommendedSize) - delete(rawMsg, key) - case "monthlyBandwidthCost": - err = unpopulate(val, "MonthlyBandwidthCost", &a.MonthlyBandwidthCost) - delete(rawMsg, key) - case "monthlyComputeCostForRecommendedSize": - err = unpopulate(val, "MonthlyComputeCostForRecommendedSize", &a.MonthlyComputeCostForRecommendedSize) - delete(rawMsg, key) - case "monthlyPremiumStorageCost": - err = unpopulate(val, "MonthlyPremiumStorageCost", &a.MonthlyPremiumStorageCost) - delete(rawMsg, key) - case "monthlyStandardSSDStorageCost": - err = unpopulate(val, "MonthlyStandardSSDStorageCost", &a.MonthlyStandardSSDStorageCost) - delete(rawMsg, key) - case "monthlyStorageCost": - err = unpopulate(val, "MonthlyStorageCost", &a.MonthlyStorageCost) - delete(rawMsg, key) - case "networkAdapters": - err = unpopulate(val, "NetworkAdapters", &a.NetworkAdapters) - delete(rawMsg, key) - case "numberOfCores": - err = unpopulate(val, "NumberOfCores", &a.NumberOfCores) - delete(rawMsg, key) - case "numberOfCoresForRecommendedSize": - err = unpopulate(val, "NumberOfCoresForRecommendedSize", &a.NumberOfCoresForRecommendedSize) - delete(rawMsg, key) - case "operatingSystemName": - err = unpopulate(val, "OperatingSystemName", &a.OperatingSystemName) - delete(rawMsg, key) - case "operatingSystemType": - err = unpopulate(val, "OperatingSystemType", &a.OperatingSystemType) - delete(rawMsg, key) - case "operatingSystemVersion": - err = unpopulate(val, "OperatingSystemVersion", &a.OperatingSystemVersion) - delete(rawMsg, key) - case "percentageCoresUtilization": - err = unpopulate(val, "PercentageCoresUtilization", &a.PercentageCoresUtilization) - delete(rawMsg, key) - case "percentageMemoryUtilization": - err = unpopulate(val, "PercentageMemoryUtilization", &a.PercentageMemoryUtilization) - delete(rawMsg, key) - case "recommendedSize": - err = unpopulate(val, "RecommendedSize", &a.RecommendedSize) - delete(rawMsg, key) - case "suitability": - err = unpopulate(val, "Suitability", &a.Suitability) - delete(rawMsg, key) - case "suitabilityDetail": - err = unpopulate(val, "SuitabilityDetail", &a.SuitabilityDetail) - delete(rawMsg, key) - case "suitabilityExplanation": - err = unpopulate(val, "SuitabilityExplanation", &a.SuitabilityExplanation) - delete(rawMsg, key) - case "updatedTimestamp": - err = unpopulateTimeRFC3339(val, "UpdatedTimestamp", &a.UpdatedTimestamp) - 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 AssessmentProperties. -func (a AssessmentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "azureDiskType", a.AzureDiskType) - populate(objectMap, "azureHybridUseBenefit", a.AzureHybridUseBenefit) - populate(objectMap, "azureLocation", a.AzureLocation) - populate(objectMap, "azureOfferCode", a.AzureOfferCode) - populate(objectMap, "azurePricingTier", a.AzurePricingTier) - populate(objectMap, "azureStorageRedundancy", a.AzureStorageRedundancy) - populate(objectMap, "azureVmFamilies", a.AzureVMFamilies) - populate(objectMap, "confidenceRatingInPercentage", a.ConfidenceRatingInPercentage) - populateTimeRFC3339(objectMap, "createdTimestamp", a.CreatedTimestamp) - populate(objectMap, "currency", a.Currency) - populate(objectMap, "discountPercentage", a.DiscountPercentage) - populate(objectMap, "eaSubscriptionId", a.EaSubscriptionID) - populate(objectMap, "monthlyBandwidthCost", a.MonthlyBandwidthCost) - populate(objectMap, "monthlyComputeCost", a.MonthlyComputeCost) - populate(objectMap, "monthlyPremiumStorageCost", a.MonthlyPremiumStorageCost) - populate(objectMap, "monthlyStandardSSDStorageCost", a.MonthlyStandardSSDStorageCost) - populate(objectMap, "monthlyStorageCost", a.MonthlyStorageCost) - populate(objectMap, "numberOfMachines", a.NumberOfMachines) - populate(objectMap, "percentile", a.Percentile) - populateTimeRFC3339(objectMap, "perfDataEndTime", a.PerfDataEndTime) - populateTimeRFC3339(objectMap, "perfDataStartTime", a.PerfDataStartTime) - populateTimeRFC3339(objectMap, "pricesTimestamp", a.PricesTimestamp) - populate(objectMap, "reservedInstance", a.ReservedInstance) - populate(objectMap, "scalingFactor", a.ScalingFactor) - populate(objectMap, "sizingCriterion", a.SizingCriterion) - populate(objectMap, "stage", a.Stage) - populate(objectMap, "status", a.Status) - populate(objectMap, "timeRange", a.TimeRange) - populateTimeRFC3339(objectMap, "updatedTimestamp", a.UpdatedTimestamp) - populate(objectMap, "vmUptime", a.VMUptime) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AssessmentProperties. -func (a *AssessmentProperties) 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 "azureDiskType": - err = unpopulate(val, "AzureDiskType", &a.AzureDiskType) - delete(rawMsg, key) - case "azureHybridUseBenefit": - err = unpopulate(val, "AzureHybridUseBenefit", &a.AzureHybridUseBenefit) - delete(rawMsg, key) - case "azureLocation": - err = unpopulate(val, "AzureLocation", &a.AzureLocation) - delete(rawMsg, key) - case "azureOfferCode": - err = unpopulate(val, "AzureOfferCode", &a.AzureOfferCode) - delete(rawMsg, key) - case "azurePricingTier": - err = unpopulate(val, "AzurePricingTier", &a.AzurePricingTier) - delete(rawMsg, key) - case "azureStorageRedundancy": - err = unpopulate(val, "AzureStorageRedundancy", &a.AzureStorageRedundancy) - delete(rawMsg, key) - case "azureVmFamilies": - err = unpopulate(val, "AzureVMFamilies", &a.AzureVMFamilies) - delete(rawMsg, key) - case "confidenceRatingInPercentage": - err = unpopulate(val, "ConfidenceRatingInPercentage", &a.ConfidenceRatingInPercentage) - delete(rawMsg, key) - case "createdTimestamp": - err = unpopulateTimeRFC3339(val, "CreatedTimestamp", &a.CreatedTimestamp) - delete(rawMsg, key) - case "currency": - err = unpopulate(val, "Currency", &a.Currency) - delete(rawMsg, key) - case "discountPercentage": - err = unpopulate(val, "DiscountPercentage", &a.DiscountPercentage) - delete(rawMsg, key) - case "eaSubscriptionId": - err = unpopulate(val, "EaSubscriptionID", &a.EaSubscriptionID) - delete(rawMsg, key) - case "monthlyBandwidthCost": - err = unpopulate(val, "MonthlyBandwidthCost", &a.MonthlyBandwidthCost) - delete(rawMsg, key) - case "monthlyComputeCost": - err = unpopulate(val, "MonthlyComputeCost", &a.MonthlyComputeCost) - delete(rawMsg, key) - case "monthlyPremiumStorageCost": - err = unpopulate(val, "MonthlyPremiumStorageCost", &a.MonthlyPremiumStorageCost) - delete(rawMsg, key) - case "monthlyStandardSSDStorageCost": - err = unpopulate(val, "MonthlyStandardSSDStorageCost", &a.MonthlyStandardSSDStorageCost) - delete(rawMsg, key) - case "monthlyStorageCost": - err = unpopulate(val, "MonthlyStorageCost", &a.MonthlyStorageCost) - delete(rawMsg, key) - case "numberOfMachines": - err = unpopulate(val, "NumberOfMachines", &a.NumberOfMachines) - delete(rawMsg, key) - case "percentile": - err = unpopulate(val, "Percentile", &a.Percentile) - delete(rawMsg, key) - case "perfDataEndTime": - err = unpopulateTimeRFC3339(val, "PerfDataEndTime", &a.PerfDataEndTime) - delete(rawMsg, key) - case "perfDataStartTime": - err = unpopulateTimeRFC3339(val, "PerfDataStartTime", &a.PerfDataStartTime) - delete(rawMsg, key) - case "pricesTimestamp": - err = unpopulateTimeRFC3339(val, "PricesTimestamp", &a.PricesTimestamp) - delete(rawMsg, key) - case "reservedInstance": - err = unpopulate(val, "ReservedInstance", &a.ReservedInstance) - delete(rawMsg, key) - case "scalingFactor": - err = unpopulate(val, "ScalingFactor", &a.ScalingFactor) - delete(rawMsg, key) - case "sizingCriterion": - err = unpopulate(val, "SizingCriterion", &a.SizingCriterion) - delete(rawMsg, key) - case "stage": - err = unpopulate(val, "Stage", &a.Stage) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &a.Status) - delete(rawMsg, key) - case "timeRange": - err = unpopulate(val, "TimeRange", &a.TimeRange) - delete(rawMsg, key) - case "updatedTimestamp": - err = unpopulateTimeRFC3339(val, "UpdatedTimestamp", &a.UpdatedTimestamp) - delete(rawMsg, key) - case "vmUptime": - err = unpopulate(val, "VMUptime", &a.VMUptime) - 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 CollectorAgentProperties. -func (c CollectorAgentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", c.ID) - populateTimeRFC3339(objectMap, "lastHeartbeatUtc", c.LastHeartbeatUTC) - populate(objectMap, "spnDetails", c.SpnDetails) - populate(objectMap, "version", c.Version) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type CollectorAgentProperties. -func (c *CollectorAgentProperties) 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 "id": - err = unpopulate(val, "ID", &c.ID) - delete(rawMsg, key) - case "lastHeartbeatUtc": - err = unpopulateTimeRFC3339(val, "LastHeartbeatUTC", &c.LastHeartbeatUTC) - delete(rawMsg, key) - case "spnDetails": - err = unpopulate(val, "SpnDetails", &c.SpnDetails) - delete(rawMsg, key) - case "version": - err = unpopulate(val, "Version", &c.Version) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DownloadURL. -func (d *DownloadURL) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "assessmentReportUrl": - err = unpopulate(val, "AssessmentReportURL", &d.AssessmentReportURL) - delete(rawMsg, key) - case "expirationTime": - err = unpopulateTimeRFC3339(val, "ExpirationTime", &d.ExpirationTime) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type GroupBodyProperties. -func (g GroupBodyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "machines", g.Machines) - populate(objectMap, "operationType", g.OperationType) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type GroupProperties. -func (g GroupProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "areAssessmentsRunning", g.AreAssessmentsRunning) - populate(objectMap, "assessments", g.Assessments) - populateTimeRFC3339(objectMap, "createdTimestamp", g.CreatedTimestamp) - populate(objectMap, "groupStatus", g.GroupStatus) - populate(objectMap, "groupType", g.GroupType) - populate(objectMap, "machineCount", g.MachineCount) - populateTimeRFC3339(objectMap, "updatedTimestamp", g.UpdatedTimestamp) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type GroupProperties. -func (g *GroupProperties) 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", g, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "areAssessmentsRunning": - err = unpopulate(val, "AreAssessmentsRunning", &g.AreAssessmentsRunning) - delete(rawMsg, key) - case "assessments": - err = unpopulate(val, "Assessments", &g.Assessments) - delete(rawMsg, key) - case "createdTimestamp": - err = unpopulateTimeRFC3339(val, "CreatedTimestamp", &g.CreatedTimestamp) - delete(rawMsg, key) - case "groupStatus": - err = unpopulate(val, "GroupStatus", &g.GroupStatus) - delete(rawMsg, key) - case "groupType": - err = unpopulate(val, "GroupType", &g.GroupType) - delete(rawMsg, key) - case "machineCount": - err = unpopulate(val, "MachineCount", &g.MachineCount) - delete(rawMsg, key) - case "updatedTimestamp": - err = unpopulateTimeRFC3339(val, "UpdatedTimestamp", &g.UpdatedTimestamp) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", g, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type MachineProperties. -func (m *MachineProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "bootType": - err = unpopulate(val, "BootType", &m.BootType) - delete(rawMsg, key) - case "createdTimestamp": - err = unpopulateTimeRFC3339(val, "CreatedTimestamp", &m.CreatedTimestamp) - delete(rawMsg, key) - case "datacenterManagementServerArmId": - err = unpopulate(val, "DatacenterManagementServerArmID", &m.DatacenterManagementServerArmID) - delete(rawMsg, key) - case "datacenterManagementServerName": - err = unpopulate(val, "DatacenterManagementServerName", &m.DatacenterManagementServerName) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &m.Description) - delete(rawMsg, key) - case "discoveryMachineArmId": - err = unpopulate(val, "DiscoveryMachineArmID", &m.DiscoveryMachineArmID) - delete(rawMsg, key) - case "disks": - err = unpopulate(val, "Disks", &m.Disks) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &m.DisplayName) - delete(rawMsg, key) - case "groups": - err = unpopulate(val, "Groups", &m.Groups) - delete(rawMsg, key) - case "megabytesOfMemory": - err = unpopulate(val, "MegabytesOfMemory", &m.MegabytesOfMemory) - delete(rawMsg, key) - case "networkAdapters": - err = unpopulate(val, "NetworkAdapters", &m.NetworkAdapters) - delete(rawMsg, key) - case "numberOfCores": - err = unpopulate(val, "NumberOfCores", &m.NumberOfCores) - delete(rawMsg, key) - case "operatingSystemName": - err = unpopulate(val, "OperatingSystemName", &m.OperatingSystemName) - delete(rawMsg, key) - case "operatingSystemType": - err = unpopulate(val, "OperatingSystemType", &m.OperatingSystemType) - delete(rawMsg, key) - case "operatingSystemVersion": - err = unpopulate(val, "OperatingSystemVersion", &m.OperatingSystemVersion) - delete(rawMsg, key) - case "updatedTimestamp": - err = unpopulateTimeRFC3339(val, "UpdatedTimestamp", &m.UpdatedTimestamp) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Project. -func (p Project) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "eTag", p.ETag) - populate(objectMap, "id", p.ID) - populate(objectMap, "location", p.Location) - populate(objectMap, "name", p.Name) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "tags", &p.Tags) - populate(objectMap, "type", p.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ProjectProperties. -func (p ProjectProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "assessmentSolutionId", p.AssessmentSolutionID) - populateTimeRFC3339(objectMap, "createdTimestamp", p.CreatedTimestamp) - populate(objectMap, "customerStorageAccountArmId", p.CustomerStorageAccountArmID) - populate(objectMap, "customerWorkspaceId", p.CustomerWorkspaceID) - populate(objectMap, "customerWorkspaceLocation", p.CustomerWorkspaceLocation) - populateTimeRFC3339(objectMap, "lastAssessmentTimestamp", p.LastAssessmentTimestamp) - populate(objectMap, "numberOfAssessments", p.NumberOfAssessments) - populate(objectMap, "numberOfGroups", p.NumberOfGroups) - populate(objectMap, "numberOfMachines", p.NumberOfMachines) - populate(objectMap, "privateEndpointConnections", p.PrivateEndpointConnections) - populate(objectMap, "projectStatus", p.ProjectStatus) - populate(objectMap, "provisioningState", p.ProvisioningState) - populate(objectMap, "publicNetworkAccess", p.PublicNetworkAccess) - populate(objectMap, "serviceEndpoint", p.ServiceEndpoint) - populateTimeRFC3339(objectMap, "updatedTimestamp", p.UpdatedTimestamp) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectProperties. -func (p *ProjectProperties) 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 "assessmentSolutionId": - err = unpopulate(val, "AssessmentSolutionID", &p.AssessmentSolutionID) - delete(rawMsg, key) - case "createdTimestamp": - err = unpopulateTimeRFC3339(val, "CreatedTimestamp", &p.CreatedTimestamp) - delete(rawMsg, key) - case "customerStorageAccountArmId": - err = unpopulate(val, "CustomerStorageAccountArmID", &p.CustomerStorageAccountArmID) - delete(rawMsg, key) - case "customerWorkspaceId": - err = unpopulate(val, "CustomerWorkspaceID", &p.CustomerWorkspaceID) - delete(rawMsg, key) - case "customerWorkspaceLocation": - err = unpopulate(val, "CustomerWorkspaceLocation", &p.CustomerWorkspaceLocation) - delete(rawMsg, key) - case "lastAssessmentTimestamp": - err = unpopulateTimeRFC3339(val, "LastAssessmentTimestamp", &p.LastAssessmentTimestamp) - delete(rawMsg, key) - case "numberOfAssessments": - err = unpopulate(val, "NumberOfAssessments", &p.NumberOfAssessments) - delete(rawMsg, key) - case "numberOfGroups": - err = unpopulate(val, "NumberOfGroups", &p.NumberOfGroups) - delete(rawMsg, key) - case "numberOfMachines": - err = unpopulate(val, "NumberOfMachines", &p.NumberOfMachines) - delete(rawMsg, key) - case "privateEndpointConnections": - err = unpopulate(val, "PrivateEndpointConnections", &p.PrivateEndpointConnections) - delete(rawMsg, key) - case "projectStatus": - err = unpopulate(val, "ProjectStatus", &p.ProjectStatus) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) - delete(rawMsg, key) - case "publicNetworkAccess": - err = unpopulate(val, "PublicNetworkAccess", &p.PublicNetworkAccess) - delete(rawMsg, key) - case "serviceEndpoint": - err = unpopulate(val, "ServiceEndpoint", &p.ServiceEndpoint) - delete(rawMsg, key) - case "updatedTimestamp": - err = unpopulateTimeRFC3339(val, "UpdatedTimestamp", &p.UpdatedTimestamp) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, 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/mixedreality/armmixedreality/CHANGELOG.md b/sdk/resourcemanager/mixedreality/armmixedreality/CHANGELOG.md index 82e6610aa27c..26c0832c442e 100644 --- a/sdk/resourcemanager/mixedreality/armmixedreality/CHANGELOG.md +++ b/sdk/resourcemanager/mixedreality/armmixedreality/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.6.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.5.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mixedreality/armmixedreality` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.5.0, which contains breaking changes. diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/README.md b/sdk/resourcemanager/mixedreality/armmixedreality/README.md index 52ab20c9a297..0a5acd84c67b 100644 --- a/sdk/resourcemanager/mixedreality/armmixedreality/README.md +++ b/sdk/resourcemanager/mixedreality/armmixedreality/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Mixed Readlity modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Mixed Readlity module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armmixedreality.NewObjectAnchorsAccountsClient(, cred, nil) +clientFactory, err := armmixedreality.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armmixedreality.NewObjectAnchorsAccountsClient(, cred, &options) +clientFactory, err := armmixedreality.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewObjectAnchorsAccountsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/autorest.md b/sdk/resourcemanager/mixedreality/armmixedreality/autorest.md index 8967a6f93e7b..08f0a01be0d0 100644 --- a/sdk/resourcemanager/mixedreality/armmixedreality/autorest.md +++ b/sdk/resourcemanager/mixedreality/armmixedreality/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.5.0 +module-version: 0.6.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_client.go b/sdk/resourcemanager/mixedreality/armmixedreality/client.go similarity index 76% rename from sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_client.go rename to sdk/resourcemanager/mixedreality/armmixedreality/client.go index 2be3db3a8b91..156a731d2df8 100644 --- a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_client.go +++ b/sdk/resourcemanager/mixedreality/armmixedreality/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 armmixedreality @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // Client contains the methods for the MixedRealityClient group. // Don't use this type directly, use NewClient() instead. type Client struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewClient creates a new instance of Client with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".Client", moduleVersion, credential, options) if err != nil { return nil, err } client := &Client{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CheckNameAvailabilityLocal - Check Name Availability for local uniqueness // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// location - The location in which uniqueness will be verified. -// checkNameAvailability - Check Name Availability Request. -// options - ClientCheckNameAvailabilityLocalOptions contains the optional parameters for the Client.CheckNameAvailabilityLocal -// method. +// - location - The location in which uniqueness will be verified. +// - checkNameAvailability - Check Name Availability Request. +// - options - ClientCheckNameAvailabilityLocalOptions contains the optional parameters for the Client.CheckNameAvailabilityLocal +// method. func (client *Client) CheckNameAvailabilityLocal(ctx context.Context, location string, checkNameAvailability CheckNameAvailabilityRequest, options *ClientCheckNameAvailabilityLocalOptions) (ClientCheckNameAvailabilityLocalResponse, error) { req, err := client.checkNameAvailabilityLocalCreateRequest(ctx, location, checkNameAvailability, options) if err != nil { return ClientCheckNameAvailabilityLocalResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientCheckNameAvailabilityLocalResponse{}, err } @@ -87,7 +78,7 @@ func (client *Client) checkNameAvailabilityLocalCreateRequest(ctx context.Contex return nil, errors.New("parameter location cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/client_example_test.go b/sdk/resourcemanager/mixedreality/armmixedreality/client_example_test.go new file mode 100644 index 000000000000..caa43950ed14 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/client_example_test.go @@ -0,0 +1,47 @@ +//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 armmixedreality_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/mixedreality/armmixedreality" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/proxy/CheckNameAvailabilityForLocalUniqueness.json +func ExampleClient_CheckNameAvailabilityLocal() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewClient().CheckNameAvailabilityLocal(ctx, "eastus2euap", armmixedreality.CheckNameAvailabilityRequest{ + Name: to.Ptr("MyAccount"), + Type: to.Ptr("Microsoft.MixedReality/spatialAnchorsAccounts"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CheckNameAvailabilityResponse = armmixedreality.CheckNameAvailabilityResponse{ + // Message: to.Ptr("..."), + // NameAvailable: to.Ptr(false), + // Reason: to.Ptr(armmixedreality.NameUnavailableReasonAlreadyExists), + // } +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/client_factory.go b/sdk/resourcemanager/mixedreality/armmixedreality/client_factory.go new file mode 100644 index 000000000000..fcc3e49805f3 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/client_factory.go @@ -0,0 +1,64 @@ +//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 armmixedreality + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewClient() *Client { + subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSpatialAnchorsAccountsClient() *SpatialAnchorsAccountsClient { + subClient, _ := NewSpatialAnchorsAccountsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewRemoteRenderingAccountsClient() *RemoteRenderingAccountsClient { + subClient, _ := NewRemoteRenderingAccountsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewObjectAnchorsAccountsClient() *ObjectAnchorsAccountsClient { + subClient, _ := NewObjectAnchorsAccountsClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_constants.go b/sdk/resourcemanager/mixedreality/armmixedreality/constants.go similarity index 98% rename from sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_constants.go rename to sdk/resourcemanager/mixedreality/armmixedreality/constants.go index eb56ad9e33d6..d1baa630b9f2 100644 --- a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_constants.go +++ b/sdk/resourcemanager/mixedreality/armmixedreality/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 armmixedreality const ( moduleName = "armmixedreality" - moduleVersion = "v0.5.0" + moduleVersion = "v0.6.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/go.mod b/sdk/resourcemanager/mixedreality/armmixedreality/go.mod index cdfa76a5fa8b..aeb3923eba63 100644 --- a/sdk/resourcemanager/mixedreality/armmixedreality/go.mod +++ b/sdk/resourcemanager/mixedreality/armmixedreality/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mixedreality/armmix go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) 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/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/go.sum b/sdk/resourcemanager/mixedreality/armmixedreality/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/mixedreality/armmixedreality/go.sum +++ b/sdk/resourcemanager/mixedreality/armmixedreality/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= 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/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_models.go b/sdk/resourcemanager/mixedreality/armmixedreality/models.go similarity index 95% rename from sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_models.go rename to sdk/resourcemanager/mixedreality/armmixedreality/models.go index c3e27de425aa..2a72c64693d6 100644 --- a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_models.go +++ b/sdk/resourcemanager/mixedreality/armmixedreality/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 armmixedreality @@ -63,27 +64,6 @@ type ClientCheckNameAvailabilityLocalOptions struct { // placeholder for future optional parameters } -// CloudError - An Error response. -type CloudError struct { - // An Error response. - Error *CloudErrorBody `json:"error,omitempty"` -} - -// CloudErrorBody - An error response from Azure. -type CloudErrorBody struct { - // An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - Code *string `json:"code,omitempty"` - - // A list of additional details about the error. - Details []*CloudErrorBody `json:"details,omitempty"` - - // A message describing the error, intended to be suitable for displaying in a user interface. - Message *string `json:"message,omitempty"` - - // The target of the particular error. For example, the name of the property in error. - Target *string `json:"target,omitempty"` -} - // Identity for the resource. type Identity struct { // The identity type. @@ -244,13 +224,13 @@ type ObjectAnchorsAccountsClientGetOptions struct { // placeholder for future optional parameters } -// ObjectAnchorsAccountsClientListByResourceGroupOptions contains the optional parameters for the ObjectAnchorsAccountsClient.ListByResourceGroup +// ObjectAnchorsAccountsClientListByResourceGroupOptions contains the optional parameters for the ObjectAnchorsAccountsClient.NewListByResourceGroupPager // method. type ObjectAnchorsAccountsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// ObjectAnchorsAccountsClientListBySubscriptionOptions contains the optional parameters for the ObjectAnchorsAccountsClient.ListBySubscription +// ObjectAnchorsAccountsClientListBySubscriptionOptions contains the optional parameters for the ObjectAnchorsAccountsClient.NewListBySubscriptionPager // method. type ObjectAnchorsAccountsClientListBySubscriptionOptions struct { // placeholder for future optional parameters @@ -322,7 +302,7 @@ type OperationProperties struct { ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -390,13 +370,13 @@ type RemoteRenderingAccountsClientGetOptions struct { // placeholder for future optional parameters } -// RemoteRenderingAccountsClientListByResourceGroupOptions contains the optional parameters for the RemoteRenderingAccountsClient.ListByResourceGroup +// RemoteRenderingAccountsClientListByResourceGroupOptions contains the optional parameters for the RemoteRenderingAccountsClient.NewListByResourceGroupPager // method. type RemoteRenderingAccountsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// RemoteRenderingAccountsClientListBySubscriptionOptions contains the optional parameters for the RemoteRenderingAccountsClient.ListBySubscription +// RemoteRenderingAccountsClientListBySubscriptionOptions contains the optional parameters for the RemoteRenderingAccountsClient.NewListBySubscriptionPager // method. type RemoteRenderingAccountsClientListBySubscriptionOptions struct { // placeholder for future optional parameters @@ -524,13 +504,13 @@ type SpatialAnchorsAccountsClientGetOptions struct { // placeholder for future optional parameters } -// SpatialAnchorsAccountsClientListByResourceGroupOptions contains the optional parameters for the SpatialAnchorsAccountsClient.ListByResourceGroup +// SpatialAnchorsAccountsClientListByResourceGroupOptions contains the optional parameters for the SpatialAnchorsAccountsClient.NewListByResourceGroupPager // method. type SpatialAnchorsAccountsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// SpatialAnchorsAccountsClientListBySubscriptionOptions contains the optional parameters for the SpatialAnchorsAccountsClient.ListBySubscription +// SpatialAnchorsAccountsClientListBySubscriptionOptions contains the optional parameters for the SpatialAnchorsAccountsClient.NewListBySubscriptionPager // method. type SpatialAnchorsAccountsClientListBySubscriptionOptions struct { // placeholder for future optional parameters diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/models_serde.go b/sdk/resourcemanager/mixedreality/armmixedreality/models_serde.go new file mode 100644 index 000000000000..8c08c7c2ee66 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/models_serde.go @@ -0,0 +1,1060 @@ +//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 armmixedreality + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AccountKeyRegenerateRequest. +func (a AccountKeyRegenerateRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "serial", a.Serial) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountKeyRegenerateRequest. +func (a *AccountKeyRegenerateRequest) 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 "serial": + err = unpopulate(val, "Serial", &a.Serial) + 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 AccountKeys. +func (a AccountKeys) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "primaryKey", a.PrimaryKey) + populate(objectMap, "secondaryKey", a.SecondaryKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountKeys. +func (a *AccountKeys) 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 "primaryKey": + err = unpopulate(val, "PrimaryKey", &a.PrimaryKey) + delete(rawMsg, key) + case "secondaryKey": + err = unpopulate(val, "SecondaryKey", &a.SecondaryKey) + 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 AccountProperties. +func (a AccountProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountDomain", a.AccountDomain) + populate(objectMap, "accountId", a.AccountID) + populate(objectMap, "storageAccountName", a.StorageAccountName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountProperties. +func (a *AccountProperties) 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 "accountDomain": + err = unpopulate(val, "AccountDomain", &a.AccountDomain) + delete(rawMsg, key) + case "accountId": + err = unpopulate(val, "AccountID", &a.AccountID) + delete(rawMsg, key) + case "storageAccountName": + err = unpopulate(val, "StorageAccountName", &a.StorageAccountName) + 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 CheckNameAvailabilityRequest. +func (c CheckNameAvailabilityRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityRequest. +func (c *CheckNameAvailabilityRequest) 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 "name": + err = unpopulate(val, "Name", &c.Name) + 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 CheckNameAvailabilityResponse. +func (c CheckNameAvailabilityResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", c.Message) + populate(objectMap, "nameAvailable", c.NameAvailable) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityResponse. +func (c *CheckNameAvailabilityResponse) 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 "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &c.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) + 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 Identity. +func (i Identity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", i.PrincipalID) + populate(objectMap, "tenantId", i.TenantID) + objectMap["type"] = "SystemAssigned" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Identity. +func (i *Identity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &i.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &i.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LogSpecification. +func (l LogSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "blobDuration", l.BlobDuration) + populate(objectMap, "displayName", l.DisplayName) + populate(objectMap, "name", l.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogSpecification. +func (l *LogSpecification) 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 "blobDuration": + err = unpopulate(val, "BlobDuration", &l.BlobDuration) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &l.DisplayName) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + 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 MetricDimension. +func (m MetricDimension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", m.DisplayName) + populate(objectMap, "internalName", m.InternalName) + populate(objectMap, "name", m.Name) + populate(objectMap, "toBeExportedForShoebox", m.ToBeExportedForShoebox) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricDimension. +func (m *MetricDimension) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &m.DisplayName) + delete(rawMsg, key) + case "internalName": + err = unpopulate(val, "InternalName", &m.InternalName) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + case "toBeExportedForShoebox": + err = unpopulate(val, "ToBeExportedForShoebox", &m.ToBeExportedForShoebox) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MetricSpecification. +func (m MetricSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "aggregationType", m.AggregationType) + populate(objectMap, "category", m.Category) + populate(objectMap, "dimensions", m.Dimensions) + populate(objectMap, "displayDescription", m.DisplayDescription) + populate(objectMap, "displayName", m.DisplayName) + populate(objectMap, "enableRegionalMdmAccount", m.EnableRegionalMdmAccount) + populate(objectMap, "fillGapWithZero", m.FillGapWithZero) + populate(objectMap, "internalMetricName", m.InternalMetricName) + populate(objectMap, "lockedAggregationType", m.LockedAggregationType) + populate(objectMap, "metricFilterPattern", m.MetricFilterPattern) + populate(objectMap, "name", m.Name) + populate(objectMap, "sourceMdmAccount", m.SourceMdmAccount) + populate(objectMap, "sourceMdmNamespace", m.SourceMdmNamespace) + populate(objectMap, "supportedAggregationTypes", m.SupportedAggregationTypes) + populate(objectMap, "supportedTimeGrainTypes", m.SupportedTimeGrainTypes) + populate(objectMap, "unit", m.Unit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricSpecification. +func (m *MetricSpecification) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "aggregationType": + err = unpopulate(val, "AggregationType", &m.AggregationType) + delete(rawMsg, key) + case "category": + err = unpopulate(val, "Category", &m.Category) + delete(rawMsg, key) + case "dimensions": + err = unpopulate(val, "Dimensions", &m.Dimensions) + delete(rawMsg, key) + case "displayDescription": + err = unpopulate(val, "DisplayDescription", &m.DisplayDescription) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &m.DisplayName) + delete(rawMsg, key) + case "enableRegionalMdmAccount": + err = unpopulate(val, "EnableRegionalMdmAccount", &m.EnableRegionalMdmAccount) + delete(rawMsg, key) + case "fillGapWithZero": + err = unpopulate(val, "FillGapWithZero", &m.FillGapWithZero) + delete(rawMsg, key) + case "internalMetricName": + err = unpopulate(val, "InternalMetricName", &m.InternalMetricName) + delete(rawMsg, key) + case "lockedAggregationType": + err = unpopulate(val, "LockedAggregationType", &m.LockedAggregationType) + delete(rawMsg, key) + case "metricFilterPattern": + err = unpopulate(val, "MetricFilterPattern", &m.MetricFilterPattern) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + case "sourceMdmAccount": + err = unpopulate(val, "SourceMdmAccount", &m.SourceMdmAccount) + delete(rawMsg, key) + case "sourceMdmNamespace": + err = unpopulate(val, "SourceMdmNamespace", &m.SourceMdmNamespace) + delete(rawMsg, key) + case "supportedAggregationTypes": + err = unpopulate(val, "SupportedAggregationTypes", &m.SupportedAggregationTypes) + delete(rawMsg, key) + case "supportedTimeGrainTypes": + err = unpopulate(val, "SupportedTimeGrainTypes", &m.SupportedTimeGrainTypes) + delete(rawMsg, key) + case "unit": + err = unpopulate(val, "Unit", &m.Unit) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ObjectAnchorsAccount. +func (o ObjectAnchorsAccount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", o.ID) + populate(objectMap, "identity", o.Identity) + populate(objectMap, "kind", o.Kind) + populate(objectMap, "location", o.Location) + populate(objectMap, "name", o.Name) + populate(objectMap, "plan", o.Plan) + populate(objectMap, "properties", o.Properties) + populate(objectMap, "sku", o.SKU) + populate(objectMap, "systemData", o.SystemData) + populate(objectMap, "tags", o.Tags) + populate(objectMap, "type", o.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ObjectAnchorsAccount. +func (o *ObjectAnchorsAccount) 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 "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &o.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &o.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &o.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "plan": + err = unpopulate(val, "Plan", &o.Plan) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &o.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &o.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &o.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &o.Type) + 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 ObjectAnchorsAccountIdentity. +func (o ObjectAnchorsAccountIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", o.PrincipalID) + populate(objectMap, "tenantId", o.TenantID) + objectMap["type"] = "SystemAssigned" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ObjectAnchorsAccountIdentity. +func (o *ObjectAnchorsAccountIdentity) 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 "principalId": + err = unpopulate(val, "PrincipalID", &o.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &o.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &o.Type) + 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 ObjectAnchorsAccountPage. +func (o ObjectAnchorsAccountPage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ObjectAnchorsAccountPage. +func (o *ObjectAnchorsAccountPage) 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 Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + populate(objectMap, "properties", o.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "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) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "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 OperationPage. +func (o OperationPage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationPage. +func (o *OperationPage) 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 OperationProperties. +func (o OperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "serviceSpecification", o.ServiceSpecification) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationProperties. +func (o *OperationProperties) 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 "serviceSpecification": + err = unpopulate(val, "ServiceSpecification", &o.ServiceSpecification) + 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 RemoteRenderingAccount. +func (r RemoteRenderingAccount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "identity", r.Identity) + populate(objectMap, "kind", r.Kind) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "plan", r.Plan) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "sku", r.SKU) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RemoteRenderingAccount. +func (r *RemoteRenderingAccount) 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 "identity": + err = unpopulate(val, "Identity", &r.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &r.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "plan": + err = unpopulate(val, "Plan", &r.Plan) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &r.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + 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 RemoteRenderingAccountPage. +func (r RemoteRenderingAccountPage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RemoteRenderingAccountPage. +func (r *RemoteRenderingAccountPage) 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 "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + 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 Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 SKU. +func (s SKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacity", s.Capacity) + populate(objectMap, "family", s.Family) + populate(objectMap, "name", s.Name) + populate(objectMap, "size", s.Size) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKU. +func (s *SKU) 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 "capacity": + err = unpopulate(val, "Capacity", &s.Capacity) + delete(rawMsg, key) + case "family": + err = unpopulate(val, "Family", &s.Family) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "size": + err = unpopulate(val, "Size", &s.Size) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &s.Tier) + 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 ServiceSpecification. +func (s ServiceSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "logSpecifications", s.LogSpecifications) + populate(objectMap, "metricSpecifications", s.MetricSpecifications) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceSpecification. +func (s *ServiceSpecification) 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 "logSpecifications": + err = unpopulate(val, "LogSpecifications", &s.LogSpecifications) + delete(rawMsg, key) + case "metricSpecifications": + err = unpopulate(val, "MetricSpecifications", &s.MetricSpecifications) + 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 SpatialAnchorsAccount. +func (s SpatialAnchorsAccount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "kind", s.Kind) + populate(objectMap, "location", s.Location) + populate(objectMap, "name", s.Name) + populate(objectMap, "plan", s.Plan) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SpatialAnchorsAccount. +func (s *SpatialAnchorsAccount) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &s.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "plan": + err = unpopulate(val, "Plan", &s.Plan) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SpatialAnchorsAccountPage. +func (s SpatialAnchorsAccountPage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SpatialAnchorsAccountPage. +func (s *SpatialAnchorsAccountPage) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. +func (t *TrackedResource) 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 "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, 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 +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_objectanchorsaccounts_client.go b/sdk/resourcemanager/mixedreality/armmixedreality/objectanchorsaccounts_client.go similarity index 86% rename from sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_objectanchorsaccounts_client.go rename to sdk/resourcemanager/mixedreality/armmixedreality/objectanchorsaccounts_client.go index 6a648dc07132..d5b8ccb3392f 100644 --- a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_objectanchorsaccounts_client.go +++ b/sdk/resourcemanager/mixedreality/armmixedreality/objectanchorsaccounts_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 armmixedreality @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,49 +24,41 @@ import ( // ObjectAnchorsAccountsClient contains the methods for the ObjectAnchorsAccounts group. // Don't use this type directly, use NewObjectAnchorsAccountsClient() instead. type ObjectAnchorsAccountsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewObjectAnchorsAccountsClient creates a new instance of ObjectAnchorsAccountsClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewObjectAnchorsAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ObjectAnchorsAccountsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ObjectAnchorsAccountsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ObjectAnchorsAccountsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Creating or Updating an object anchors Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// objectAnchorsAccount - Object Anchors Account parameter. -// options - ObjectAnchorsAccountsClientCreateOptions contains the optional parameters for the ObjectAnchorsAccountsClient.Create -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - objectAnchorsAccount - Object Anchors Account parameter. +// - options - ObjectAnchorsAccountsClientCreateOptions contains the optional parameters for the ObjectAnchorsAccountsClient.Create +// method. func (client *ObjectAnchorsAccountsClient) Create(ctx context.Context, resourceGroupName string, accountName string, objectAnchorsAccount ObjectAnchorsAccount, options *ObjectAnchorsAccountsClientCreateOptions) (ObjectAnchorsAccountsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, objectAnchorsAccount, options) if err != nil { return ObjectAnchorsAccountsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ObjectAnchorsAccountsClientCreateResponse{}, err } @@ -92,7 +83,7 @@ func (client *ObjectAnchorsAccountsClient) createCreateRequest(ctx context.Conte return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -114,17 +105,18 @@ func (client *ObjectAnchorsAccountsClient) createHandleResponse(resp *http.Respo // Delete - Delete an Object Anchors Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// options - ObjectAnchorsAccountsClientDeleteOptions contains the optional parameters for the ObjectAnchorsAccountsClient.Delete -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - options - ObjectAnchorsAccountsClientDeleteOptions contains the optional parameters for the ObjectAnchorsAccountsClient.Delete +// method. func (client *ObjectAnchorsAccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, options *ObjectAnchorsAccountsClientDeleteOptions) (ObjectAnchorsAccountsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return ObjectAnchorsAccountsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ObjectAnchorsAccountsClientDeleteResponse{}, err } @@ -149,7 +141,7 @@ func (client *ObjectAnchorsAccountsClient) deleteCreateRequest(ctx context.Conte return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -162,17 +154,18 @@ func (client *ObjectAnchorsAccountsClient) deleteCreateRequest(ctx context.Conte // Get - Retrieve an Object Anchors Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// options - ObjectAnchorsAccountsClientGetOptions contains the optional parameters for the ObjectAnchorsAccountsClient.Get -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - options - ObjectAnchorsAccountsClientGetOptions contains the optional parameters for the ObjectAnchorsAccountsClient.Get +// method. func (client *ObjectAnchorsAccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string, options *ObjectAnchorsAccountsClientGetOptions) (ObjectAnchorsAccountsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return ObjectAnchorsAccountsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ObjectAnchorsAccountsClientGetResponse{}, err } @@ -197,7 +190,7 @@ func (client *ObjectAnchorsAccountsClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -218,11 +211,11 @@ func (client *ObjectAnchorsAccountsClient) getHandleResponse(resp *http.Response } // NewListByResourceGroupPager - List Resources by Resource Group -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// options - ObjectAnchorsAccountsClientListByResourceGroupOptions contains the optional parameters for the ObjectAnchorsAccountsClient.ListByResourceGroup -// method. +// - resourceGroupName - Name of an Azure resource group. +// - options - ObjectAnchorsAccountsClientListByResourceGroupOptions contains the optional parameters for the ObjectAnchorsAccountsClient.NewListByResourceGroupPager +// method. func (client *ObjectAnchorsAccountsClient) NewListByResourceGroupPager(resourceGroupName string, options *ObjectAnchorsAccountsClientListByResourceGroupOptions) *runtime.Pager[ObjectAnchorsAccountsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[ObjectAnchorsAccountsClientListByResourceGroupResponse]{ More: func(page ObjectAnchorsAccountsClientListByResourceGroupResponse) bool { @@ -239,7 +232,7 @@ func (client *ObjectAnchorsAccountsClient) NewListByResourceGroupPager(resourceG if err != nil { return ObjectAnchorsAccountsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ObjectAnchorsAccountsClientListByResourceGroupResponse{}, err } @@ -262,7 +255,7 @@ func (client *ObjectAnchorsAccountsClient) listByResourceGroupCreateRequest(ctx return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -283,10 +276,10 @@ func (client *ObjectAnchorsAccountsClient) listByResourceGroupHandleResponse(res } // NewListBySubscriptionPager - List Object Anchors Accounts by Subscription -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// options - ObjectAnchorsAccountsClientListBySubscriptionOptions contains the optional parameters for the ObjectAnchorsAccountsClient.ListBySubscription -// method. +// - options - ObjectAnchorsAccountsClientListBySubscriptionOptions contains the optional parameters for the ObjectAnchorsAccountsClient.NewListBySubscriptionPager +// method. func (client *ObjectAnchorsAccountsClient) NewListBySubscriptionPager(options *ObjectAnchorsAccountsClientListBySubscriptionOptions) *runtime.Pager[ObjectAnchorsAccountsClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[ObjectAnchorsAccountsClientListBySubscriptionResponse]{ More: func(page ObjectAnchorsAccountsClientListBySubscriptionResponse) bool { @@ -303,7 +296,7 @@ func (client *ObjectAnchorsAccountsClient) NewListBySubscriptionPager(options *O if err != nil { return ObjectAnchorsAccountsClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ObjectAnchorsAccountsClientListBySubscriptionResponse{}, err } @@ -322,7 +315,7 @@ func (client *ObjectAnchorsAccountsClient) listBySubscriptionCreateRequest(ctx c return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -344,17 +337,18 @@ func (client *ObjectAnchorsAccountsClient) listBySubscriptionHandleResponse(resp // ListKeys - List Both of the 2 Keys of an object anchors Account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// options - ObjectAnchorsAccountsClientListKeysOptions contains the optional parameters for the ObjectAnchorsAccountsClient.ListKeys -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - options - ObjectAnchorsAccountsClientListKeysOptions contains the optional parameters for the ObjectAnchorsAccountsClient.ListKeys +// method. func (client *ObjectAnchorsAccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string, options *ObjectAnchorsAccountsClientListKeysOptions) (ObjectAnchorsAccountsClientListKeysResponse, error) { req, err := client.listKeysCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return ObjectAnchorsAccountsClientListKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ObjectAnchorsAccountsClientListKeysResponse{}, err } @@ -379,7 +373,7 @@ func (client *ObjectAnchorsAccountsClient) listKeysCreateRequest(ctx context.Con return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -401,18 +395,19 @@ func (client *ObjectAnchorsAccountsClient) listKeysHandleResponse(resp *http.Res // RegenerateKeys - Regenerate specified Key of an object anchors Account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// regenerate - Required information for key regeneration. -// options - ObjectAnchorsAccountsClientRegenerateKeysOptions contains the optional parameters for the ObjectAnchorsAccountsClient.RegenerateKeys -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - regenerate - Required information for key regeneration. +// - options - ObjectAnchorsAccountsClientRegenerateKeysOptions contains the optional parameters for the ObjectAnchorsAccountsClient.RegenerateKeys +// method. func (client *ObjectAnchorsAccountsClient) RegenerateKeys(ctx context.Context, resourceGroupName string, accountName string, regenerate AccountKeyRegenerateRequest, options *ObjectAnchorsAccountsClientRegenerateKeysOptions) (ObjectAnchorsAccountsClientRegenerateKeysResponse, error) { req, err := client.regenerateKeysCreateRequest(ctx, resourceGroupName, accountName, regenerate, options) if err != nil { return ObjectAnchorsAccountsClientRegenerateKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ObjectAnchorsAccountsClientRegenerateKeysResponse{}, err } @@ -437,7 +432,7 @@ func (client *ObjectAnchorsAccountsClient) regenerateKeysCreateRequest(ctx conte return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -459,18 +454,19 @@ func (client *ObjectAnchorsAccountsClient) regenerateKeysHandleResponse(resp *ht // Update - Updating an Object Anchors Account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// objectAnchorsAccount - Object Anchors Account parameter. -// options - ObjectAnchorsAccountsClientUpdateOptions contains the optional parameters for the ObjectAnchorsAccountsClient.Update -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - objectAnchorsAccount - Object Anchors Account parameter. +// - options - ObjectAnchorsAccountsClientUpdateOptions contains the optional parameters for the ObjectAnchorsAccountsClient.Update +// method. func (client *ObjectAnchorsAccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, objectAnchorsAccount ObjectAnchorsAccount, options *ObjectAnchorsAccountsClientUpdateOptions) (ObjectAnchorsAccountsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, objectAnchorsAccount, options) if err != nil { return ObjectAnchorsAccountsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ObjectAnchorsAccountsClientUpdateResponse{}, err } @@ -495,7 +491,7 @@ func (client *ObjectAnchorsAccountsClient) updateCreateRequest(ctx context.Conte return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/objectanchorsaccounts_client_example_test.go b/sdk/resourcemanager/mixedreality/armmixedreality/objectanchorsaccounts_client_example_test.go new file mode 100644 index 000000000000..edd4883b3e9b --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/objectanchorsaccounts_client_example_test.go @@ -0,0 +1,323 @@ +//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 armmixedreality_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/mixedreality/armmixedreality" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/GetBySubscription.json +func ExampleObjectAnchorsAccountsClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewObjectAnchorsAccountsClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ObjectAnchorsAccountPage = armmixedreality.ObjectAnchorsAccountPage{ + // Value: []*armmixedreality.ObjectAnchorsAccount{ + // { + // Name: to.Ptr("alpha"), + // Type: to.Ptr("Microsoft.MixedReality/objectAnchorsAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/objectAnchorsAccounts/alpha"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Identity: &armmixedreality.ObjectAnchorsAccountIdentity{ + // Type: to.Ptr("SystemAssigned"), + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // }, + // { + // Name: to.Ptr("omega"), + // Type: to.Ptr("Microsoft.MixedReality/objectAnchorsAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/objectAnchorsAccounts/omega"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Identity: &armmixedreality.ObjectAnchorsAccountIdentity{ + // Type: to.Ptr("SystemAssigned"), + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/GetByResourceGroup.json +func ExampleObjectAnchorsAccountsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewObjectAnchorsAccountsClient().NewListByResourceGroupPager("MyResourceGroup", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ObjectAnchorsAccountPage = armmixedreality.ObjectAnchorsAccountPage{ + // Value: []*armmixedreality.ObjectAnchorsAccount{ + // { + // Name: to.Ptr("alpha"), + // Type: to.Ptr("Microsoft.MixedReality/objectAnchorsAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/objectAnchorsAccounts/alpha"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Identity: &armmixedreality.ObjectAnchorsAccountIdentity{ + // Type: to.Ptr("SystemAssigned"), + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // }, + // { + // Name: to.Ptr("omega"), + // Type: to.Ptr("Microsoft.MixedReality/objectAnchorsAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/objectAnchorsAccounts/omega"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Identity: &armmixedreality.ObjectAnchorsAccountIdentity{ + // Type: to.Ptr("SystemAssigned"), + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/Delete.json +func ExampleObjectAnchorsAccountsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewObjectAnchorsAccountsClient().Delete(ctx, "MyResourceGroup", "MyAccount", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/Get.json +func ExampleObjectAnchorsAccountsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewObjectAnchorsAccountsClient().Get(ctx, "MyResourceGroup", "MyAccount", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ObjectAnchorsAccount = armmixedreality.ObjectAnchorsAccount{ + // Name: to.Ptr("MyAccount"), + // Type: to.Ptr("Microsoft.MixedReality/objectAnchorsAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/objectAnchorsAccounts/MyAccount"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Identity: &armmixedreality.ObjectAnchorsAccountIdentity{ + // Type: to.Ptr("SystemAssigned"), + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/Patch.json +func ExampleObjectAnchorsAccountsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewObjectAnchorsAccountsClient().Update(ctx, "MyResourceGroup", "MyAccount", armmixedreality.ObjectAnchorsAccount{ + Location: to.Ptr("eastus2euap"), + Tags: map[string]*string{ + "hero": to.Ptr("romeo"), + "heroine": to.Ptr("juliet"), + }, + Identity: &armmixedreality.ObjectAnchorsAccountIdentity{ + Type: to.Ptr("SystemAssigned"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ObjectAnchorsAccount = armmixedreality.ObjectAnchorsAccount{ + // Name: to.Ptr("MyAccount"), + // Type: to.Ptr("Microsoft.MixedReality/objectAnchorsAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/objectAnchorsAccounts/MyAccount"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // "hero": to.Ptr("romeo"), + // "heroine": to.Ptr("juliet"), + // }, + // Identity: &armmixedreality.ObjectAnchorsAccountIdentity{ + // Type: to.Ptr("SystemAssigned"), + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/Put.json +func ExampleObjectAnchorsAccountsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewObjectAnchorsAccountsClient().Create(ctx, "MyResourceGroup", "MyAccount", armmixedreality.ObjectAnchorsAccount{ + Location: to.Ptr("eastus2euap"), + Identity: &armmixedreality.ObjectAnchorsAccountIdentity{ + Type: to.Ptr("SystemAssigned"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ObjectAnchorsAccount = armmixedreality.ObjectAnchorsAccount{ + // Name: to.Ptr("MyAccount"), + // Type: to.Ptr("Microsoft.MixedReality/objectAnchorsAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/objectAnchorsAccounts/MyAccount"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Identity: &armmixedreality.ObjectAnchorsAccountIdentity{ + // Type: to.Ptr("SystemAssigned"), + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/ListKeys.json +func ExampleObjectAnchorsAccountsClient_ListKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewObjectAnchorsAccountsClient().ListKeys(ctx, "MyResourceGroup", "MyAccount", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccountKeys = armmixedreality.AccountKeys{ + // PrimaryKey: to.Ptr("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), + // SecondaryKey: to.Ptr("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/RegenerateKey.json +func ExampleObjectAnchorsAccountsClient_RegenerateKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewObjectAnchorsAccountsClient().RegenerateKeys(ctx, "MyResourceGroup", "MyAccount", armmixedreality.AccountKeyRegenerateRequest{ + Serial: to.Ptr(armmixedreality.SerialPrimary), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccountKeys = armmixedreality.AccountKeys{ + // PrimaryKey: to.Ptr("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), + // SecondaryKey: to.Ptr("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), + // } +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_operations_client.go b/sdk/resourcemanager/mixedreality/armmixedreality/operations_client.go similarity index 77% rename from sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_operations_client.go rename to sdk/resourcemanager/mixedreality/armmixedreality/operations_client.go index bb5822d35a59..639f18ced5a4 100644 --- a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_operations_client.go +++ b/sdk/resourcemanager/mixedreality/armmixedreality/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 armmixedreality @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,36 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Exposing Available Operations -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -68,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -83,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.MixedReality/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/operations_client_example_test.go b/sdk/resourcemanager/mixedreality/armmixedreality/operations_client_example_test.go new file mode 100644 index 000000000000..fd2bd133b554 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/operations_client_example_test.go @@ -0,0 +1,82 @@ +//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 armmixedreality_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mixedreality/armmixedreality" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/proxy/ExposingAvailableOperations.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationPage = armmixedreality.OperationPage{ + // Value: []*armmixedreality.Operation{ + // { + // Name: to.Ptr("Microsoft.MixedReality/register/action"), + // Display: &armmixedreality.OperationDisplay{ + // Description: to.Ptr("Registers a subscription for the Mixed Reality resource provider."), + // Operation: to.Ptr("Registers the Mixed Reality resource provider"), + // Provider: to.Ptr("Microsoft.MixedReality"), + // Resource: to.Ptr("Mixed Reality resource provider"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.MixedReality/SpatialAnchorsAccounts/delete"), + // Display: &armmixedreality.OperationDisplay{ + // Description: to.Ptr("Deletes the resource for Microsoft.MixedReality/SpatialAnchorsAccounts"), + // Operation: to.Ptr("Delete Spatial Anchors Accounts"), + // Provider: to.Ptr("Microsoft.MixedReality"), + // Resource: to.Ptr("SpatialAnchorsAccounts"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.MixedReality/SpatialAnchorsAccounts/read"), + // Display: &armmixedreality.OperationDisplay{ + // Description: to.Ptr("Gets the resource for Microsoft.MixedReality/SpatialAnchorsAccounts"), + // Operation: to.Ptr("Get Spatial Anchors Accounts"), + // Provider: to.Ptr("Microsoft.MixedReality"), + // Resource: to.Ptr("SpatialAnchorsAccounts"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.MixedReality/SpatialAnchorsAccounts/write"), + // Display: &armmixedreality.OperationDisplay{ + // Description: to.Ptr("Updates the resource for Microsoft.MixedReality/SpatialAnchorsAccounts"), + // Operation: to.Ptr("Update Spatial Anchors Accounts"), + // Provider: to.Ptr("Microsoft.MixedReality"), + // Resource: to.Ptr("SpatialAnchorsAccounts"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_remoterenderingaccounts_client.go b/sdk/resourcemanager/mixedreality/armmixedreality/remoterenderingaccounts_client.go similarity index 86% rename from sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_remoterenderingaccounts_client.go rename to sdk/resourcemanager/mixedreality/armmixedreality/remoterenderingaccounts_client.go index de68c2021f0e..1db0af4c8b6b 100644 --- a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_remoterenderingaccounts_client.go +++ b/sdk/resourcemanager/mixedreality/armmixedreality/remoterenderingaccounts_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 armmixedreality @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,49 +24,41 @@ import ( // RemoteRenderingAccountsClient contains the methods for the RemoteRenderingAccounts group. // Don't use this type directly, use NewRemoteRenderingAccountsClient() instead. type RemoteRenderingAccountsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewRemoteRenderingAccountsClient creates a new instance of RemoteRenderingAccountsClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewRemoteRenderingAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RemoteRenderingAccountsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".RemoteRenderingAccountsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &RemoteRenderingAccountsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Creating or Updating a Remote Rendering Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// remoteRenderingAccount - Remote Rendering Account parameter. -// options - RemoteRenderingAccountsClientCreateOptions contains the optional parameters for the RemoteRenderingAccountsClient.Create -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - remoteRenderingAccount - Remote Rendering Account parameter. +// - options - RemoteRenderingAccountsClientCreateOptions contains the optional parameters for the RemoteRenderingAccountsClient.Create +// method. func (client *RemoteRenderingAccountsClient) Create(ctx context.Context, resourceGroupName string, accountName string, remoteRenderingAccount RemoteRenderingAccount, options *RemoteRenderingAccountsClientCreateOptions) (RemoteRenderingAccountsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, remoteRenderingAccount, options) if err != nil { return RemoteRenderingAccountsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RemoteRenderingAccountsClientCreateResponse{}, err } @@ -92,7 +83,7 @@ func (client *RemoteRenderingAccountsClient) createCreateRequest(ctx context.Con return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -114,17 +105,18 @@ func (client *RemoteRenderingAccountsClient) createHandleResponse(resp *http.Res // Delete - Delete a Remote Rendering Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// options - RemoteRenderingAccountsClientDeleteOptions contains the optional parameters for the RemoteRenderingAccountsClient.Delete -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - options - RemoteRenderingAccountsClientDeleteOptions contains the optional parameters for the RemoteRenderingAccountsClient.Delete +// method. func (client *RemoteRenderingAccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, options *RemoteRenderingAccountsClientDeleteOptions) (RemoteRenderingAccountsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return RemoteRenderingAccountsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RemoteRenderingAccountsClientDeleteResponse{}, err } @@ -149,7 +141,7 @@ func (client *RemoteRenderingAccountsClient) deleteCreateRequest(ctx context.Con return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -162,17 +154,18 @@ func (client *RemoteRenderingAccountsClient) deleteCreateRequest(ctx context.Con // Get - Retrieve a Remote Rendering Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// options - RemoteRenderingAccountsClientGetOptions contains the optional parameters for the RemoteRenderingAccountsClient.Get -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - options - RemoteRenderingAccountsClientGetOptions contains the optional parameters for the RemoteRenderingAccountsClient.Get +// method. func (client *RemoteRenderingAccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string, options *RemoteRenderingAccountsClientGetOptions) (RemoteRenderingAccountsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return RemoteRenderingAccountsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RemoteRenderingAccountsClientGetResponse{}, err } @@ -197,7 +190,7 @@ func (client *RemoteRenderingAccountsClient) getCreateRequest(ctx context.Contex return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -218,11 +211,11 @@ func (client *RemoteRenderingAccountsClient) getHandleResponse(resp *http.Respon } // NewListByResourceGroupPager - List Resources by Resource Group -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// options - RemoteRenderingAccountsClientListByResourceGroupOptions contains the optional parameters for the RemoteRenderingAccountsClient.ListByResourceGroup -// method. +// - resourceGroupName - Name of an Azure resource group. +// - options - RemoteRenderingAccountsClientListByResourceGroupOptions contains the optional parameters for the RemoteRenderingAccountsClient.NewListByResourceGroupPager +// method. func (client *RemoteRenderingAccountsClient) NewListByResourceGroupPager(resourceGroupName string, options *RemoteRenderingAccountsClientListByResourceGroupOptions) *runtime.Pager[RemoteRenderingAccountsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[RemoteRenderingAccountsClientListByResourceGroupResponse]{ More: func(page RemoteRenderingAccountsClientListByResourceGroupResponse) bool { @@ -239,7 +232,7 @@ func (client *RemoteRenderingAccountsClient) NewListByResourceGroupPager(resourc if err != nil { return RemoteRenderingAccountsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RemoteRenderingAccountsClientListByResourceGroupResponse{}, err } @@ -262,7 +255,7 @@ func (client *RemoteRenderingAccountsClient) listByResourceGroupCreateRequest(ct return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -283,10 +276,10 @@ func (client *RemoteRenderingAccountsClient) listByResourceGroupHandleResponse(r } // NewListBySubscriptionPager - List Remote Rendering Accounts by Subscription -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// options - RemoteRenderingAccountsClientListBySubscriptionOptions contains the optional parameters for the RemoteRenderingAccountsClient.ListBySubscription -// method. +// - options - RemoteRenderingAccountsClientListBySubscriptionOptions contains the optional parameters for the RemoteRenderingAccountsClient.NewListBySubscriptionPager +// method. func (client *RemoteRenderingAccountsClient) NewListBySubscriptionPager(options *RemoteRenderingAccountsClientListBySubscriptionOptions) *runtime.Pager[RemoteRenderingAccountsClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[RemoteRenderingAccountsClientListBySubscriptionResponse]{ More: func(page RemoteRenderingAccountsClientListBySubscriptionResponse) bool { @@ -303,7 +296,7 @@ func (client *RemoteRenderingAccountsClient) NewListBySubscriptionPager(options if err != nil { return RemoteRenderingAccountsClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RemoteRenderingAccountsClientListBySubscriptionResponse{}, err } @@ -322,7 +315,7 @@ func (client *RemoteRenderingAccountsClient) listBySubscriptionCreateRequest(ctx return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -344,17 +337,18 @@ func (client *RemoteRenderingAccountsClient) listBySubscriptionHandleResponse(re // ListKeys - List Both of the 2 Keys of a Remote Rendering Account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// options - RemoteRenderingAccountsClientListKeysOptions contains the optional parameters for the RemoteRenderingAccountsClient.ListKeys -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - options - RemoteRenderingAccountsClientListKeysOptions contains the optional parameters for the RemoteRenderingAccountsClient.ListKeys +// method. func (client *RemoteRenderingAccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string, options *RemoteRenderingAccountsClientListKeysOptions) (RemoteRenderingAccountsClientListKeysResponse, error) { req, err := client.listKeysCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return RemoteRenderingAccountsClientListKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RemoteRenderingAccountsClientListKeysResponse{}, err } @@ -379,7 +373,7 @@ func (client *RemoteRenderingAccountsClient) listKeysCreateRequest(ctx context.C return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -401,18 +395,19 @@ func (client *RemoteRenderingAccountsClient) listKeysHandleResponse(resp *http.R // RegenerateKeys - Regenerate specified Key of a Remote Rendering Account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// regenerate - Required information for key regeneration. -// options - RemoteRenderingAccountsClientRegenerateKeysOptions contains the optional parameters for the RemoteRenderingAccountsClient.RegenerateKeys -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - regenerate - Required information for key regeneration. +// - options - RemoteRenderingAccountsClientRegenerateKeysOptions contains the optional parameters for the RemoteRenderingAccountsClient.RegenerateKeys +// method. func (client *RemoteRenderingAccountsClient) RegenerateKeys(ctx context.Context, resourceGroupName string, accountName string, regenerate AccountKeyRegenerateRequest, options *RemoteRenderingAccountsClientRegenerateKeysOptions) (RemoteRenderingAccountsClientRegenerateKeysResponse, error) { req, err := client.regenerateKeysCreateRequest(ctx, resourceGroupName, accountName, regenerate, options) if err != nil { return RemoteRenderingAccountsClientRegenerateKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RemoteRenderingAccountsClientRegenerateKeysResponse{}, err } @@ -437,7 +432,7 @@ func (client *RemoteRenderingAccountsClient) regenerateKeysCreateRequest(ctx con return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -459,18 +454,19 @@ func (client *RemoteRenderingAccountsClient) regenerateKeysHandleResponse(resp * // Update - Updating a Remote Rendering Account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// remoteRenderingAccount - Remote Rendering Account parameter. -// options - RemoteRenderingAccountsClientUpdateOptions contains the optional parameters for the RemoteRenderingAccountsClient.Update -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - remoteRenderingAccount - Remote Rendering Account parameter. +// - options - RemoteRenderingAccountsClientUpdateOptions contains the optional parameters for the RemoteRenderingAccountsClient.Update +// method. func (client *RemoteRenderingAccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, remoteRenderingAccount RemoteRenderingAccount, options *RemoteRenderingAccountsClientUpdateOptions) (RemoteRenderingAccountsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, remoteRenderingAccount, options) if err != nil { return RemoteRenderingAccountsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RemoteRenderingAccountsClientUpdateResponse{}, err } @@ -495,7 +491,7 @@ func (client *RemoteRenderingAccountsClient) updateCreateRequest(ctx context.Con return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/remoterenderingaccounts_client_example_test.go b/sdk/resourcemanager/mixedreality/armmixedreality/remoterenderingaccounts_client_example_test.go new file mode 100644 index 000000000000..44573c1b4a25 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/remoterenderingaccounts_client_example_test.go @@ -0,0 +1,323 @@ +//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 armmixedreality_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/mixedreality/armmixedreality" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/GetBySubscription.json +func ExampleRemoteRenderingAccountsClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRemoteRenderingAccountsClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RemoteRenderingAccountPage = armmixedreality.RemoteRenderingAccountPage{ + // Value: []*armmixedreality.RemoteRenderingAccount{ + // { + // Name: to.Ptr("alpha"), + // Type: to.Ptr("Microsoft.MixedReality/remoteRenderingAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/remoteRenderingAccounts/alpha"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Identity: &armmixedreality.Identity{ + // Type: to.Ptr("SystemAssigned"), + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // }, + // { + // Name: to.Ptr("omega"), + // Type: to.Ptr("Microsoft.MixedReality/remoteRenderingAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/remoteRenderingAccounts/omega"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Identity: &armmixedreality.Identity{ + // Type: to.Ptr("SystemAssigned"), + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/GetByResourceGroup.json +func ExampleRemoteRenderingAccountsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRemoteRenderingAccountsClient().NewListByResourceGroupPager("MyResourceGroup", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RemoteRenderingAccountPage = armmixedreality.RemoteRenderingAccountPage{ + // Value: []*armmixedreality.RemoteRenderingAccount{ + // { + // Name: to.Ptr("alpha"), + // Type: to.Ptr("Microsoft.MixedReality/remoteRenderingAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/remoteRenderingAccounts/alpha"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Identity: &armmixedreality.Identity{ + // Type: to.Ptr("SystemAssigned"), + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // }, + // { + // Name: to.Ptr("omega"), + // Type: to.Ptr("Microsoft.MixedReality/remoteRenderingAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/remoteRenderingAccounts/omega"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Identity: &armmixedreality.Identity{ + // Type: to.Ptr("SystemAssigned"), + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/Delete.json +func ExampleRemoteRenderingAccountsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewRemoteRenderingAccountsClient().Delete(ctx, "MyResourceGroup", "MyAccount", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/Get.json +func ExampleRemoteRenderingAccountsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRemoteRenderingAccountsClient().Get(ctx, "MyResourceGroup", "MyAccount", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RemoteRenderingAccount = armmixedreality.RemoteRenderingAccount{ + // Name: to.Ptr("MyAccount"), + // Type: to.Ptr("Microsoft.MixedReality/remoteRenderingAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/remoteRenderingAccounts/MyAccount"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Identity: &armmixedreality.Identity{ + // Type: to.Ptr("SystemAssigned"), + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/Patch.json +func ExampleRemoteRenderingAccountsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRemoteRenderingAccountsClient().Update(ctx, "MyResourceGroup", "MyAccount", armmixedreality.RemoteRenderingAccount{ + Location: to.Ptr("eastus2euap"), + Tags: map[string]*string{ + "hero": to.Ptr("romeo"), + "heroine": to.Ptr("juliet"), + }, + Identity: &armmixedreality.Identity{ + Type: to.Ptr("SystemAssigned"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RemoteRenderingAccount = armmixedreality.RemoteRenderingAccount{ + // Name: to.Ptr("MyAccount"), + // Type: to.Ptr("Microsoft.MixedReality/remoteRenderingAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/remoteRenderingAccounts/MyAccount"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // "hero": to.Ptr("romeo"), + // "heroine": to.Ptr("juliet"), + // }, + // Identity: &armmixedreality.Identity{ + // Type: to.Ptr("SystemAssigned"), + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/Put.json +func ExampleRemoteRenderingAccountsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRemoteRenderingAccountsClient().Create(ctx, "MyResourceGroup", "MyAccount", armmixedreality.RemoteRenderingAccount{ + Location: to.Ptr("eastus2euap"), + Identity: &armmixedreality.Identity{ + Type: to.Ptr("SystemAssigned"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RemoteRenderingAccount = armmixedreality.RemoteRenderingAccount{ + // Name: to.Ptr("MyAccount"), + // Type: to.Ptr("Microsoft.MixedReality/remoteRenderingAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/remoteRenderingAccounts/MyAccount"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Identity: &armmixedreality.Identity{ + // Type: to.Ptr("SystemAssigned"), + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/ListKeys.json +func ExampleRemoteRenderingAccountsClient_ListKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRemoteRenderingAccountsClient().ListKeys(ctx, "MyResourceGroup", "MyAccount", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccountKeys = armmixedreality.AccountKeys{ + // PrimaryKey: to.Ptr(""), + // SecondaryKey: to.Ptr(""), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/RegenerateKey.json +func ExampleRemoteRenderingAccountsClient_RegenerateKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRemoteRenderingAccountsClient().RegenerateKeys(ctx, "MyResourceGroup", "MyAccount", armmixedreality.AccountKeyRegenerateRequest{ + Serial: to.Ptr(armmixedreality.SerialPrimary), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccountKeys = armmixedreality.AccountKeys{ + // PrimaryKey: to.Ptr("************"), + // SecondaryKey: to.Ptr("************"), + // } +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_response_types.go b/sdk/resourcemanager/mixedreality/armmixedreality/response_types.go similarity index 90% rename from sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_response_types.go rename to sdk/resourcemanager/mixedreality/armmixedreality/response_types.go index 5ed99011ac4e..2c44afdb99f7 100644 --- a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_response_types.go +++ b/sdk/resourcemanager/mixedreality/armmixedreality/response_types.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armmixedreality @@ -28,12 +29,12 @@ type ObjectAnchorsAccountsClientGetResponse struct { ObjectAnchorsAccount } -// ObjectAnchorsAccountsClientListByResourceGroupResponse contains the response from method ObjectAnchorsAccountsClient.ListByResourceGroup. +// ObjectAnchorsAccountsClientListByResourceGroupResponse contains the response from method ObjectAnchorsAccountsClient.NewListByResourceGroupPager. type ObjectAnchorsAccountsClientListByResourceGroupResponse struct { ObjectAnchorsAccountPage } -// ObjectAnchorsAccountsClientListBySubscriptionResponse contains the response from method ObjectAnchorsAccountsClient.ListBySubscription. +// ObjectAnchorsAccountsClientListBySubscriptionResponse contains the response from method ObjectAnchorsAccountsClient.NewListBySubscriptionPager. type ObjectAnchorsAccountsClientListBySubscriptionResponse struct { ObjectAnchorsAccountPage } @@ -53,7 +54,7 @@ type ObjectAnchorsAccountsClientUpdateResponse struct { ObjectAnchorsAccount } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationPage } @@ -73,12 +74,12 @@ type RemoteRenderingAccountsClientGetResponse struct { RemoteRenderingAccount } -// RemoteRenderingAccountsClientListByResourceGroupResponse contains the response from method RemoteRenderingAccountsClient.ListByResourceGroup. +// RemoteRenderingAccountsClientListByResourceGroupResponse contains the response from method RemoteRenderingAccountsClient.NewListByResourceGroupPager. type RemoteRenderingAccountsClientListByResourceGroupResponse struct { RemoteRenderingAccountPage } -// RemoteRenderingAccountsClientListBySubscriptionResponse contains the response from method RemoteRenderingAccountsClient.ListBySubscription. +// RemoteRenderingAccountsClientListBySubscriptionResponse contains the response from method RemoteRenderingAccountsClient.NewListBySubscriptionPager. type RemoteRenderingAccountsClientListBySubscriptionResponse struct { RemoteRenderingAccountPage } @@ -113,12 +114,12 @@ type SpatialAnchorsAccountsClientGetResponse struct { SpatialAnchorsAccount } -// SpatialAnchorsAccountsClientListByResourceGroupResponse contains the response from method SpatialAnchorsAccountsClient.ListByResourceGroup. +// SpatialAnchorsAccountsClientListByResourceGroupResponse contains the response from method SpatialAnchorsAccountsClient.NewListByResourceGroupPager. type SpatialAnchorsAccountsClientListByResourceGroupResponse struct { SpatialAnchorsAccountPage } -// SpatialAnchorsAccountsClientListBySubscriptionResponse contains the response from method SpatialAnchorsAccountsClient.ListBySubscription. +// SpatialAnchorsAccountsClientListBySubscriptionResponse contains the response from method SpatialAnchorsAccountsClient.NewListBySubscriptionPager. type SpatialAnchorsAccountsClientListBySubscriptionResponse struct { SpatialAnchorsAccountPage } diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_spatialanchorsaccounts_client.go b/sdk/resourcemanager/mixedreality/armmixedreality/spatialanchorsaccounts_client.go similarity index 86% rename from sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_spatialanchorsaccounts_client.go rename to sdk/resourcemanager/mixedreality/armmixedreality/spatialanchorsaccounts_client.go index d902c9f1a4e9..5503dee13db8 100644 --- a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_spatialanchorsaccounts_client.go +++ b/sdk/resourcemanager/mixedreality/armmixedreality/spatialanchorsaccounts_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 armmixedreality @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,49 +24,41 @@ import ( // SpatialAnchorsAccountsClient contains the methods for the SpatialAnchorsAccounts group. // Don't use this type directly, use NewSpatialAnchorsAccountsClient() instead. type SpatialAnchorsAccountsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSpatialAnchorsAccountsClient creates a new instance of SpatialAnchorsAccountsClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSpatialAnchorsAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SpatialAnchorsAccountsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SpatialAnchorsAccountsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SpatialAnchorsAccountsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Creating or Updating a Spatial Anchors Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// spatialAnchorsAccount - Spatial Anchors Account parameter. -// options - SpatialAnchorsAccountsClientCreateOptions contains the optional parameters for the SpatialAnchorsAccountsClient.Create -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - spatialAnchorsAccount - Spatial Anchors Account parameter. +// - options - SpatialAnchorsAccountsClientCreateOptions contains the optional parameters for the SpatialAnchorsAccountsClient.Create +// method. func (client *SpatialAnchorsAccountsClient) Create(ctx context.Context, resourceGroupName string, accountName string, spatialAnchorsAccount SpatialAnchorsAccount, options *SpatialAnchorsAccountsClientCreateOptions) (SpatialAnchorsAccountsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, spatialAnchorsAccount, options) if err != nil { return SpatialAnchorsAccountsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SpatialAnchorsAccountsClientCreateResponse{}, err } @@ -92,7 +83,7 @@ func (client *SpatialAnchorsAccountsClient) createCreateRequest(ctx context.Cont return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -114,17 +105,18 @@ func (client *SpatialAnchorsAccountsClient) createHandleResponse(resp *http.Resp // Delete - Delete a Spatial Anchors Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// options - SpatialAnchorsAccountsClientDeleteOptions contains the optional parameters for the SpatialAnchorsAccountsClient.Delete -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - options - SpatialAnchorsAccountsClientDeleteOptions contains the optional parameters for the SpatialAnchorsAccountsClient.Delete +// method. func (client *SpatialAnchorsAccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, options *SpatialAnchorsAccountsClientDeleteOptions) (SpatialAnchorsAccountsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return SpatialAnchorsAccountsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SpatialAnchorsAccountsClientDeleteResponse{}, err } @@ -149,7 +141,7 @@ func (client *SpatialAnchorsAccountsClient) deleteCreateRequest(ctx context.Cont return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -162,17 +154,18 @@ func (client *SpatialAnchorsAccountsClient) deleteCreateRequest(ctx context.Cont // Get - Retrieve a Spatial Anchors Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// options - SpatialAnchorsAccountsClientGetOptions contains the optional parameters for the SpatialAnchorsAccountsClient.Get -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - options - SpatialAnchorsAccountsClientGetOptions contains the optional parameters for the SpatialAnchorsAccountsClient.Get +// method. func (client *SpatialAnchorsAccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string, options *SpatialAnchorsAccountsClientGetOptions) (SpatialAnchorsAccountsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return SpatialAnchorsAccountsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SpatialAnchorsAccountsClientGetResponse{}, err } @@ -197,7 +190,7 @@ func (client *SpatialAnchorsAccountsClient) getCreateRequest(ctx context.Context return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -218,11 +211,11 @@ func (client *SpatialAnchorsAccountsClient) getHandleResponse(resp *http.Respons } // NewListByResourceGroupPager - List Resources by Resource Group -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// options - SpatialAnchorsAccountsClientListByResourceGroupOptions contains the optional parameters for the SpatialAnchorsAccountsClient.ListByResourceGroup -// method. +// - resourceGroupName - Name of an Azure resource group. +// - options - SpatialAnchorsAccountsClientListByResourceGroupOptions contains the optional parameters for the SpatialAnchorsAccountsClient.NewListByResourceGroupPager +// method. func (client *SpatialAnchorsAccountsClient) NewListByResourceGroupPager(resourceGroupName string, options *SpatialAnchorsAccountsClientListByResourceGroupOptions) *runtime.Pager[SpatialAnchorsAccountsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[SpatialAnchorsAccountsClientListByResourceGroupResponse]{ More: func(page SpatialAnchorsAccountsClientListByResourceGroupResponse) bool { @@ -239,7 +232,7 @@ func (client *SpatialAnchorsAccountsClient) NewListByResourceGroupPager(resource if err != nil { return SpatialAnchorsAccountsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SpatialAnchorsAccountsClientListByResourceGroupResponse{}, err } @@ -262,7 +255,7 @@ func (client *SpatialAnchorsAccountsClient) listByResourceGroupCreateRequest(ctx return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -283,10 +276,10 @@ func (client *SpatialAnchorsAccountsClient) listByResourceGroupHandleResponse(re } // NewListBySubscriptionPager - List Spatial Anchors Accounts by Subscription -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// options - SpatialAnchorsAccountsClientListBySubscriptionOptions contains the optional parameters for the SpatialAnchorsAccountsClient.ListBySubscription -// method. +// - options - SpatialAnchorsAccountsClientListBySubscriptionOptions contains the optional parameters for the SpatialAnchorsAccountsClient.NewListBySubscriptionPager +// method. func (client *SpatialAnchorsAccountsClient) NewListBySubscriptionPager(options *SpatialAnchorsAccountsClientListBySubscriptionOptions) *runtime.Pager[SpatialAnchorsAccountsClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[SpatialAnchorsAccountsClientListBySubscriptionResponse]{ More: func(page SpatialAnchorsAccountsClientListBySubscriptionResponse) bool { @@ -303,7 +296,7 @@ func (client *SpatialAnchorsAccountsClient) NewListBySubscriptionPager(options * if err != nil { return SpatialAnchorsAccountsClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SpatialAnchorsAccountsClientListBySubscriptionResponse{}, err } @@ -322,7 +315,7 @@ func (client *SpatialAnchorsAccountsClient) listBySubscriptionCreateRequest(ctx return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -344,17 +337,18 @@ func (client *SpatialAnchorsAccountsClient) listBySubscriptionHandleResponse(res // ListKeys - List Both of the 2 Keys of a Spatial Anchors Account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// options - SpatialAnchorsAccountsClientListKeysOptions contains the optional parameters for the SpatialAnchorsAccountsClient.ListKeys -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - options - SpatialAnchorsAccountsClientListKeysOptions contains the optional parameters for the SpatialAnchorsAccountsClient.ListKeys +// method. func (client *SpatialAnchorsAccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string, options *SpatialAnchorsAccountsClientListKeysOptions) (SpatialAnchorsAccountsClientListKeysResponse, error) { req, err := client.listKeysCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return SpatialAnchorsAccountsClientListKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SpatialAnchorsAccountsClientListKeysResponse{}, err } @@ -379,7 +373,7 @@ func (client *SpatialAnchorsAccountsClient) listKeysCreateRequest(ctx context.Co return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -401,18 +395,19 @@ func (client *SpatialAnchorsAccountsClient) listKeysHandleResponse(resp *http.Re // RegenerateKeys - Regenerate specified Key of a Spatial Anchors Account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// regenerate - Required information for key regeneration. -// options - SpatialAnchorsAccountsClientRegenerateKeysOptions contains the optional parameters for the SpatialAnchorsAccountsClient.RegenerateKeys -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - regenerate - Required information for key regeneration. +// - options - SpatialAnchorsAccountsClientRegenerateKeysOptions contains the optional parameters for the SpatialAnchorsAccountsClient.RegenerateKeys +// method. func (client *SpatialAnchorsAccountsClient) RegenerateKeys(ctx context.Context, resourceGroupName string, accountName string, regenerate AccountKeyRegenerateRequest, options *SpatialAnchorsAccountsClientRegenerateKeysOptions) (SpatialAnchorsAccountsClientRegenerateKeysResponse, error) { req, err := client.regenerateKeysCreateRequest(ctx, resourceGroupName, accountName, regenerate, options) if err != nil { return SpatialAnchorsAccountsClientRegenerateKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SpatialAnchorsAccountsClientRegenerateKeysResponse{}, err } @@ -437,7 +432,7 @@ func (client *SpatialAnchorsAccountsClient) regenerateKeysCreateRequest(ctx cont return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -459,18 +454,19 @@ func (client *SpatialAnchorsAccountsClient) regenerateKeysHandleResponse(resp *h // Update - Updating a Spatial Anchors Account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-03-01-preview -// resourceGroupName - Name of an Azure resource group. -// accountName - Name of an Mixed Reality Account. -// spatialAnchorsAccount - Spatial Anchors Account parameter. -// options - SpatialAnchorsAccountsClientUpdateOptions contains the optional parameters for the SpatialAnchorsAccountsClient.Update -// method. +// - resourceGroupName - Name of an Azure resource group. +// - accountName - Name of an Mixed Reality Account. +// - spatialAnchorsAccount - Spatial Anchors Account parameter. +// - options - SpatialAnchorsAccountsClientUpdateOptions contains the optional parameters for the SpatialAnchorsAccountsClient.Update +// method. func (client *SpatialAnchorsAccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, spatialAnchorsAccount SpatialAnchorsAccount, options *SpatialAnchorsAccountsClientUpdateOptions) (SpatialAnchorsAccountsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, spatialAnchorsAccount, options) if err != nil { return SpatialAnchorsAccountsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SpatialAnchorsAccountsClientUpdateResponse{}, err } @@ -495,7 +491,7 @@ func (client *SpatialAnchorsAccountsClient) updateCreateRequest(ctx context.Cont return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/spatialanchorsaccounts_client_example_test.go b/sdk/resourcemanager/mixedreality/armmixedreality/spatialanchorsaccounts_client_example_test.go new file mode 100644 index 000000000000..414b281c6821 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/spatialanchorsaccounts_client_example_test.go @@ -0,0 +1,296 @@ +//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 armmixedreality_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/mixedreality/armmixedreality" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/GetBySubscription.json +func ExampleSpatialAnchorsAccountsClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSpatialAnchorsAccountsClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SpatialAnchorsAccountPage = armmixedreality.SpatialAnchorsAccountPage{ + // Value: []*armmixedreality.SpatialAnchorsAccount{ + // { + // Name: to.Ptr("alpha"), + // Type: to.Ptr("Microsoft.MixedReality/spatialAnchorsAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/spatialAnchorsAccounts/alpha"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // }, + // { + // Name: to.Ptr("omega"), + // Type: to.Ptr("Microsoft.MixedReality/spatialAnchorsAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/spatialAnchorsAccounts/omega"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/GetByResourceGroup.json +func ExampleSpatialAnchorsAccountsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSpatialAnchorsAccountsClient().NewListByResourceGroupPager("MyResourceGroup", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SpatialAnchorsAccountPage = armmixedreality.SpatialAnchorsAccountPage{ + // Value: []*armmixedreality.SpatialAnchorsAccount{ + // { + // Name: to.Ptr("alpha"), + // Type: to.Ptr("Microsoft.MixedReality/spatialAnchorsAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/spatialAnchorsAccounts/alpha"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // }, + // { + // Name: to.Ptr("omega"), + // Type: to.Ptr("Microsoft.MixedReality/spatialAnchorsAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/spatialAnchorsAccounts/omega"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/Delete.json +func ExampleSpatialAnchorsAccountsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewSpatialAnchorsAccountsClient().Delete(ctx, "MyResourceGroup", "MyAccount", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/Get.json +func ExampleSpatialAnchorsAccountsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSpatialAnchorsAccountsClient().Get(ctx, "MyResourceGroup", "MyAccount", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SpatialAnchorsAccount = armmixedreality.SpatialAnchorsAccount{ + // Name: to.Ptr("MyAccount"), + // Type: to.Ptr("Microsoft.MixedReality/spatialAnchorsAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/spatialAnchorsAccounts/MyAccount"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/Patch.json +func ExampleSpatialAnchorsAccountsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSpatialAnchorsAccountsClient().Update(ctx, "MyResourceGroup", "MyAccount", armmixedreality.SpatialAnchorsAccount{ + Location: to.Ptr("eastus2euap"), + Tags: map[string]*string{ + "hero": to.Ptr("romeo"), + "heroine": to.Ptr("juliet"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SpatialAnchorsAccount = armmixedreality.SpatialAnchorsAccount{ + // Name: to.Ptr("MyAccount"), + // Type: to.Ptr("Microsoft.MixedReality/spatialAnchorsAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/spatialAnchorsAccounts/MyAccount"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // "hero": to.Ptr("romeo"), + // "heroine": to.Ptr("juliet"), + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/Put.json +func ExampleSpatialAnchorsAccountsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSpatialAnchorsAccountsClient().Create(ctx, "MyResourceGroup", "MyAccount", armmixedreality.SpatialAnchorsAccount{ + Location: to.Ptr("eastus2euap"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SpatialAnchorsAccount = armmixedreality.SpatialAnchorsAccount{ + // Name: to.Ptr("MyAccount"), + // Type: to.Ptr("Microsoft.MixedReality/spatialAnchorsAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.MixedReality/spatialAnchorsAccounts/MyAccount"), + // Location: to.Ptr("eastus2euap"), + // Tags: map[string]*string{ + // }, + // Properties: &armmixedreality.AccountProperties{ + // AccountDomain: to.Ptr("mixedreality.azure.com"), + // AccountID: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/ListKeys.json +func ExampleSpatialAnchorsAccountsClient_ListKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSpatialAnchorsAccountsClient().ListKeys(ctx, "MyResourceGroup", "MyAccount", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccountKeys = armmixedreality.AccountKeys{ + // PrimaryKey: to.Ptr("************"), + // SecondaryKey: to.Ptr("************"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/RegenerateKey.json +func ExampleSpatialAnchorsAccountsClient_RegenerateKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmixedreality.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSpatialAnchorsAccountsClient().RegenerateKeys(ctx, "MyResourceGroup", "MyAccount", armmixedreality.AccountKeyRegenerateRequest{ + Serial: to.Ptr(armmixedreality.SerialPrimary), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccountKeys = armmixedreality.AccountKeys{ + // PrimaryKey: to.Ptr("************"), + // SecondaryKey: to.Ptr("************"), + // } +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_time_rfc3339.go b/sdk/resourcemanager/mixedreality/armmixedreality/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/mixedreality/armmixedreality/time_rfc3339.go index d2c5b480b924..816b80d63b2c 100644 --- a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/mixedreality/armmixedreality/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 armmixedreality @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_mixedrealityclient_client_test.go b/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_mixedrealityclient_client_test.go deleted file mode 100644 index 0f245cc6fd99..000000000000 --- a/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_mixedrealityclient_client_test.go +++ /dev/null @@ -1,43 +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 armmixedreality_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/mixedreality/armmixedreality" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/proxy/CheckNameAvailabilityForLocalUniqueness.json -func ExampleClient_CheckNameAvailabilityLocal() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CheckNameAvailabilityLocal(ctx, - "eastus2euap", - armmixedreality.CheckNameAvailabilityRequest{ - Name: to.Ptr("MyAccount"), - Type: to.Ptr("Microsoft.MixedReality/spatialAnchorsAccounts"), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_objectanchorsaccounts_client_test.go b/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_objectanchorsaccounts_client_test.go deleted file mode 100644 index 8e827cfd680e..000000000000 --- a/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_objectanchorsaccounts_client_test.go +++ /dev/null @@ -1,216 +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 armmixedreality_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/mixedreality/armmixedreality" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/GetBySubscription.json -func ExampleObjectAnchorsAccountsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewObjectAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/GetByResourceGroup.json -func ExampleObjectAnchorsAccountsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewObjectAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("MyResourceGroup", - 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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/Delete.json -func ExampleObjectAnchorsAccountsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewObjectAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "MyResourceGroup", - "MyAccount", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/Get.json -func ExampleObjectAnchorsAccountsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewObjectAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "MyResourceGroup", - "MyAccount", - 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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/Patch.json -func ExampleObjectAnchorsAccountsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewObjectAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "MyResourceGroup", - "MyAccount", - armmixedreality.ObjectAnchorsAccount{ - Location: to.Ptr("eastus2euap"), - Tags: map[string]*string{ - "hero": to.Ptr("romeo"), - "heroine": to.Ptr("juliet"), - }, - Identity: &armmixedreality.ObjectAnchorsAccountIdentity{ - Type: to.Ptr("SystemAssigned"), - }, - }, - 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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/Put.json -func ExampleObjectAnchorsAccountsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewObjectAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, - "MyResourceGroup", - "MyAccount", - armmixedreality.ObjectAnchorsAccount{ - Location: to.Ptr("eastus2euap"), - Identity: &armmixedreality.ObjectAnchorsAccountIdentity{ - Type: to.Ptr("SystemAssigned"), - }, - }, - 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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/ListKeys.json -func ExampleObjectAnchorsAccountsClient_ListKeys() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewObjectAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListKeys(ctx, - "MyResourceGroup", - "MyAccount", - 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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/RegenerateKey.json -func ExampleObjectAnchorsAccountsClient_RegenerateKeys() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewObjectAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.RegenerateKeys(ctx, - "MyResourceGroup", - "MyAccount", - armmixedreality.AccountKeyRegenerateRequest{ - Serial: to.Ptr(armmixedreality.SerialPrimary), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_operations_client_test.go deleted file mode 100644 index 15d23b0b4165..000000000000 --- a/sdk/resourcemanager/mixedreality/armmixedreality/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 armmixedreality_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mixedreality/armmixedreality" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/proxy/ExposingAvailableOperations.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 := armmixedreality.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/mixedreality/armmixedreality/ze_generated_example_remoterenderingaccounts_client_test.go b/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_remoterenderingaccounts_client_test.go deleted file mode 100644 index 58dd8bb28625..000000000000 --- a/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_remoterenderingaccounts_client_test.go +++ /dev/null @@ -1,216 +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 armmixedreality_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/mixedreality/armmixedreality" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/GetBySubscription.json -func ExampleRemoteRenderingAccountsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewRemoteRenderingAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/GetByResourceGroup.json -func ExampleRemoteRenderingAccountsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewRemoteRenderingAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("MyResourceGroup", - 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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/Delete.json -func ExampleRemoteRenderingAccountsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewRemoteRenderingAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "MyResourceGroup", - "MyAccount", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/Get.json -func ExampleRemoteRenderingAccountsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewRemoteRenderingAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "MyResourceGroup", - "MyAccount", - 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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/Patch.json -func ExampleRemoteRenderingAccountsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewRemoteRenderingAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "MyResourceGroup", - "MyAccount", - armmixedreality.RemoteRenderingAccount{ - Location: to.Ptr("eastus2euap"), - Tags: map[string]*string{ - "hero": to.Ptr("romeo"), - "heroine": to.Ptr("juliet"), - }, - Identity: &armmixedreality.Identity{ - Type: to.Ptr("SystemAssigned"), - }, - }, - 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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/Put.json -func ExampleRemoteRenderingAccountsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewRemoteRenderingAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, - "MyResourceGroup", - "MyAccount", - armmixedreality.RemoteRenderingAccount{ - Location: to.Ptr("eastus2euap"), - Identity: &armmixedreality.Identity{ - Type: to.Ptr("SystemAssigned"), - }, - }, - 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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/ListKeys.json -func ExampleRemoteRenderingAccountsClient_ListKeys() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewRemoteRenderingAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListKeys(ctx, - "MyResourceGroup", - "MyAccount", - 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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/RegenerateKey.json -func ExampleRemoteRenderingAccountsClient_RegenerateKeys() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewRemoteRenderingAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.RegenerateKeys(ctx, - "MyResourceGroup", - "MyAccount", - armmixedreality.AccountKeyRegenerateRequest{ - Serial: to.Ptr(armmixedreality.SerialPrimary), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_spatialanchorsaccounts_client_test.go b/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_spatialanchorsaccounts_client_test.go deleted file mode 100644 index 71f02ef518d2..000000000000 --- a/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_spatialanchorsaccounts_client_test.go +++ /dev/null @@ -1,210 +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 armmixedreality_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/mixedreality/armmixedreality" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/GetBySubscription.json -func ExampleSpatialAnchorsAccountsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewSpatialAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/GetByResourceGroup.json -func ExampleSpatialAnchorsAccountsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewSpatialAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("MyResourceGroup", - 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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/Delete.json -func ExampleSpatialAnchorsAccountsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewSpatialAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "MyResourceGroup", - "MyAccount", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/Get.json -func ExampleSpatialAnchorsAccountsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewSpatialAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "MyResourceGroup", - "MyAccount", - 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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/Patch.json -func ExampleSpatialAnchorsAccountsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewSpatialAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "MyResourceGroup", - "MyAccount", - armmixedreality.SpatialAnchorsAccount{ - Location: to.Ptr("eastus2euap"), - Tags: map[string]*string{ - "hero": to.Ptr("romeo"), - "heroine": to.Ptr("juliet"), - }, - }, - 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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/Put.json -func ExampleSpatialAnchorsAccountsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewSpatialAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, - "MyResourceGroup", - "MyAccount", - armmixedreality.SpatialAnchorsAccount{ - Location: to.Ptr("eastus2euap"), - }, - 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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/ListKeys.json -func ExampleSpatialAnchorsAccountsClient_ListKeys() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewSpatialAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListKeys(ctx, - "MyResourceGroup", - "MyAccount", - 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/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/RegenerateKey.json -func ExampleSpatialAnchorsAccountsClient_RegenerateKeys() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmixedreality.NewSpatialAnchorsAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.RegenerateKeys(ctx, - "MyResourceGroup", - "MyAccount", - armmixedreality.AccountKeyRegenerateRequest{ - Serial: to.Ptr(armmixedreality.SerialPrimary), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_models_serde.go b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_models_serde.go deleted file mode 100644 index b2f5c9ce9104..000000000000 --- a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_models_serde.go +++ /dev/null @@ -1,145 +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 armmixedreality - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type ObjectAnchorsAccount. -func (o ObjectAnchorsAccount) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", o.ID) - populate(objectMap, "identity", o.Identity) - populate(objectMap, "kind", o.Kind) - populate(objectMap, "location", o.Location) - populate(objectMap, "name", o.Name) - populate(objectMap, "plan", o.Plan) - populate(objectMap, "properties", o.Properties) - populate(objectMap, "sku", o.SKU) - populate(objectMap, "systemData", o.SystemData) - populate(objectMap, "tags", o.Tags) - populate(objectMap, "type", o.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type RemoteRenderingAccount. -func (r RemoteRenderingAccount) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", r.ID) - populate(objectMap, "identity", r.Identity) - populate(objectMap, "kind", r.Kind) - populate(objectMap, "location", r.Location) - populate(objectMap, "name", r.Name) - populate(objectMap, "plan", r.Plan) - populate(objectMap, "properties", r.Properties) - populate(objectMap, "sku", r.SKU) - populate(objectMap, "systemData", r.SystemData) - populate(objectMap, "tags", r.Tags) - populate(objectMap, "type", r.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type SpatialAnchorsAccount. -func (s SpatialAnchorsAccount) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", s.ID) - populate(objectMap, "identity", s.Identity) - populate(objectMap, "kind", s.Kind) - populate(objectMap, "location", s.Location) - populate(objectMap, "name", s.Name) - populate(objectMap, "plan", s.Plan) - populate(objectMap, "properties", s.Properties) - populate(objectMap, "sku", s.SKU) - populate(objectMap, "systemData", s.SystemData) - populate(objectMap, "tags", s.Tags) - populate(objectMap, "type", s.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type TrackedResource. -func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -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/mobilenetwork/armmobilenetwork/CHANGELOG.md b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/CHANGELOG.md index 5d81606a40de..b44d44d8c98d 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/CHANGELOG.md +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 2.1.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 2.0.0 (2023-01-27) ### Breaking Changes diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/README.md b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/README.md index 50736686febf..3210def7501a 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/README.md +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Private 5G Core modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Private 5G Core module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armmobilenetwork.NewSlicesClient(, cred, nil) +clientFactory, err := armmobilenetwork.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client := armmobilenetwork.NewSlicesClient(, cred, &options) +clientFactory, err := armmobilenetwork.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewMobileNetworksClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/attacheddatanetworks_client.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/attacheddatanetworks_client.go index be6794886627..4c6f437e46ee 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/attacheddatanetworks_client.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/attacheddatanetworks_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,31 +24,22 @@ import ( // AttachedDataNetworksClient contains the methods for the AttachedDataNetworks group. // Don't use this type directly, use NewAttachedDataNetworksClient() instead. type AttachedDataNetworksClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAttachedDataNetworksClient creates a new instance of AttachedDataNetworksClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAttachedDataNetworksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AttachedDataNetworksClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AttachedDataNetworksClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AttachedDataNetworksClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,38 +47,40 @@ func NewAttachedDataNetworksClient(subscriptionID string, credential azcore.Toke // BeginCreateOrUpdate - Creates or updates an attached data network. Must be created in the same location as its parent packet // core data plane. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// packetCoreDataPlaneName - The name of the packet core data plane. -// attachedDataNetworkName - The name of the attached data network. -// parameters - Parameters supplied to the create or update attached data network operation. -// options - AttachedDataNetworksClientBeginCreateOrUpdateOptions contains the optional parameters for the AttachedDataNetworksClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - packetCoreDataPlaneName - The name of the packet core data plane. +// - attachedDataNetworkName - The name of the attached data network. +// - parameters - Parameters supplied to the create or update attached data network operation. +// - options - AttachedDataNetworksClientBeginCreateOrUpdateOptions contains the optional parameters for the AttachedDataNetworksClient.BeginCreateOrUpdate +// method. func (client *AttachedDataNetworksClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, attachedDataNetworkName string, parameters AttachedDataNetwork, options *AttachedDataNetworksClientBeginCreateOrUpdateOptions) (*runtime.Poller[AttachedDataNetworksClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, attachedDataNetworkName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AttachedDataNetworksClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AttachedDataNetworksClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[AttachedDataNetworksClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AttachedDataNetworksClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates an attached data network. Must be created in the same location as its parent packet // core data plane. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *AttachedDataNetworksClient) createOrUpdate(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, attachedDataNetworkName string, parameters AttachedDataNetwork, options *AttachedDataNetworksClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, attachedDataNetworkName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -122,7 +113,7 @@ func (client *AttachedDataNetworksClient) createOrUpdateCreateRequest(ctx contex return nil, errors.New("parameter attachedDataNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{attachedDataNetworkName}", url.PathEscape(attachedDataNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -135,36 +126,38 @@ func (client *AttachedDataNetworksClient) createOrUpdateCreateRequest(ctx contex // BeginDelete - Deletes the specified attached data network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// packetCoreDataPlaneName - The name of the packet core data plane. -// attachedDataNetworkName - The name of the attached data network. -// options - AttachedDataNetworksClientBeginDeleteOptions contains the optional parameters for the AttachedDataNetworksClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - packetCoreDataPlaneName - The name of the packet core data plane. +// - attachedDataNetworkName - The name of the attached data network. +// - options - AttachedDataNetworksClientBeginDeleteOptions contains the optional parameters for the AttachedDataNetworksClient.BeginDelete +// method. func (client *AttachedDataNetworksClient) BeginDelete(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, attachedDataNetworkName string, options *AttachedDataNetworksClientBeginDeleteOptions) (*runtime.Poller[AttachedDataNetworksClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, attachedDataNetworkName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AttachedDataNetworksClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AttachedDataNetworksClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[AttachedDataNetworksClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AttachedDataNetworksClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the specified attached data network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *AttachedDataNetworksClient) deleteOperation(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, attachedDataNetworkName string, options *AttachedDataNetworksClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, attachedDataNetworkName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -197,7 +190,7 @@ func (client *AttachedDataNetworksClient) deleteCreateRequest(ctx context.Contex return nil, errors.New("parameter attachedDataNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{attachedDataNetworkName}", url.PathEscape(attachedDataNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -210,19 +203,20 @@ func (client *AttachedDataNetworksClient) deleteCreateRequest(ctx context.Contex // Get - Gets information about the specified attached data network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// packetCoreDataPlaneName - The name of the packet core data plane. -// attachedDataNetworkName - The name of the attached data network. -// options - AttachedDataNetworksClientGetOptions contains the optional parameters for the AttachedDataNetworksClient.Get -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - packetCoreDataPlaneName - The name of the packet core data plane. +// - attachedDataNetworkName - The name of the attached data network. +// - options - AttachedDataNetworksClientGetOptions contains the optional parameters for the AttachedDataNetworksClient.Get +// method. func (client *AttachedDataNetworksClient) Get(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, attachedDataNetworkName string, options *AttachedDataNetworksClientGetOptions) (AttachedDataNetworksClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, attachedDataNetworkName, options) if err != nil { return AttachedDataNetworksClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AttachedDataNetworksClientGetResponse{}, err } @@ -255,7 +249,7 @@ func (client *AttachedDataNetworksClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter attachedDataNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{attachedDataNetworkName}", url.PathEscape(attachedDataNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -276,12 +270,13 @@ func (client *AttachedDataNetworksClient) getHandleResponse(resp *http.Response) } // NewListByPacketCoreDataPlanePager - Gets all the attached data networks associated with a packet core data plane. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// packetCoreDataPlaneName - The name of the packet core data plane. -// options - AttachedDataNetworksClientListByPacketCoreDataPlaneOptions contains the optional parameters for the AttachedDataNetworksClient.ListByPacketCoreDataPlane -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - packetCoreDataPlaneName - The name of the packet core data plane. +// - options - AttachedDataNetworksClientListByPacketCoreDataPlaneOptions contains the optional parameters for the AttachedDataNetworksClient.NewListByPacketCoreDataPlanePager +// method. func (client *AttachedDataNetworksClient) NewListByPacketCoreDataPlanePager(resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, options *AttachedDataNetworksClientListByPacketCoreDataPlaneOptions) *runtime.Pager[AttachedDataNetworksClientListByPacketCoreDataPlaneResponse] { return runtime.NewPager(runtime.PagingHandler[AttachedDataNetworksClientListByPacketCoreDataPlaneResponse]{ More: func(page AttachedDataNetworksClientListByPacketCoreDataPlaneResponse) bool { @@ -298,7 +293,7 @@ func (client *AttachedDataNetworksClient) NewListByPacketCoreDataPlanePager(reso if err != nil { return AttachedDataNetworksClientListByPacketCoreDataPlaneResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AttachedDataNetworksClientListByPacketCoreDataPlaneResponse{}, err } @@ -329,7 +324,7 @@ func (client *AttachedDataNetworksClient) listByPacketCoreDataPlaneCreateRequest return nil, errors.New("parameter packetCoreDataPlaneName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{packetCoreDataPlaneName}", url.PathEscape(packetCoreDataPlaneName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -351,20 +346,21 @@ func (client *AttachedDataNetworksClient) listByPacketCoreDataPlaneHandleRespons // UpdateTags - Updates an attached data network tags. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// packetCoreDataPlaneName - The name of the packet core data plane. -// attachedDataNetworkName - The name of the attached data network. -// parameters - Parameters supplied to update attached data network tags. -// options - AttachedDataNetworksClientUpdateTagsOptions contains the optional parameters for the AttachedDataNetworksClient.UpdateTags -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - packetCoreDataPlaneName - The name of the packet core data plane. +// - attachedDataNetworkName - The name of the attached data network. +// - parameters - Parameters supplied to update attached data network tags. +// - options - AttachedDataNetworksClientUpdateTagsOptions contains the optional parameters for the AttachedDataNetworksClient.UpdateTags +// method. func (client *AttachedDataNetworksClient) UpdateTags(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, attachedDataNetworkName string, parameters TagsObject, options *AttachedDataNetworksClientUpdateTagsOptions) (AttachedDataNetworksClientUpdateTagsResponse, error) { req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, attachedDataNetworkName, parameters, options) if err != nil { return AttachedDataNetworksClientUpdateTagsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AttachedDataNetworksClientUpdateTagsResponse{}, err } @@ -397,7 +393,7 @@ func (client *AttachedDataNetworksClient) updateTagsCreateRequest(ctx context.Co return nil, errors.New("parameter attachedDataNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{attachedDataNetworkName}", url.PathEscape(attachedDataNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/attacheddatanetworks_client_example_test.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/attacheddatanetworks_client_example_test.go index 231a3cb4e498..4d26de7702aa 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/attacheddatanetworks_client_example_test.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/attacheddatanetworks_client_example_test.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 armmobilenetwork_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mobilenetwork/armmobilenetwork/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/AttachedDataNetworkDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/AttachedDataNetworkDelete.json func ExampleAttachedDataNetworksClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewAttachedDataNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rg1", "TestPacketCoreCP", "TestPacketCoreDP", "TestAttachedDataNetwork", nil) + poller, err := clientFactory.NewAttachedDataNetworksClient().BeginDelete(ctx, "rg1", "TestPacketCoreCP", "TestPacketCoreDP", "TestAttachedDataNetwork", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -38,37 +39,83 @@ func ExampleAttachedDataNetworksClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/AttachedDataNetworkGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/AttachedDataNetworkGet.json func ExampleAttachedDataNetworksClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewAttachedDataNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rg1", "TestPacketCoreCP", "TestPacketCoreDP", "TestAttachedDataNetwork", nil) + res, err := clientFactory.NewAttachedDataNetworksClient().Get(ctx, "rg1", "TestPacketCoreCP", "TestPacketCoreDP", "TestAttachedDataNetwork", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AttachedDataNetwork = armmobilenetwork.AttachedDataNetwork{ + // Name: to.Ptr("TestAttachedDataNetwork"), + // Type: to.Ptr("Microsoft.MobileNetwork/attachedDataNetwork"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.AttachedDataNetworkPropertiesFormat{ + // DNSAddresses: []*string{ + // to.Ptr("1.1.1.1")}, + // NaptConfiguration: &armmobilenetwork.NaptConfiguration{ + // Enabled: to.Ptr(armmobilenetwork.NaptEnabledEnabled), + // PinholeLimits: to.Ptr[int32](65536), + // PinholeTimeouts: &armmobilenetwork.PinholeTimeouts{ + // Icmp: to.Ptr[int32](30), + // TCP: to.Ptr[int32](180), + // UDP: to.Ptr[int32](30), + // }, + // PortRange: &armmobilenetwork.PortRange{ + // MaxPort: to.Ptr[int32](49999), + // MinPort: to.Ptr[int32](1024), + // }, + // PortReuseHoldTime: &armmobilenetwork.PortReuseHoldTimes{ + // TCP: to.Ptr[int32](120), + // UDP: to.Ptr[int32](60), + // }, + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // UserEquipmentAddressPoolPrefix: []*string{ + // to.Ptr("2.2.0.0/16")}, + // UserEquipmentStaticAddressPoolPrefix: []*string{ + // to.Ptr("2.4.0.0/16")}, + // UserPlaneDataInterface: &armmobilenetwork.InterfaceProperties{ + // Name: to.Ptr("N6"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/AttachedDataNetworkCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/AttachedDataNetworkCreate.json func ExampleAttachedDataNetworksClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewAttachedDataNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "TestPacketCoreCP", "TestPacketCoreDP", "TestAttachedDataNetwork", armmobilenetwork.AttachedDataNetwork{ + poller, err := clientFactory.NewAttachedDataNetworksClient().BeginCreateOrUpdate(ctx, "rg1", "TestPacketCoreCP", "TestPacketCoreDP", "TestAttachedDataNetwork", armmobilenetwork.AttachedDataNetwork{ Location: to.Ptr("eastus"), Properties: &armmobilenetwork.AttachedDataNetworkPropertiesFormat{ DNSAddresses: []*string{ @@ -106,22 +153,68 @@ func ExampleAttachedDataNetworksClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AttachedDataNetwork = armmobilenetwork.AttachedDataNetwork{ + // Name: to.Ptr("TestAttachedDataNetwork"), + // Type: to.Ptr("Microsoft.MobileNetwork/attachedDataNetwork"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.AttachedDataNetworkPropertiesFormat{ + // DNSAddresses: []*string{ + // to.Ptr("1.1.1.1")}, + // NaptConfiguration: &armmobilenetwork.NaptConfiguration{ + // Enabled: to.Ptr(armmobilenetwork.NaptEnabledEnabled), + // PinholeLimits: to.Ptr[int32](65536), + // PinholeTimeouts: &armmobilenetwork.PinholeTimeouts{ + // Icmp: to.Ptr[int32](30), + // TCP: to.Ptr[int32](180), + // UDP: to.Ptr[int32](30), + // }, + // PortRange: &armmobilenetwork.PortRange{ + // MaxPort: to.Ptr[int32](49999), + // MinPort: to.Ptr[int32](1024), + // }, + // PortReuseHoldTime: &armmobilenetwork.PortReuseHoldTimes{ + // TCP: to.Ptr[int32](120), + // UDP: to.Ptr[int32](60), + // }, + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // UserEquipmentAddressPoolPrefix: []*string{ + // to.Ptr("2.2.0.0/16")}, + // UserEquipmentStaticAddressPoolPrefix: []*string{ + // to.Ptr("2.4.0.0/16")}, + // UserPlaneDataInterface: &armmobilenetwork.InterfaceProperties{ + // Name: to.Ptr("N6"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/AttachedDataNetworkUpdateTags.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/AttachedDataNetworkUpdateTags.json func ExampleAttachedDataNetworksClient_UpdateTags() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewAttachedDataNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.UpdateTags(ctx, "rg1", "TestPacketCoreCP", "TestPacketCoreDP", "TestAttachedDataNetwork", armmobilenetwork.TagsObject{ + res, err := clientFactory.NewAttachedDataNetworksClient().UpdateTags(ctx, "rg1", "TestPacketCoreCP", "TestPacketCoreDP", "TestAttachedDataNetwork", armmobilenetwork.TagsObject{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -130,30 +223,127 @@ func ExampleAttachedDataNetworksClient_UpdateTags() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AttachedDataNetwork = armmobilenetwork.AttachedDataNetwork{ + // Name: to.Ptr("TestAccessPoint"), + // Type: to.Ptr("Microsoft.MobileNetwork/attachedDataNetwork"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armmobilenetwork.AttachedDataNetworkPropertiesFormat{ + // DNSAddresses: []*string{ + // to.Ptr("1.1.1.1")}, + // NaptConfiguration: &armmobilenetwork.NaptConfiguration{ + // Enabled: to.Ptr(armmobilenetwork.NaptEnabledEnabled), + // PinholeLimits: to.Ptr[int32](65536), + // PinholeTimeouts: &armmobilenetwork.PinholeTimeouts{ + // Icmp: to.Ptr[int32](30), + // TCP: to.Ptr[int32](180), + // UDP: to.Ptr[int32](30), + // }, + // PortRange: &armmobilenetwork.PortRange{ + // MaxPort: to.Ptr[int32](49999), + // MinPort: to.Ptr[int32](1024), + // }, + // PortReuseHoldTime: &armmobilenetwork.PortReuseHoldTimes{ + // TCP: to.Ptr[int32](120), + // UDP: to.Ptr[int32](60), + // }, + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // UserEquipmentAddressPoolPrefix: []*string{ + // to.Ptr("2.2.0.0/16")}, + // UserEquipmentStaticAddressPoolPrefix: []*string{ + // to.Ptr("2.4.0.0/16")}, + // UserPlaneDataInterface: &armmobilenetwork.InterfaceProperties{ + // Name: to.Ptr("N6"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/AttachedDataNetworkListByPacketCoreDataPlane.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/AttachedDataNetworkListByPacketCoreDataPlane.json func ExampleAttachedDataNetworksClient_NewListByPacketCoreDataPlanePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewAttachedDataNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByPacketCoreDataPlanePager("rg1", "TestPacketCoreCP", "TestPacketCoreDP", nil) + pager := clientFactory.NewAttachedDataNetworksClient().NewListByPacketCoreDataPlanePager("rg1", "TestPacketCoreCP", "TestPacketCoreDP", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AttachedDataNetworkListResult = armmobilenetwork.AttachedDataNetworkListResult{ + // Value: []*armmobilenetwork.AttachedDataNetwork{ + // { + // Name: to.Ptr("TestAttachedDataNetwork"), + // Type: to.Ptr("Microsoft.MobileNetwork/attachedDataNetworks"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.AttachedDataNetworkPropertiesFormat{ + // DNSAddresses: []*string{ + // to.Ptr("1.1.1.1")}, + // NaptConfiguration: &armmobilenetwork.NaptConfiguration{ + // Enabled: to.Ptr(armmobilenetwork.NaptEnabledEnabled), + // PinholeLimits: to.Ptr[int32](65536), + // PinholeTimeouts: &armmobilenetwork.PinholeTimeouts{ + // Icmp: to.Ptr[int32](30), + // TCP: to.Ptr[int32](180), + // UDP: to.Ptr[int32](30), + // }, + // PortRange: &armmobilenetwork.PortRange{ + // MaxPort: to.Ptr[int32](49999), + // MinPort: to.Ptr[int32](1024), + // }, + // PortReuseHoldTime: &armmobilenetwork.PortReuseHoldTimes{ + // TCP: to.Ptr[int32](120), + // UDP: to.Ptr[int32](60), + // }, + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // UserEquipmentAddressPoolPrefix: []*string{ + // to.Ptr("2.2.0.0/16")}, + // UserEquipmentStaticAddressPoolPrefix: []*string{ + // to.Ptr("2.4.0.0/16")}, + // UserPlaneDataInterface: &armmobilenetwork.InterfaceProperties{ + // Name: to.Ptr("N6"), + // }, + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/autorest.md b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/autorest.md index 5e3eb9e1bc5c..12c5ed6d741a 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/autorest.md +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.0.0 +module-version: 2.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/client_factory.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/client_factory.go new file mode 100644 index 000000000000..370010892d83 --- /dev/null +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/client_factory.go @@ -0,0 +1,104 @@ +//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 armmobilenetwork + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewAttachedDataNetworksClient() *AttachedDataNetworksClient { + subClient, _ := NewAttachedDataNetworksClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDataNetworksClient() *DataNetworksClient { + subClient, _ := NewDataNetworksClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewMobileNetworksClient() *MobileNetworksClient { + subClient, _ := NewMobileNetworksClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPacketCoreControlPlanesClient() *PacketCoreControlPlanesClient { + subClient, _ := NewPacketCoreControlPlanesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPacketCoreControlPlaneVersionsClient() *PacketCoreControlPlaneVersionsClient { + subClient, _ := NewPacketCoreControlPlaneVersionsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPacketCoreDataPlanesClient() *PacketCoreDataPlanesClient { + subClient, _ := NewPacketCoreDataPlanesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewServicesClient() *ServicesClient { + subClient, _ := NewServicesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSimsClient() *SimsClient { + subClient, _ := NewSimsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSimGroupsClient() *SimGroupsClient { + subClient, _ := NewSimGroupsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSimPoliciesClient() *SimPoliciesClient { + subClient, _ := NewSimPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSitesClient() *SitesClient { + subClient, _ := NewSitesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSlicesClient() *SlicesClient { + subClient, _ := NewSlicesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/constants.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/constants.go index c589556179a7..016708d74a79 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/constants.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/constants.go @@ -11,7 +11,7 @@ package armmobilenetwork const ( moduleName = "armmobilenetwork" - moduleVersion = "v2.0.0" + moduleVersion = "v2.1.0" ) // AuthenticationType - How to authenticate users who access local diagnostics APIs. diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/datanetworks_client.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/datanetworks_client.go index 83353f204c92..9ae93860b2f5 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/datanetworks_client.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/datanetworks_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,67 +24,60 @@ import ( // DataNetworksClient contains the methods for the DataNetworks group. // Don't use this type directly, use NewDataNetworksClient() instead. type DataNetworksClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDataNetworksClient creates a new instance of DataNetworksClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewDataNetworksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DataNetworksClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".DataNetworksClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DataNetworksClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a data network. Must be created in the same location as its parent mobile network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// dataNetworkName - The name of the data network. -// parameters - Parameters supplied to the create or update data network operation. -// options - DataNetworksClientBeginCreateOrUpdateOptions contains the optional parameters for the DataNetworksClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - dataNetworkName - The name of the data network. +// - parameters - Parameters supplied to the create or update data network operation. +// - options - DataNetworksClientBeginCreateOrUpdateOptions contains the optional parameters for the DataNetworksClient.BeginCreateOrUpdate +// method. func (client *DataNetworksClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, mobileNetworkName string, dataNetworkName string, parameters DataNetwork, options *DataNetworksClientBeginCreateOrUpdateOptions) (*runtime.Poller[DataNetworksClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, mobileNetworkName, dataNetworkName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DataNetworksClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DataNetworksClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[DataNetworksClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DataNetworksClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a data network. Must be created in the same location as its parent mobile network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *DataNetworksClient) createOrUpdate(ctx context.Context, resourceGroupName string, mobileNetworkName string, dataNetworkName string, parameters DataNetwork, options *DataNetworksClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, mobileNetworkName, dataNetworkName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -115,7 +106,7 @@ func (client *DataNetworksClient) createOrUpdateCreateRequest(ctx context.Contex return nil, errors.New("parameter dataNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dataNetworkName}", url.PathEscape(dataNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -128,35 +119,37 @@ func (client *DataNetworksClient) createOrUpdateCreateRequest(ctx context.Contex // BeginDelete - Deletes the specified data network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// dataNetworkName - The name of the data network. -// options - DataNetworksClientBeginDeleteOptions contains the optional parameters for the DataNetworksClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - dataNetworkName - The name of the data network. +// - options - DataNetworksClientBeginDeleteOptions contains the optional parameters for the DataNetworksClient.BeginDelete +// method. func (client *DataNetworksClient) BeginDelete(ctx context.Context, resourceGroupName string, mobileNetworkName string, dataNetworkName string, options *DataNetworksClientBeginDeleteOptions) (*runtime.Poller[DataNetworksClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, mobileNetworkName, dataNetworkName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DataNetworksClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DataNetworksClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[DataNetworksClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DataNetworksClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the specified data network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *DataNetworksClient) deleteOperation(ctx context.Context, resourceGroupName string, mobileNetworkName string, dataNetworkName string, options *DataNetworksClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, mobileNetworkName, dataNetworkName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -185,7 +178,7 @@ func (client *DataNetworksClient) deleteCreateRequest(ctx context.Context, resou return nil, errors.New("parameter dataNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dataNetworkName}", url.PathEscape(dataNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,17 +191,18 @@ func (client *DataNetworksClient) deleteCreateRequest(ctx context.Context, resou // Get - Gets information about the specified data network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// dataNetworkName - The name of the data network. -// options - DataNetworksClientGetOptions contains the optional parameters for the DataNetworksClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - dataNetworkName - The name of the data network. +// - options - DataNetworksClientGetOptions contains the optional parameters for the DataNetworksClient.Get method. func (client *DataNetworksClient) Get(ctx context.Context, resourceGroupName string, mobileNetworkName string, dataNetworkName string, options *DataNetworksClientGetOptions) (DataNetworksClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, mobileNetworkName, dataNetworkName, options) if err != nil { return DataNetworksClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DataNetworksClientGetResponse{}, err } @@ -237,7 +231,7 @@ func (client *DataNetworksClient) getCreateRequest(ctx context.Context, resource return nil, errors.New("parameter dataNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dataNetworkName}", url.PathEscape(dataNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -258,11 +252,12 @@ func (client *DataNetworksClient) getHandleResponse(resp *http.Response) (DataNe } // NewListByMobileNetworkPager - Lists all data networks in the mobile network. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// options - DataNetworksClientListByMobileNetworkOptions contains the optional parameters for the DataNetworksClient.ListByMobileNetwork -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - options - DataNetworksClientListByMobileNetworkOptions contains the optional parameters for the DataNetworksClient.NewListByMobileNetworkPager +// method. func (client *DataNetworksClient) NewListByMobileNetworkPager(resourceGroupName string, mobileNetworkName string, options *DataNetworksClientListByMobileNetworkOptions) *runtime.Pager[DataNetworksClientListByMobileNetworkResponse] { return runtime.NewPager(runtime.PagingHandler[DataNetworksClientListByMobileNetworkResponse]{ More: func(page DataNetworksClientListByMobileNetworkResponse) bool { @@ -279,7 +274,7 @@ func (client *DataNetworksClient) NewListByMobileNetworkPager(resourceGroupName if err != nil { return DataNetworksClientListByMobileNetworkResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DataNetworksClientListByMobileNetworkResponse{}, err } @@ -306,7 +301,7 @@ func (client *DataNetworksClient) listByMobileNetworkCreateRequest(ctx context.C return nil, errors.New("parameter mobileNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{mobileNetworkName}", url.PathEscape(mobileNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -328,18 +323,19 @@ func (client *DataNetworksClient) listByMobileNetworkHandleResponse(resp *http.R // UpdateTags - Updates data network tags. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// dataNetworkName - The name of the data network. -// parameters - Parameters supplied to update data network tags. -// options - DataNetworksClientUpdateTagsOptions contains the optional parameters for the DataNetworksClient.UpdateTags method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - dataNetworkName - The name of the data network. +// - parameters - Parameters supplied to update data network tags. +// - options - DataNetworksClientUpdateTagsOptions contains the optional parameters for the DataNetworksClient.UpdateTags method. func (client *DataNetworksClient) UpdateTags(ctx context.Context, resourceGroupName string, mobileNetworkName string, dataNetworkName string, parameters TagsObject, options *DataNetworksClientUpdateTagsOptions) (DataNetworksClientUpdateTagsResponse, error) { req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, mobileNetworkName, dataNetworkName, parameters, options) if err != nil { return DataNetworksClientUpdateTagsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DataNetworksClientUpdateTagsResponse{}, err } @@ -368,7 +364,7 @@ func (client *DataNetworksClient) updateTagsCreateRequest(ctx context.Context, r return nil, errors.New("parameter dataNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dataNetworkName}", url.PathEscape(dataNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/datanetworks_client_example_test.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/datanetworks_client_example_test.go index 0b9121c2a0fe..70836a695e42 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/datanetworks_client_example_test.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/datanetworks_client_example_test.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 armmobilenetwork_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mobilenetwork/armmobilenetwork/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/DataNetworkDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/DataNetworkDelete.json func ExampleDataNetworksClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewDataNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rg1", "testMobileNetwork", "testDataNetwork", nil) + poller, err := clientFactory.NewDataNetworksClient().BeginDelete(ctx, "rg1", "testMobileNetwork", "testDataNetwork", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -38,37 +39,58 @@ func ExampleDataNetworksClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/DataNetworkGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/DataNetworkGet.json func ExampleDataNetworksClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewDataNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rg1", "testMobileNetwork", "testDataNetwork", nil) + res, err := clientFactory.NewDataNetworksClient().Get(ctx, "rg1", "testMobileNetwork", "testDataNetwork", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataNetwork = armmobilenetwork.DataNetwork{ + // Name: to.Ptr("testDataNetwork"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks/dataNetworks"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testDataNetwork"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.DataNetworkPropertiesFormat{ + // Description: to.Ptr("myFavouriteDataNetwork"), + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/DataNetworkCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/DataNetworkCreate.json func ExampleDataNetworksClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewDataNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "testMobileNetwork", "testDataNetwork", armmobilenetwork.DataNetwork{ + poller, err := clientFactory.NewDataNetworksClient().BeginCreateOrUpdate(ctx, "rg1", "testMobileNetwork", "testDataNetwork", armmobilenetwork.DataNetwork{ Location: to.Ptr("eastus"), Properties: &armmobilenetwork.DataNetworkPropertiesFormat{ Description: to.Ptr("myFavouriteDataNetwork"), @@ -81,22 +103,43 @@ func ExampleDataNetworksClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataNetwork = armmobilenetwork.DataNetwork{ + // Name: to.Ptr("testDataNetwork"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks/dataNetworks"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testDataNetwork"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.DataNetworkPropertiesFormat{ + // Description: to.Ptr("myFavouriteDataNetwork"), + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/DataNetworkUpdateTags.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/DataNetworkUpdateTags.json func ExampleDataNetworksClient_UpdateTags() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewDataNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.UpdateTags(ctx, "rg1", "testMobileNetwork", "testDataNetwork", armmobilenetwork.TagsObject{ + res, err := clientFactory.NewDataNetworksClient().UpdateTags(ctx, "rg1", "testMobileNetwork", "testDataNetwork", armmobilenetwork.TagsObject{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -105,30 +148,77 @@ func ExampleDataNetworksClient_UpdateTags() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataNetwork = armmobilenetwork.DataNetwork{ + // Name: to.Ptr("testDataNetwork"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks/dataNetworks"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testDataNetwork"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armmobilenetwork.DataNetworkPropertiesFormat{ + // Description: to.Ptr("myFavouriteDataNetwork"), + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/DataNetworkListByMobileNetwork.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/DataNetworkListByMobileNetwork.json func ExampleDataNetworksClient_NewListByMobileNetworkPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewDataNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByMobileNetworkPager("rg1", "testMobileNetwork", nil) + pager := clientFactory.NewDataNetworksClient().NewListByMobileNetworkPager("rg1", "testMobileNetwork", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DataNetworkListResult = armmobilenetwork.DataNetworkListResult{ + // Value: []*armmobilenetwork.DataNetwork{ + // { + // Name: to.Ptr("testDataNetwork"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks/dataNetworks"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testDataNetwork"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.DataNetworkPropertiesFormat{ + // Description: to.Ptr("myFavouriteDataNetwork"), + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/go.mod b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/go.mod index e94133eb9543..e30f99bd596c 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/go.mod +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mobilenetwork/armmo 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.2.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 // indirect - github.com/golang-jwt/jwt/v4 v4.4.2 // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/go.sum b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/go.sum index 8c0539b73123..8ba445a8c4da 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/go.sum +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/go.sum @@ -1,30 +1,31 @@ -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.2.0 h1:t/W5MYAuQy81cvM8VUNfRLzhtKpXhVUAN7Cd7KVbTyc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0/go.mod h1:NBanQUfSWiWn3QEpWDTCU0IjBECKOYvl2R8xdRtMtiM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.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.7.0 h1:VgSJlZH5u0k2qxSpqyghcFQKmvYckj46uymKK5XzkBM= -github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0/go.mod h1:BDJ5qMFKx9DugEg3+uQSDCdbYPr5s9vBTrL9P8TpqOU= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= 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/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= -github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -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/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/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/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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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-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= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/mobilenetworks_client.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/mobilenetworks_client.go index 988ac0f67f5c..152157f7492e 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/mobilenetworks_client.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/mobilenetworks_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,66 +24,59 @@ import ( // MobileNetworksClient contains the methods for the MobileNetworks group. // Don't use this type directly, use NewMobileNetworksClient() instead. type MobileNetworksClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewMobileNetworksClient creates a new instance of MobileNetworksClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewMobileNetworksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MobileNetworksClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".MobileNetworksClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &MobileNetworksClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a mobile network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// parameters - Parameters supplied to the create or update mobile network operation. -// options - MobileNetworksClientBeginCreateOrUpdateOptions contains the optional parameters for the MobileNetworksClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - parameters - Parameters supplied to the create or update mobile network operation. +// - options - MobileNetworksClientBeginCreateOrUpdateOptions contains the optional parameters for the MobileNetworksClient.BeginCreateOrUpdate +// method. func (client *MobileNetworksClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, mobileNetworkName string, parameters MobileNetwork, options *MobileNetworksClientBeginCreateOrUpdateOptions) (*runtime.Poller[MobileNetworksClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, mobileNetworkName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[MobileNetworksClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MobileNetworksClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[MobileNetworksClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[MobileNetworksClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a mobile network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *MobileNetworksClient) createOrUpdate(ctx context.Context, resourceGroupName string, mobileNetworkName string, parameters MobileNetwork, options *MobileNetworksClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, mobileNetworkName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -110,7 +101,7 @@ func (client *MobileNetworksClient) createOrUpdateCreateRequest(ctx context.Cont return nil, errors.New("parameter mobileNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{mobileNetworkName}", url.PathEscape(mobileNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -123,34 +114,36 @@ func (client *MobileNetworksClient) createOrUpdateCreateRequest(ctx context.Cont // BeginDelete - Deletes the specified mobile network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// options - MobileNetworksClientBeginDeleteOptions contains the optional parameters for the MobileNetworksClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - options - MobileNetworksClientBeginDeleteOptions contains the optional parameters for the MobileNetworksClient.BeginDelete +// method. func (client *MobileNetworksClient) BeginDelete(ctx context.Context, resourceGroupName string, mobileNetworkName string, options *MobileNetworksClientBeginDeleteOptions) (*runtime.Poller[MobileNetworksClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, mobileNetworkName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[MobileNetworksClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MobileNetworksClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[MobileNetworksClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[MobileNetworksClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the specified mobile network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *MobileNetworksClient) deleteOperation(ctx context.Context, resourceGroupName string, mobileNetworkName string, options *MobileNetworksClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, mobileNetworkName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -175,7 +168,7 @@ func (client *MobileNetworksClient) deleteCreateRequest(ctx context.Context, res return nil, errors.New("parameter mobileNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{mobileNetworkName}", url.PathEscape(mobileNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -188,16 +181,17 @@ func (client *MobileNetworksClient) deleteCreateRequest(ctx context.Context, res // Get - Gets information about the specified mobile network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// options - MobileNetworksClientGetOptions contains the optional parameters for the MobileNetworksClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - options - MobileNetworksClientGetOptions contains the optional parameters for the MobileNetworksClient.Get method. func (client *MobileNetworksClient) Get(ctx context.Context, resourceGroupName string, mobileNetworkName string, options *MobileNetworksClientGetOptions) (MobileNetworksClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, mobileNetworkName, options) if err != nil { return MobileNetworksClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MobileNetworksClientGetResponse{}, err } @@ -222,7 +216,7 @@ func (client *MobileNetworksClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter mobileNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{mobileNetworkName}", url.PathEscape(mobileNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -243,10 +237,11 @@ func (client *MobileNetworksClient) getHandleResponse(resp *http.Response) (Mobi } // NewListByResourceGroupPager - Lists all the mobile networks in a resource group. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - MobileNetworksClientListByResourceGroupOptions contains the optional parameters for the MobileNetworksClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - MobileNetworksClientListByResourceGroupOptions contains the optional parameters for the MobileNetworksClient.NewListByResourceGroupPager +// method. func (client *MobileNetworksClient) NewListByResourceGroupPager(resourceGroupName string, options *MobileNetworksClientListByResourceGroupOptions) *runtime.Pager[MobileNetworksClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[MobileNetworksClientListByResourceGroupResponse]{ More: func(page MobileNetworksClientListByResourceGroupResponse) bool { @@ -263,7 +258,7 @@ func (client *MobileNetworksClient) NewListByResourceGroupPager(resourceGroupNam if err != nil { return MobileNetworksClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MobileNetworksClientListByResourceGroupResponse{}, err } @@ -286,7 +281,7 @@ func (client *MobileNetworksClient) listByResourceGroupCreateRequest(ctx context return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -307,9 +302,10 @@ func (client *MobileNetworksClient) listByResourceGroupHandleResponse(resp *http } // NewListBySubscriptionPager - Lists all the mobile networks in a subscription. +// // Generated from API version 2022-11-01 -// options - MobileNetworksClientListBySubscriptionOptions contains the optional parameters for the MobileNetworksClient.ListBySubscription -// method. +// - options - MobileNetworksClientListBySubscriptionOptions contains the optional parameters for the MobileNetworksClient.NewListBySubscriptionPager +// method. func (client *MobileNetworksClient) NewListBySubscriptionPager(options *MobileNetworksClientListBySubscriptionOptions) *runtime.Pager[MobileNetworksClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[MobileNetworksClientListBySubscriptionResponse]{ More: func(page MobileNetworksClientListBySubscriptionResponse) bool { @@ -326,7 +322,7 @@ func (client *MobileNetworksClient) NewListBySubscriptionPager(options *MobileNe if err != nil { return MobileNetworksClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MobileNetworksClientListBySubscriptionResponse{}, err } @@ -345,7 +341,7 @@ func (client *MobileNetworksClient) listBySubscriptionCreateRequest(ctx context. return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -367,18 +363,19 @@ func (client *MobileNetworksClient) listBySubscriptionHandleResponse(resp *http. // UpdateTags - Updates mobile network tags. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// parameters - Parameters supplied to update mobile network tags. -// options - MobileNetworksClientUpdateTagsOptions contains the optional parameters for the MobileNetworksClient.UpdateTags -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - parameters - Parameters supplied to update mobile network tags. +// - options - MobileNetworksClientUpdateTagsOptions contains the optional parameters for the MobileNetworksClient.UpdateTags +// method. func (client *MobileNetworksClient) UpdateTags(ctx context.Context, resourceGroupName string, mobileNetworkName string, parameters TagsObject, options *MobileNetworksClientUpdateTagsOptions) (MobileNetworksClientUpdateTagsResponse, error) { req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, mobileNetworkName, parameters, options) if err != nil { return MobileNetworksClientUpdateTagsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MobileNetworksClientUpdateTagsResponse{}, err } @@ -403,7 +400,7 @@ func (client *MobileNetworksClient) updateTagsCreateRequest(ctx context.Context, return nil, errors.New("parameter mobileNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{mobileNetworkName}", url.PathEscape(mobileNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/mobilenetworks_client_example_test.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/mobilenetworks_client_example_test.go index f7ee26c00e24..a4abca09f4b5 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/mobilenetworks_client_example_test.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/mobilenetworks_client_example_test.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 armmobilenetwork_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mobilenetwork/armmobilenetwork/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkDelete.json func ExampleMobileNetworksClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewMobileNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rg1", "testMobileNetwork", nil) + poller, err := clientFactory.NewMobileNetworksClient().BeginDelete(ctx, "rg1", "testMobileNetwork", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -38,37 +39,61 @@ func ExampleMobileNetworksClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkGet.json func ExampleMobileNetworksClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewMobileNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rg1", "testMobileNetwork", nil) + res, err := clientFactory.NewMobileNetworksClient().Get(ctx, "rg1", "testMobileNetwork", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.MobileNetwork = armmobilenetwork.MobileNetwork{ + // Name: to.Ptr("testMobileNetwork"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.PropertiesFormat{ + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // PublicLandMobileNetworkIdentifier: &armmobilenetwork.PlmnID{ + // Mcc: to.Ptr("001"), + // Mnc: to.Ptr("01"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkCreate.json func ExampleMobileNetworksClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewMobileNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "testMobileNetwork", armmobilenetwork.MobileNetwork{ + poller, err := clientFactory.NewMobileNetworksClient().BeginCreateOrUpdate(ctx, "rg1", "testMobileNetwork", armmobilenetwork.MobileNetwork{ Location: to.Ptr("eastus"), Properties: &armmobilenetwork.PropertiesFormat{ PublicLandMobileNetworkIdentifier: &armmobilenetwork.PlmnID{ @@ -84,22 +109,46 @@ func ExampleMobileNetworksClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.MobileNetwork = armmobilenetwork.MobileNetwork{ + // Name: to.Ptr("testMobileNetwork"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.PropertiesFormat{ + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // PublicLandMobileNetworkIdentifier: &armmobilenetwork.PlmnID{ + // Mcc: to.Ptr("001"), + // Mnc: to.Ptr("01"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkUpdateTags.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkUpdateTags.json func ExampleMobileNetworksClient_UpdateTags() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewMobileNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.UpdateTags(ctx, "rg1", "testMobileNetwork", armmobilenetwork.TagsObject{ + res, err := clientFactory.NewMobileNetworksClient().UpdateTags(ctx, "rg1", "testMobileNetwork", armmobilenetwork.TagsObject{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -108,54 +157,134 @@ func ExampleMobileNetworksClient_UpdateTags() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.MobileNetwork = armmobilenetwork.MobileNetwork{ + // Name: to.Ptr("testMobileNetwork"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armmobilenetwork.PropertiesFormat{ + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // PublicLandMobileNetworkIdentifier: &armmobilenetwork.PlmnID{ + // Mcc: to.Ptr("001"), + // Mnc: to.Ptr("01"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkListBySubscription.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkListBySubscription.json func ExampleMobileNetworksClient_NewListBySubscriptionPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewMobileNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySubscriptionPager(nil) + pager := clientFactory.NewMobileNetworksClient().NewListBySubscriptionPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ListResult = armmobilenetwork.ListResult{ + // Value: []*armmobilenetwork.MobileNetwork{ + // { + // Name: to.Ptr("testMobileNetwork"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.PropertiesFormat{ + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // PublicLandMobileNetworkIdentifier: &armmobilenetwork.PlmnID{ + // Mcc: to.Ptr("001"), + // Mnc: to.Ptr("01"), + // }, + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkListByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkListByResourceGroup.json func ExampleMobileNetworksClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewMobileNetworksClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("rg1", nil) + pager := clientFactory.NewMobileNetworksClient().NewListByResourceGroupPager("rg1", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ListResult = armmobilenetwork.ListResult{ + // Value: []*armmobilenetwork.MobileNetwork{ + // { + // Name: to.Ptr("testMobileNetwork"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.PropertiesFormat{ + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // PublicLandMobileNetworkIdentifier: &armmobilenetwork.PlmnID{ + // Mcc: to.Ptr("001"), + // Mnc: to.Ptr("01"), + // }, + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/models.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/models.go index c75db830698e..b8c7c5178289 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/models.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/models.go @@ -59,7 +59,7 @@ type AsyncOperationStatus struct { PercentComplete *float64 `json:"percentComplete,omitempty"` // Properties returned by the resource provider on a successful operation - Properties interface{} `json:"properties,omitempty"` + Properties any `json:"properties,omitempty"` // Fully qualified ID for the resource that this async operation status relates to. ResourceID *string `json:"resourceId,omitempty"` @@ -159,7 +159,7 @@ type AttachedDataNetworksClientGetOptions struct { // placeholder for future optional parameters } -// AttachedDataNetworksClientListByPacketCoreDataPlaneOptions contains the optional parameters for the AttachedDataNetworksClient.ListByPacketCoreDataPlane +// AttachedDataNetworksClientListByPacketCoreDataPlaneOptions contains the optional parameters for the AttachedDataNetworksClient.NewListByPacketCoreDataPlanePager // method. type AttachedDataNetworksClientListByPacketCoreDataPlaneOptions struct { // placeholder for future optional parameters @@ -355,7 +355,7 @@ type DataNetworksClientGetOptions struct { // placeholder for future optional parameters } -// DataNetworksClientListByMobileNetworkOptions contains the optional parameters for the DataNetworksClient.ListByMobileNetwork +// DataNetworksClientListByMobileNetworkOptions contains the optional parameters for the DataNetworksClient.NewListByMobileNetworkPager // method. type DataNetworksClientListByMobileNetworkOptions struct { // placeholder for future optional parameters @@ -430,7 +430,7 @@ type EncryptedSimUploadList struct { // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty" azure:"ro"` + Info any `json:"info,omitempty" azure:"ro"` // READ-ONLY; The additional info type. Type *string `json:"type,omitempty" azure:"ro"` @@ -581,13 +581,13 @@ type MobileNetworksClientGetOptions struct { // placeholder for future optional parameters } -// MobileNetworksClientListByResourceGroupOptions contains the optional parameters for the MobileNetworksClient.ListByResourceGroup +// MobileNetworksClientListByResourceGroupOptions contains the optional parameters for the MobileNetworksClient.NewListByResourceGroupPager // method. type MobileNetworksClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// MobileNetworksClientListBySubscriptionOptions contains the optional parameters for the MobileNetworksClient.ListBySubscription +// MobileNetworksClientListBySubscriptionOptions contains the optional parameters for the MobileNetworksClient.NewListBySubscriptionPager // method. type MobileNetworksClientListBySubscriptionOptions struct { // placeholder for future optional parameters @@ -656,7 +656,7 @@ type OperationList struct { Value []*Operation `json:"value,omitempty" azure:"ro"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -726,7 +726,7 @@ type PacketCoreControlPlanePropertiesFormat struct { CoreNetworkTechnology *CoreNetworkType `json:"coreNetworkTechnology,omitempty"` // Settings to allow interoperability with third party components e.g. RANs and UEs. - InteropSettings interface{} `json:"interopSettings,omitempty"` + InteropSettings any `json:"interopSettings,omitempty"` // The MTU (in bytes) signaled to the UE. The same MTU is set on the user plane data links for all data networks. The MTU // set on the user plane access link is calculated to be 60 bytes greater than this @@ -788,7 +788,7 @@ type PacketCoreControlPlaneVersionsClientGetOptions struct { // placeholder for future optional parameters } -// PacketCoreControlPlaneVersionsClientListOptions contains the optional parameters for the PacketCoreControlPlaneVersionsClient.List +// PacketCoreControlPlaneVersionsClientListOptions contains the optional parameters for the PacketCoreControlPlaneVersionsClient.NewListPager // method. type PacketCoreControlPlaneVersionsClientListOptions struct { // placeholder for future optional parameters @@ -834,13 +834,13 @@ type PacketCoreControlPlanesClientGetOptions struct { // placeholder for future optional parameters } -// PacketCoreControlPlanesClientListByResourceGroupOptions contains the optional parameters for the PacketCoreControlPlanesClient.ListByResourceGroup +// PacketCoreControlPlanesClientListByResourceGroupOptions contains the optional parameters for the PacketCoreControlPlanesClient.NewListByResourceGroupPager // method. type PacketCoreControlPlanesClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// PacketCoreControlPlanesClientListBySubscriptionOptions contains the optional parameters for the PacketCoreControlPlanesClient.ListBySubscription +// PacketCoreControlPlanesClientListBySubscriptionOptions contains the optional parameters for the PacketCoreControlPlanesClient.NewListBySubscriptionPager // method. type PacketCoreControlPlanesClientListBySubscriptionOptions struct { // placeholder for future optional parameters @@ -915,7 +915,7 @@ type PacketCoreDataPlanesClientGetOptions struct { // placeholder for future optional parameters } -// PacketCoreDataPlanesClientListByPacketCoreControlPlaneOptions contains the optional parameters for the PacketCoreDataPlanesClient.ListByPacketCoreControlPlane +// PacketCoreDataPlanesClientListByPacketCoreControlPlaneOptions contains the optional parameters for the PacketCoreDataPlanesClient.NewListByPacketCoreControlPlanePager // method. type PacketCoreDataPlanesClientListByPacketCoreControlPlaneOptions struct { // placeholder for future optional parameters @@ -1255,7 +1255,8 @@ type ServicesClientGetOptions struct { // placeholder for future optional parameters } -// ServicesClientListByMobileNetworkOptions contains the optional parameters for the ServicesClient.ListByMobileNetwork method. +// ServicesClientListByMobileNetworkOptions contains the optional parameters for the ServicesClient.NewListByMobileNetworkPager +// method. type ServicesClientListByMobileNetworkOptions struct { // placeholder for future optional parameters } @@ -1361,13 +1362,14 @@ type SimGroupsClientGetOptions struct { // placeholder for future optional parameters } -// SimGroupsClientListByResourceGroupOptions contains the optional parameters for the SimGroupsClient.ListByResourceGroup +// SimGroupsClientListByResourceGroupOptions contains the optional parameters for the SimGroupsClient.NewListByResourceGroupPager // method. type SimGroupsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// SimGroupsClientListBySubscriptionOptions contains the optional parameters for the SimGroupsClient.ListBySubscription method. +// SimGroupsClientListBySubscriptionOptions contains the optional parameters for the SimGroupsClient.NewListBySubscriptionPager +// method. type SimGroupsClientListBySubscriptionOptions struct { // placeholder for future optional parameters } @@ -1422,7 +1424,7 @@ type SimPoliciesClientGetOptions struct { // placeholder for future optional parameters } -// SimPoliciesClientListByMobileNetworkOptions contains the optional parameters for the SimPoliciesClient.ListByMobileNetwork +// SimPoliciesClientListByMobileNetworkOptions contains the optional parameters for the SimPoliciesClient.NewListByMobileNetworkPager // method. type SimPoliciesClientListByMobileNetworkOptions struct { // placeholder for future optional parameters @@ -1606,7 +1608,7 @@ type SimsClientGetOptions struct { // placeholder for future optional parameters } -// SimsClientListByGroupOptions contains the optional parameters for the SimsClient.ListByGroup method. +// SimsClientListByGroupOptions contains the optional parameters for the SimsClient.NewListByGroupPager method. type SimsClientListByGroupOptions struct { // placeholder for future optional parameters } @@ -1677,7 +1679,8 @@ type SitesClientGetOptions struct { // placeholder for future optional parameters } -// SitesClientListByMobileNetworkOptions contains the optional parameters for the SitesClient.ListByMobileNetwork method. +// SitesClientListByMobileNetworkOptions contains the optional parameters for the SitesClient.NewListByMobileNetworkPager +// method. type SitesClientListByMobileNetworkOptions struct { // placeholder for future optional parameters } @@ -1770,7 +1773,8 @@ type SlicesClientGetOptions struct { // placeholder for future optional parameters } -// SlicesClientListByMobileNetworkOptions contains the optional parameters for the SlicesClient.ListByMobileNetwork method. +// SlicesClientListByMobileNetworkOptions contains the optional parameters for the SlicesClient.NewListByMobileNetworkPager +// method. type SlicesClientListByMobileNetworkOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/models_serde.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/models_serde.go index cc1f9f371b1c..93d93e71648e 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/models_serde.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type Ambr. func (a Ambr) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "downlink", a.Downlink) populate(objectMap, "uplink", a.Uplink) return json.Marshal(objectMap) @@ -49,7 +49,7 @@ func (a *Ambr) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Arp. func (a Arp) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "preemptCap", a.PreemptCap) populate(objectMap, "preemptVuln", a.PreemptVuln) populate(objectMap, "priorityLevel", a.PriorityLevel) @@ -84,7 +84,7 @@ func (a *Arp) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AsyncOperationID. func (a AsyncOperationID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) return json.Marshal(objectMap) } @@ -111,7 +111,7 @@ func (a *AsyncOperationID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AsyncOperationStatus. func (a AsyncOperationStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "endTime", a.EndTime) populate(objectMap, "error", a.Error) populate(objectMap, "id", a.ID) @@ -170,7 +170,7 @@ func (a *AsyncOperationStatus) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AttachedDataNetwork. func (a AttachedDataNetwork) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "location", a.Location) populate(objectMap, "name", a.Name) @@ -221,7 +221,7 @@ func (a *AttachedDataNetwork) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AttachedDataNetworkListResult. func (a AttachedDataNetworkListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -252,7 +252,7 @@ func (a *AttachedDataNetworkListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AttachedDataNetworkPropertiesFormat. func (a AttachedDataNetworkPropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "dnsAddresses", a.DNSAddresses) populate(objectMap, "naptConfiguration", a.NaptConfiguration) populate(objectMap, "provisioningState", a.ProvisioningState) @@ -299,7 +299,7 @@ func (a *AttachedDataNetworkPropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AttachedDataNetworkResourceID. func (a AttachedDataNetworkResourceID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) return json.Marshal(objectMap) } @@ -326,7 +326,7 @@ func (a *AttachedDataNetworkResourceID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AzureStackEdgeDeviceResourceID. func (a AzureStackEdgeDeviceResourceID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) return json.Marshal(objectMap) } @@ -353,7 +353,7 @@ func (a *AzureStackEdgeDeviceResourceID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AzureStackHCIClusterResourceID. func (a AzureStackHCIClusterResourceID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) return json.Marshal(objectMap) } @@ -380,7 +380,7 @@ func (a *AzureStackHCIClusterResourceID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CertificateProvisioning. func (c CertificateProvisioning) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "reason", c.Reason) populate(objectMap, "state", c.State) return json.Marshal(objectMap) @@ -411,7 +411,7 @@ func (c *CertificateProvisioning) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CommonSimPropertiesFormat. func (c CommonSimPropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "deviceType", c.DeviceType) populate(objectMap, "integratedCircuitCardIdentifier", c.IntegratedCircuitCardIdentifier) populate(objectMap, "internationalMobileSubscriberIdentity", c.InternationalMobileSubscriberIdentity) @@ -474,7 +474,7 @@ func (c *CommonSimPropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectedClusterResourceID. func (c ConnectedClusterResourceID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) return json.Marshal(objectMap) } @@ -501,7 +501,7 @@ func (c *ConnectedClusterResourceID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CustomLocationResourceID. func (c CustomLocationResourceID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) return json.Marshal(objectMap) } @@ -528,7 +528,7 @@ func (c *CustomLocationResourceID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DataNetwork. func (d DataNetwork) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", d.ID) populate(objectMap, "location", d.Location) populate(objectMap, "name", d.Name) @@ -579,7 +579,7 @@ func (d *DataNetwork) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DataNetworkConfiguration. func (d DataNetworkConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "additionalAllowedSessionTypes", d.AdditionalAllowedSessionTypes) populate(objectMap, "allocationAndRetentionPriorityLevel", d.AllocationAndRetentionPriorityLevel) populate(objectMap, "allowedServices", d.AllowedServices) @@ -642,7 +642,7 @@ func (d *DataNetworkConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DataNetworkListResult. func (d DataNetworkListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", d.NextLink) populate(objectMap, "value", d.Value) return json.Marshal(objectMap) @@ -673,7 +673,7 @@ func (d *DataNetworkListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DataNetworkPropertiesFormat. func (d DataNetworkPropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", d.Description) populate(objectMap, "provisioningState", d.ProvisioningState) return json.Marshal(objectMap) @@ -704,7 +704,7 @@ func (d *DataNetworkPropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DataNetworkResourceID. func (d DataNetworkResourceID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", d.ID) return json.Marshal(objectMap) } @@ -731,7 +731,7 @@ func (d *DataNetworkResourceID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EncryptedSimPropertiesFormat. func (e EncryptedSimPropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "deviceType", e.DeviceType) populate(objectMap, "encryptedCredentials", e.EncryptedCredentials) populate(objectMap, "integratedCircuitCardIdentifier", e.IntegratedCircuitCardIdentifier) @@ -798,7 +798,7 @@ func (e *EncryptedSimPropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EncryptedSimUploadList. func (e EncryptedSimUploadList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "azureKeyIdentifier", e.AzureKeyIdentifier) populate(objectMap, "encryptedTransportKey", e.EncryptedTransportKey) populate(objectMap, "signedTransportKey", e.SignedTransportKey) @@ -845,7 +845,7 @@ func (e *EncryptedSimUploadList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "info", &e.Info) populate(objectMap, "type", e.Type) return json.Marshal(objectMap) @@ -876,7 +876,7 @@ func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorDetail. func (e ErrorDetail) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "additionalInfo", e.AdditionalInfo) populate(objectMap, "code", e.Code) populate(objectMap, "details", e.Details) @@ -919,7 +919,7 @@ func (e *ErrorDetail) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorResponse. func (e ErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "error", e.Error) return json.Marshal(objectMap) } @@ -946,7 +946,7 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HTTPSServerCertificate. func (h HTTPSServerCertificate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "certificateUrl", h.CertificateURL) populate(objectMap, "provisioning", h.Provisioning) return json.Marshal(objectMap) @@ -977,7 +977,7 @@ func (h *HTTPSServerCertificate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Installation. func (i Installation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "operation", i.Operation) populate(objectMap, "state", i.State) return json.Marshal(objectMap) @@ -1008,7 +1008,7 @@ func (i *Installation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InterfaceProperties. func (i InterfaceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "ipv4Address", i.IPv4Address) populate(objectMap, "ipv4Gateway", i.IPv4Gateway) populate(objectMap, "ipv4Subnet", i.IPv4Subnet) @@ -1047,7 +1047,7 @@ func (i *InterfaceProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type KeyVaultKey. func (k KeyVaultKey) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "keyUrl", k.KeyURL) return json.Marshal(objectMap) } @@ -1074,7 +1074,7 @@ func (k *KeyVaultKey) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ListResult. func (l ListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", l.NextLink) populate(objectMap, "value", l.Value) return json.Marshal(objectMap) @@ -1105,7 +1105,7 @@ func (l *ListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LocalDiagnosticsAccessConfiguration. func (l LocalDiagnosticsAccessConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "authenticationType", l.AuthenticationType) populate(objectMap, "httpsServerCertificate", l.HTTPSServerCertificate) return json.Marshal(objectMap) @@ -1136,7 +1136,7 @@ func (l *LocalDiagnosticsAccessConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentity. func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "principalId", m.PrincipalID) populate(objectMap, "tenantId", m.TenantID) populate(objectMap, "type", m.Type) @@ -1175,7 +1175,7 @@ func (m *ManagedServiceIdentity) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MobileNetwork. func (m MobileNetwork) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", m.ID) populate(objectMap, "location", m.Location) populate(objectMap, "name", m.Name) @@ -1226,7 +1226,7 @@ func (m *MobileNetwork) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type NaptConfiguration. func (n NaptConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "enabled", n.Enabled) populate(objectMap, "pinholeLimits", n.PinholeLimits) populate(objectMap, "pinholeTimeouts", n.PinholeTimeouts) @@ -1269,7 +1269,7 @@ func (n *NaptConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "display", o.Display) populate(objectMap, "isDataAction", o.IsDataAction) populate(objectMap, "name", o.Name) @@ -1304,7 +1304,7 @@ func (o *Operation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -1343,7 +1343,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationList. func (o OperationList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -1374,7 +1374,7 @@ func (o *OperationList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PacketCoreControlPlane. func (p PacketCoreControlPlane) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "identity", p.Identity) populate(objectMap, "location", p.Location) @@ -1429,7 +1429,7 @@ func (p *PacketCoreControlPlane) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PacketCoreControlPlaneCollectDiagnosticsPackage. func (p PacketCoreControlPlaneCollectDiagnosticsPackage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "storageAccountBlobUrl", p.StorageAccountBlobURL) return json.Marshal(objectMap) } @@ -1456,7 +1456,7 @@ func (p *PacketCoreControlPlaneCollectDiagnosticsPackage) UnmarshalJSON(data []b // MarshalJSON implements the json.Marshaller interface for type PacketCoreControlPlaneListResult. func (p PacketCoreControlPlaneListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", p.NextLink) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) @@ -1487,7 +1487,7 @@ func (p *PacketCoreControlPlaneListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PacketCoreControlPlanePropertiesFormat. func (p PacketCoreControlPlanePropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "controlPlaneAccessInterface", p.ControlPlaneAccessInterface) populate(objectMap, "coreNetworkTechnology", p.CoreNetworkTechnology) populate(objectMap, "installation", p.Installation) @@ -1558,7 +1558,7 @@ func (p *PacketCoreControlPlanePropertiesFormat) UnmarshalJSON(data []byte) erro // MarshalJSON implements the json.Marshaller interface for type PacketCoreControlPlaneVersion. func (p PacketCoreControlPlaneVersion) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) populate(objectMap, "properties", p.Properties) @@ -1601,7 +1601,7 @@ func (p *PacketCoreControlPlaneVersion) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PacketCoreControlPlaneVersionListResult. func (p PacketCoreControlPlaneVersionListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", p.NextLink) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) @@ -1632,7 +1632,7 @@ func (p *PacketCoreControlPlaneVersionListResult) UnmarshalJSON(data []byte) err // MarshalJSON implements the json.Marshaller interface for type PacketCoreControlPlaneVersionPropertiesFormat. func (p PacketCoreControlPlaneVersionPropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "platforms", p.Platforms) populate(objectMap, "provisioningState", p.ProvisioningState) return json.Marshal(objectMap) @@ -1663,7 +1663,7 @@ func (p *PacketCoreControlPlaneVersionPropertiesFormat) UnmarshalJSON(data []byt // MarshalJSON implements the json.Marshaller interface for type PacketCoreDataPlane. func (p PacketCoreDataPlane) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "location", p.Location) populate(objectMap, "name", p.Name) @@ -1714,7 +1714,7 @@ func (p *PacketCoreDataPlane) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PacketCoreDataPlaneListResult. func (p PacketCoreDataPlaneListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", p.NextLink) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) @@ -1745,7 +1745,7 @@ func (p *PacketCoreDataPlaneListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PacketCoreDataPlanePropertiesFormat. func (p PacketCoreDataPlanePropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "provisioningState", p.ProvisioningState) populate(objectMap, "userPlaneAccessInterface", p.UserPlaneAccessInterface) return json.Marshal(objectMap) @@ -1776,7 +1776,7 @@ func (p *PacketCoreDataPlanePropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PccRuleConfiguration. func (p PccRuleConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "ruleName", p.RuleName) populate(objectMap, "rulePrecedence", p.RulePrecedence) populate(objectMap, "ruleQosPolicy", p.RuleQosPolicy) @@ -1819,7 +1819,7 @@ func (p *PccRuleConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PccRuleQosPolicy. func (p PccRuleQosPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allocationAndRetentionPriorityLevel", p.AllocationAndRetentionPriorityLevel) populate(objectMap, "5qi", p.FiveQi) populate(objectMap, "guaranteedBitRate", p.GuaranteedBitRate) @@ -1866,7 +1866,7 @@ func (p *PccRuleQosPolicy) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PinholeTimeouts. func (p PinholeTimeouts) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "icmp", p.Icmp) populate(objectMap, "tcp", p.TCP) populate(objectMap, "udp", p.UDP) @@ -1901,7 +1901,7 @@ func (p *PinholeTimeouts) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Platform. func (p Platform) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "maximumPlatformSoftwareVersion", p.MaximumPlatformSoftwareVersion) populate(objectMap, "minimumPlatformSoftwareVersion", p.MinimumPlatformSoftwareVersion) populate(objectMap, "obsoleteVersion", p.ObsoleteVersion) @@ -1948,7 +1948,7 @@ func (p *Platform) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PlatformConfiguration. func (p PlatformConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "azureStackEdgeDevice", p.AzureStackEdgeDevice) populate(objectMap, "azureStackEdgeDevices", p.AzureStackEdgeDevices) populate(objectMap, "azureStackHciCluster", p.AzureStackHciCluster) @@ -1995,7 +1995,7 @@ func (p *PlatformConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PlmnID. func (p PlmnID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "mcc", p.Mcc) populate(objectMap, "mnc", p.Mnc) return json.Marshal(objectMap) @@ -2026,7 +2026,7 @@ func (p *PlmnID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PortRange. func (p PortRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "maxPort", p.MaxPort) populate(objectMap, "minPort", p.MinPort) return json.Marshal(objectMap) @@ -2057,7 +2057,7 @@ func (p *PortRange) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PortReuseHoldTimes. func (p PortReuseHoldTimes) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "tcp", p.TCP) populate(objectMap, "udp", p.UDP) return json.Marshal(objectMap) @@ -2088,7 +2088,7 @@ func (p *PortReuseHoldTimes) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PropertiesFormat. func (p PropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "provisioningState", p.ProvisioningState) populate(objectMap, "publicLandMobileNetworkIdentifier", p.PublicLandMobileNetworkIdentifier) populate(objectMap, "serviceKey", p.ServiceKey) @@ -2123,7 +2123,7 @@ func (p *PropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ProxyResource. func (p ProxyResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) populate(objectMap, "systemData", p.SystemData) @@ -2162,7 +2162,7 @@ func (p *ProxyResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type QosPolicy. func (q QosPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allocationAndRetentionPriorityLevel", q.AllocationAndRetentionPriorityLevel) populate(objectMap, "5qi", q.FiveQi) populate(objectMap, "maximumBitRate", q.MaximumBitRate) @@ -2205,7 +2205,7 @@ func (q *QosPolicy) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "systemData", r.SystemData) @@ -2244,7 +2244,7 @@ func (r *Resource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceID. func (r ResourceID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) return json.Marshal(objectMap) } @@ -2271,7 +2271,7 @@ func (r *ResourceID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Service. func (s Service) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "location", s.Location) populate(objectMap, "name", s.Name) @@ -2322,7 +2322,7 @@ func (s *Service) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServiceDataFlowTemplate. func (s ServiceDataFlowTemplate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "direction", s.Direction) populate(objectMap, "ports", s.Ports) populate(objectMap, "protocol", s.Protocol) @@ -2365,7 +2365,7 @@ func (s *ServiceDataFlowTemplate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServiceListResult. func (s ServiceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -2396,7 +2396,7 @@ func (s *ServiceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServicePropertiesFormat. func (s ServicePropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "pccRules", s.PccRules) populate(objectMap, "provisioningState", s.ProvisioningState) populate(objectMap, "servicePrecedence", s.ServicePrecedence) @@ -2435,7 +2435,7 @@ func (s *ServicePropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServiceResourceID. func (s ServiceResourceID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) return json.Marshal(objectMap) } @@ -2462,7 +2462,7 @@ func (s *ServiceResourceID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Sim. func (s Sim) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -2505,7 +2505,7 @@ func (s *Sim) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimDeleteList. func (s SimDeleteList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "sims", s.Sims) return json.Marshal(objectMap) } @@ -2532,7 +2532,7 @@ func (s *SimDeleteList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimGroup. func (s SimGroup) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "identity", s.Identity) populate(objectMap, "location", s.Location) @@ -2587,7 +2587,7 @@ func (s *SimGroup) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimGroupListResult. func (s SimGroupListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -2618,7 +2618,7 @@ func (s *SimGroupListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimGroupPropertiesFormat. func (s SimGroupPropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "encryptionKey", s.EncryptionKey) populate(objectMap, "mobileNetwork", s.MobileNetwork) populate(objectMap, "provisioningState", s.ProvisioningState) @@ -2653,7 +2653,7 @@ func (s *SimGroupPropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimGroupResourceID. func (s SimGroupResourceID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) return json.Marshal(objectMap) } @@ -2680,7 +2680,7 @@ func (s *SimGroupResourceID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimListResult. func (s SimListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -2711,7 +2711,7 @@ func (s *SimListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimNameAndEncryptedProperties. func (s SimNameAndEncryptedProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) return json.Marshal(objectMap) @@ -2742,7 +2742,7 @@ func (s *SimNameAndEncryptedProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimNameAndProperties. func (s SimNameAndProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) return json.Marshal(objectMap) @@ -2773,7 +2773,7 @@ func (s *SimNameAndProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimPolicy. func (s SimPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "location", s.Location) populate(objectMap, "name", s.Name) @@ -2824,7 +2824,7 @@ func (s *SimPolicy) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimPolicyListResult. func (s SimPolicyListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -2855,7 +2855,7 @@ func (s *SimPolicyListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimPolicyPropertiesFormat. func (s SimPolicyPropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "defaultSlice", s.DefaultSlice) populate(objectMap, "provisioningState", s.ProvisioningState) populate(objectMap, "registrationTimer", s.RegistrationTimer) @@ -2906,7 +2906,7 @@ func (s *SimPolicyPropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimPolicyResourceID. func (s SimPolicyResourceID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) return json.Marshal(objectMap) } @@ -2933,7 +2933,7 @@ func (s *SimPolicyResourceID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimPropertiesFormat. func (s SimPropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "authenticationKey", s.AuthenticationKey) populate(objectMap, "deviceType", s.DeviceType) populate(objectMap, "integratedCircuitCardIdentifier", s.IntegratedCircuitCardIdentifier) @@ -3004,7 +3004,7 @@ func (s *SimPropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimStaticIPProperties. func (s SimStaticIPProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "attachedDataNetwork", s.AttachedDataNetwork) populate(objectMap, "slice", s.Slice) populate(objectMap, "staticIp", s.StaticIP) @@ -3039,7 +3039,7 @@ func (s *SimStaticIPProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimStaticIPPropertiesStaticIP. func (s SimStaticIPPropertiesStaticIP) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "ipv4Address", s.IPv4Address) return json.Marshal(objectMap) } @@ -3066,7 +3066,7 @@ func (s *SimStaticIPPropertiesStaticIP) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SimUploadList. func (s SimUploadList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "sims", s.Sims) return json.Marshal(objectMap) } @@ -3093,7 +3093,7 @@ func (s *SimUploadList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Site. func (s Site) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "location", s.Location) populate(objectMap, "name", s.Name) @@ -3144,7 +3144,7 @@ func (s *Site) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SiteListResult. func (s SiteListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -3175,7 +3175,7 @@ func (s *SiteListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SitePropertiesFormat. func (s SitePropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "networkFunctions", s.NetworkFunctions) populate(objectMap, "provisioningState", s.ProvisioningState) return json.Marshal(objectMap) @@ -3206,7 +3206,7 @@ func (s *SitePropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SiteResourceID. func (s SiteResourceID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) return json.Marshal(objectMap) } @@ -3233,7 +3233,7 @@ func (s *SiteResourceID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Slice. func (s Slice) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "location", s.Location) populate(objectMap, "name", s.Name) @@ -3284,7 +3284,7 @@ func (s *Slice) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SliceConfiguration. func (s SliceConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "dataNetworkConfigurations", s.DataNetworkConfigurations) populate(objectMap, "defaultDataNetwork", s.DefaultDataNetwork) populate(objectMap, "slice", s.Slice) @@ -3319,7 +3319,7 @@ func (s *SliceConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SliceListResult. func (s SliceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -3350,7 +3350,7 @@ func (s *SliceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SlicePropertiesFormat. func (s SlicePropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", s.Description) populate(objectMap, "provisioningState", s.ProvisioningState) populate(objectMap, "snssai", s.Snssai) @@ -3385,7 +3385,7 @@ func (s *SlicePropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SliceResourceID. func (s SliceResourceID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) return json.Marshal(objectMap) } @@ -3412,7 +3412,7 @@ func (s *SliceResourceID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Snssai. func (s Snssai) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "sd", s.Sd) populate(objectMap, "sst", s.Sst) return json.Marshal(objectMap) @@ -3443,7 +3443,7 @@ func (s *Snssai) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SubResource. func (s SubResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) return json.Marshal(objectMap) } @@ -3470,7 +3470,7 @@ func (s *SubResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -3517,7 +3517,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TagsObject. func (t TagsObject) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "tags", t.Tags) return json.Marshal(objectMap) } @@ -3544,7 +3544,7 @@ func (t *TagsObject) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrackedResource. func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "location", t.Location) populate(objectMap, "name", t.Name) @@ -3591,7 +3591,7 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentity. func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "clientId", u.ClientID) populate(objectMap, "principalId", u.PrincipalID) return json.Marshal(objectMap) @@ -3620,7 +3620,7 @@ func (u *UserAssignedIdentity) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -3630,7 +3630,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/operations_client.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/operations_client.go index 5f2c8eb2b047..62e0741e05a7 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/operations_client.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/operations_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,35 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Gets a list of the operations. +// // Generated from API version 2022-11-01 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -68,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -83,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.MobileNetwork/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/operations_client_example_test.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/operations_client_example_test.go index 3607db7dd4a6..8725eb34c93c 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/operations_client_example_test.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/operations_client_example_test.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 armmobilenetwork_test @@ -16,26 +17,40 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mobilenetwork/armmobilenetwork/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/OperationList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/OperationList.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 := armmobilenetwork.NewOperationsClient(cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewOperationsClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationList = armmobilenetwork.OperationList{ + // Value: []*armmobilenetwork.Operation{ + // { + // Name: to.Ptr("Microsoft.MobileNetwork/mobileNetworks/read"), + // Display: &armmobilenetwork.OperationDisplay{ + // Description: to.Ptr("Gets mobileNetwork"), + // Operation: to.Ptr("Get mobileNetwork"), + // Provider: to.Ptr("Microsoft.MobileNetwok"), + // Resource: to.Ptr("MobileNetwork"), + // }, + // IsDataAction: to.Ptr(false), + // }}, + // } } } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplanes_client.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplanes_client.go index 381111801170..63bde132f049 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplanes_client.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplanes_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,31 +24,22 @@ import ( // PacketCoreControlPlanesClient contains the methods for the PacketCoreControlPlanes group. // Don't use this type directly, use NewPacketCoreControlPlanesClient() instead. type PacketCoreControlPlanesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPacketCoreControlPlanesClient creates a new instance of PacketCoreControlPlanesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPacketCoreControlPlanesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PacketCoreControlPlanesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PacketCoreControlPlanesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PacketCoreControlPlanesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,36 +47,38 @@ func NewPacketCoreControlPlanesClient(subscriptionID string, credential azcore.T // BeginCollectDiagnosticsPackage - Collect a diagnostics package for the specified packet core control plane. This action // will upload the diagnostics to a storage account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// parameters - Parameters supplied to the packet core control plane collect diagnostics package operation. -// options - PacketCoreControlPlanesClientBeginCollectDiagnosticsPackageOptions contains the optional parameters for the PacketCoreControlPlanesClient.BeginCollectDiagnosticsPackage -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - parameters - Parameters supplied to the packet core control plane collect diagnostics package operation. +// - options - PacketCoreControlPlanesClientBeginCollectDiagnosticsPackageOptions contains the optional parameters for the PacketCoreControlPlanesClient.BeginCollectDiagnosticsPackage +// method. func (client *PacketCoreControlPlanesClient) BeginCollectDiagnosticsPackage(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, parameters PacketCoreControlPlaneCollectDiagnosticsPackage, options *PacketCoreControlPlanesClientBeginCollectDiagnosticsPackageOptions) (*runtime.Poller[PacketCoreControlPlanesClientCollectDiagnosticsPackageResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.collectDiagnosticsPackage(ctx, resourceGroupName, packetCoreControlPlaneName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PacketCoreControlPlanesClientCollectDiagnosticsPackageResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PacketCoreControlPlanesClientCollectDiagnosticsPackageResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[PacketCoreControlPlanesClientCollectDiagnosticsPackageResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PacketCoreControlPlanesClientCollectDiagnosticsPackageResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CollectDiagnosticsPackage - Collect a diagnostics package for the specified packet core control plane. This action will // upload the diagnostics to a storage account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *PacketCoreControlPlanesClient) collectDiagnosticsPackage(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, parameters PacketCoreControlPlaneCollectDiagnosticsPackage, options *PacketCoreControlPlanesClientBeginCollectDiagnosticsPackageOptions) (*http.Response, error) { req, err := client.collectDiagnosticsPackageCreateRequest(ctx, resourceGroupName, packetCoreControlPlaneName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -112,7 +103,7 @@ func (client *PacketCoreControlPlanesClient) collectDiagnosticsPackageCreateRequ return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -125,35 +116,37 @@ func (client *PacketCoreControlPlanesClient) collectDiagnosticsPackageCreateRequ // BeginCreateOrUpdate - Creates or updates a packet core control plane. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// parameters - Parameters supplied to the create or update packet core control plane operation. -// options - PacketCoreControlPlanesClientBeginCreateOrUpdateOptions contains the optional parameters for the PacketCoreControlPlanesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - parameters - Parameters supplied to the create or update packet core control plane operation. +// - options - PacketCoreControlPlanesClientBeginCreateOrUpdateOptions contains the optional parameters for the PacketCoreControlPlanesClient.BeginCreateOrUpdate +// method. func (client *PacketCoreControlPlanesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, parameters PacketCoreControlPlane, options *PacketCoreControlPlanesClientBeginCreateOrUpdateOptions) (*runtime.Poller[PacketCoreControlPlanesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, packetCoreControlPlaneName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PacketCoreControlPlanesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PacketCoreControlPlanesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[PacketCoreControlPlanesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PacketCoreControlPlanesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a packet core control plane. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *PacketCoreControlPlanesClient) createOrUpdate(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, parameters PacketCoreControlPlane, options *PacketCoreControlPlanesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, packetCoreControlPlaneName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -178,7 +171,7 @@ func (client *PacketCoreControlPlanesClient) createOrUpdateCreateRequest(ctx con return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -191,34 +184,36 @@ func (client *PacketCoreControlPlanesClient) createOrUpdateCreateRequest(ctx con // BeginDelete - Deletes the specified packet core control plane. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// options - PacketCoreControlPlanesClientBeginDeleteOptions contains the optional parameters for the PacketCoreControlPlanesClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - options - PacketCoreControlPlanesClientBeginDeleteOptions contains the optional parameters for the PacketCoreControlPlanesClient.BeginDelete +// method. func (client *PacketCoreControlPlanesClient) BeginDelete(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, options *PacketCoreControlPlanesClientBeginDeleteOptions) (*runtime.Poller[PacketCoreControlPlanesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, packetCoreControlPlaneName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PacketCoreControlPlanesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PacketCoreControlPlanesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[PacketCoreControlPlanesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PacketCoreControlPlanesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the specified packet core control plane. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *PacketCoreControlPlanesClient) deleteOperation(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, options *PacketCoreControlPlanesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, packetCoreControlPlaneName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -243,7 +238,7 @@ func (client *PacketCoreControlPlanesClient) deleteCreateRequest(ctx context.Con return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -256,17 +251,18 @@ func (client *PacketCoreControlPlanesClient) deleteCreateRequest(ctx context.Con // Get - Gets information about the specified packet core control plane. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// options - PacketCoreControlPlanesClientGetOptions contains the optional parameters for the PacketCoreControlPlanesClient.Get -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - options - PacketCoreControlPlanesClientGetOptions contains the optional parameters for the PacketCoreControlPlanesClient.Get +// method. func (client *PacketCoreControlPlanesClient) Get(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, options *PacketCoreControlPlanesClientGetOptions) (PacketCoreControlPlanesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, packetCoreControlPlaneName, options) if err != nil { return PacketCoreControlPlanesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PacketCoreControlPlanesClientGetResponse{}, err } @@ -291,7 +287,7 @@ func (client *PacketCoreControlPlanesClient) getCreateRequest(ctx context.Contex return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -312,10 +308,11 @@ func (client *PacketCoreControlPlanesClient) getHandleResponse(resp *http.Respon } // NewListByResourceGroupPager - Lists all the packet core control planes in a resource group. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - PacketCoreControlPlanesClientListByResourceGroupOptions contains the optional parameters for the PacketCoreControlPlanesClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - PacketCoreControlPlanesClientListByResourceGroupOptions contains the optional parameters for the PacketCoreControlPlanesClient.NewListByResourceGroupPager +// method. func (client *PacketCoreControlPlanesClient) NewListByResourceGroupPager(resourceGroupName string, options *PacketCoreControlPlanesClientListByResourceGroupOptions) *runtime.Pager[PacketCoreControlPlanesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[PacketCoreControlPlanesClientListByResourceGroupResponse]{ More: func(page PacketCoreControlPlanesClientListByResourceGroupResponse) bool { @@ -332,7 +329,7 @@ func (client *PacketCoreControlPlanesClient) NewListByResourceGroupPager(resourc if err != nil { return PacketCoreControlPlanesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PacketCoreControlPlanesClientListByResourceGroupResponse{}, err } @@ -355,7 +352,7 @@ func (client *PacketCoreControlPlanesClient) listByResourceGroupCreateRequest(ct return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -376,9 +373,10 @@ func (client *PacketCoreControlPlanesClient) listByResourceGroupHandleResponse(r } // NewListBySubscriptionPager - Lists all the packet core control planes in a subscription. +// // Generated from API version 2022-11-01 -// options - PacketCoreControlPlanesClientListBySubscriptionOptions contains the optional parameters for the PacketCoreControlPlanesClient.ListBySubscription -// method. +// - options - PacketCoreControlPlanesClientListBySubscriptionOptions contains the optional parameters for the PacketCoreControlPlanesClient.NewListBySubscriptionPager +// method. func (client *PacketCoreControlPlanesClient) NewListBySubscriptionPager(options *PacketCoreControlPlanesClientListBySubscriptionOptions) *runtime.Pager[PacketCoreControlPlanesClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[PacketCoreControlPlanesClientListBySubscriptionResponse]{ More: func(page PacketCoreControlPlanesClientListBySubscriptionResponse) bool { @@ -395,7 +393,7 @@ func (client *PacketCoreControlPlanesClient) NewListBySubscriptionPager(options if err != nil { return PacketCoreControlPlanesClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PacketCoreControlPlanesClientListBySubscriptionResponse{}, err } @@ -414,7 +412,7 @@ func (client *PacketCoreControlPlanesClient) listBySubscriptionCreateRequest(ctx return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -437,35 +435,37 @@ func (client *PacketCoreControlPlanesClient) listBySubscriptionHandleResponse(re // BeginReinstall - Reinstall the specified packet core control plane. This action will remove any transaction state from // the packet core to return it to a known state. This action will cause a service outage. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// options - PacketCoreControlPlanesClientBeginReinstallOptions contains the optional parameters for the PacketCoreControlPlanesClient.BeginReinstall -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - options - PacketCoreControlPlanesClientBeginReinstallOptions contains the optional parameters for the PacketCoreControlPlanesClient.BeginReinstall +// method. func (client *PacketCoreControlPlanesClient) BeginReinstall(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, options *PacketCoreControlPlanesClientBeginReinstallOptions) (*runtime.Poller[PacketCoreControlPlanesClientReinstallResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.reinstall(ctx, resourceGroupName, packetCoreControlPlaneName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PacketCoreControlPlanesClientReinstallResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PacketCoreControlPlanesClientReinstallResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[PacketCoreControlPlanesClientReinstallResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PacketCoreControlPlanesClientReinstallResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Reinstall - Reinstall the specified packet core control plane. This action will remove any transaction state from the packet // core to return it to a known state. This action will cause a service outage. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *PacketCoreControlPlanesClient) reinstall(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, options *PacketCoreControlPlanesClientBeginReinstallOptions) (*http.Response, error) { req, err := client.reinstallCreateRequest(ctx, resourceGroupName, packetCoreControlPlaneName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -490,7 +490,7 @@ func (client *PacketCoreControlPlanesClient) reinstallCreateRequest(ctx context. return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -504,35 +504,37 @@ func (client *PacketCoreControlPlanesClient) reinstallCreateRequest(ctx context. // BeginRollback - Roll back the specified packet core control plane to the previous version, "rollbackVersion". Multiple // consecutive rollbacks are not possible. This action may cause a service outage. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// options - PacketCoreControlPlanesClientBeginRollbackOptions contains the optional parameters for the PacketCoreControlPlanesClient.BeginRollback -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - options - PacketCoreControlPlanesClientBeginRollbackOptions contains the optional parameters for the PacketCoreControlPlanesClient.BeginRollback +// method. func (client *PacketCoreControlPlanesClient) BeginRollback(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, options *PacketCoreControlPlanesClientBeginRollbackOptions) (*runtime.Poller[PacketCoreControlPlanesClientRollbackResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.rollback(ctx, resourceGroupName, packetCoreControlPlaneName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PacketCoreControlPlanesClientRollbackResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PacketCoreControlPlanesClientRollbackResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[PacketCoreControlPlanesClientRollbackResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PacketCoreControlPlanesClientRollbackResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Rollback - Roll back the specified packet core control plane to the previous version, "rollbackVersion". Multiple consecutive // rollbacks are not possible. This action may cause a service outage. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *PacketCoreControlPlanesClient) rollback(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, options *PacketCoreControlPlanesClientBeginRollbackOptions) (*http.Response, error) { req, err := client.rollbackCreateRequest(ctx, resourceGroupName, packetCoreControlPlaneName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -557,7 +559,7 @@ func (client *PacketCoreControlPlanesClient) rollbackCreateRequest(ctx context.C return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -570,18 +572,19 @@ func (client *PacketCoreControlPlanesClient) rollbackCreateRequest(ctx context.C // UpdateTags - Updates packet core control planes tags. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// parameters - Parameters supplied to update packet core control plane tags. -// options - PacketCoreControlPlanesClientUpdateTagsOptions contains the optional parameters for the PacketCoreControlPlanesClient.UpdateTags -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - parameters - Parameters supplied to update packet core control plane tags. +// - options - PacketCoreControlPlanesClientUpdateTagsOptions contains the optional parameters for the PacketCoreControlPlanesClient.UpdateTags +// method. func (client *PacketCoreControlPlanesClient) UpdateTags(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, parameters TagsObject, options *PacketCoreControlPlanesClientUpdateTagsOptions) (PacketCoreControlPlanesClientUpdateTagsResponse, error) { req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, packetCoreControlPlaneName, parameters, options) if err != nil { return PacketCoreControlPlanesClientUpdateTagsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PacketCoreControlPlanesClientUpdateTagsResponse{}, err } @@ -606,7 +609,7 @@ func (client *PacketCoreControlPlanesClient) updateTagsCreateRequest(ctx context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplanes_client_example_test.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplanes_client_example_test.go index 1570ac0faadf..85ecbb9b124e 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplanes_client_example_test.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplanes_client_example_test.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 armmobilenetwork_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mobilenetwork/armmobilenetwork/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneDelete.json func ExamplePacketCoreControlPlanesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreControlPlanesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rg1", "TestPacketCoreCP", nil) + poller, err := clientFactory.NewPacketCoreControlPlanesClient().BeginDelete(ctx, "rg1", "TestPacketCoreCP", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -38,37 +39,103 @@ func ExamplePacketCoreControlPlanesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneGet.json func ExamplePacketCoreControlPlanesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreControlPlanesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rg1", "TestPacketCoreCP", nil) + res, err := clientFactory.NewPacketCoreControlPlanesClient().Get(ctx, "rg1", "TestPacketCoreCP", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PacketCoreControlPlane = armmobilenetwork.PacketCoreControlPlane{ + // Name: to.Ptr("TestPacketCoreCP"), + // Type: to.Ptr("Microsoft.MobileNetwork/packetCoreControlPlane"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.PacketCoreControlPlanePropertiesFormat{ + // ControlPlaneAccessInterface: &armmobilenetwork.InterfaceProperties{ + // Name: to.Ptr("N2"), + // }, + // CoreNetworkTechnology: to.Ptr(armmobilenetwork.CoreNetworkTypeFiveGC), + // Installation: &armmobilenetwork.Installation{ + // Operation: &armmobilenetwork.AsyncOperationID{ + // ID: to.Ptr("/providers/Microsoft.MobileNetwork/locations/EASTUS/operationStatuses/abc"), + // }, + // State: to.Ptr(armmobilenetwork.InstallationStateInstalling), + // }, + // LocalDiagnosticsAccess: &armmobilenetwork.LocalDiagnosticsAccessConfiguration{ + // AuthenticationType: to.Ptr(armmobilenetwork.AuthenticationTypePassword), + // HTTPSServerCertificate: &armmobilenetwork.HTTPSServerCertificate{ + // CertificateURL: to.Ptr("https://contosovault.vault.azure.net/certificates/ingress"), + // Provisioning: &armmobilenetwork.CertificateProvisioning{ + // State: to.Ptr(armmobilenetwork.CertificateProvisioningStateNotProvisioned), + // }, + // }, + // }, + // Platform: &armmobilenetwork.PlatformConfiguration{ + // Type: to.Ptr(armmobilenetwork.PlatformTypeAKSHCI), + // AzureStackEdgeDevice: &armmobilenetwork.AzureStackEdgeDeviceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice"), + // }, + // AzureStackEdgeDevices: []*armmobilenetwork.AzureStackEdgeDeviceResourceID{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice"), + // }, + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice2"), + // }}, + // ConnectedCluster: &armmobilenetwork.ConnectedClusterResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Kubernetes/connectedClusters/TestConnectedCluster"), + // }, + // CustomLocation: &armmobilenetwork.CustomLocationResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ExtendedLocation/customLocations/TestCustomLocation"), + // }, + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // RollbackVersion: to.Ptr("0.1.0"), + // Sites: []*armmobilenetwork.SiteResourceID{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite"), + // }}, + // SKU: to.Ptr(armmobilenetwork.BillingSKUG0), + // UeMtu: to.Ptr[int32](1600), + // Version: to.Ptr("0.2.0"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneCreate.json func ExamplePacketCoreControlPlanesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreControlPlanesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "TestPacketCoreCP", armmobilenetwork.PacketCoreControlPlane{ + poller, err := clientFactory.NewPacketCoreControlPlanesClient().BeginCreateOrUpdate(ctx, "rg1", "TestPacketCoreCP", armmobilenetwork.PacketCoreControlPlane{ Location: to.Ptr("eastus"), Properties: &armmobilenetwork.PacketCoreControlPlanePropertiesFormat{ ControlPlaneAccessInterface: &armmobilenetwork.InterfaceProperties{ @@ -109,22 +176,84 @@ func ExamplePacketCoreControlPlanesClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PacketCoreControlPlane = armmobilenetwork.PacketCoreControlPlane{ + // Name: to.Ptr("TestPacketCoreCP"), + // Type: to.Ptr("Microsoft.MobileNetwork/packetCoreControlPlane"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.PacketCoreControlPlanePropertiesFormat{ + // ControlPlaneAccessInterface: &armmobilenetwork.InterfaceProperties{ + // Name: to.Ptr("N2"), + // }, + // CoreNetworkTechnology: to.Ptr(armmobilenetwork.CoreNetworkTypeFiveGC), + // Installation: &armmobilenetwork.Installation{ + // State: to.Ptr(armmobilenetwork.InstallationStateInstalled), + // }, + // LocalDiagnosticsAccess: &armmobilenetwork.LocalDiagnosticsAccessConfiguration{ + // AuthenticationType: to.Ptr(armmobilenetwork.AuthenticationTypeAAD), + // HTTPSServerCertificate: &armmobilenetwork.HTTPSServerCertificate{ + // CertificateURL: to.Ptr("https://contosovault.vault.azure.net/certificates/ingress"), + // Provisioning: &armmobilenetwork.CertificateProvisioning{ + // State: to.Ptr(armmobilenetwork.CertificateProvisioningStateNotProvisioned), + // }, + // }, + // }, + // Platform: &armmobilenetwork.PlatformConfiguration{ + // Type: to.Ptr(armmobilenetwork.PlatformTypeAKSHCI), + // AzureStackEdgeDevice: &armmobilenetwork.AzureStackEdgeDeviceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice"), + // }, + // AzureStackEdgeDevices: []*armmobilenetwork.AzureStackEdgeDeviceResourceID{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice"), + // }, + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice2"), + // }}, + // ConnectedCluster: &armmobilenetwork.ConnectedClusterResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Kubernetes/connectedClusters/TestConnectedCluster"), + // }, + // CustomLocation: &armmobilenetwork.CustomLocationResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ExtendedLocation/customLocations/TestCustomLocation"), + // }, + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // Sites: []*armmobilenetwork.SiteResourceID{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite"), + // }}, + // SKU: to.Ptr(armmobilenetwork.BillingSKUG0), + // UeMtu: to.Ptr[int32](1600), + // Version: to.Ptr("0.2.0"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneUpdateTags.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneUpdateTags.json func ExamplePacketCoreControlPlanesClient_UpdateTags() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreControlPlanesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.UpdateTags(ctx, "rg1", "TestPacketCoreCP", armmobilenetwork.TagsObject{ + res, err := clientFactory.NewPacketCoreControlPlanesClient().UpdateTags(ctx, "rg1", "TestPacketCoreCP", armmobilenetwork.TagsObject{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -133,70 +262,267 @@ func ExamplePacketCoreControlPlanesClient_UpdateTags() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PacketCoreControlPlane = armmobilenetwork.PacketCoreControlPlane{ + // Name: to.Ptr("TestPacketCoreCP"), + // Type: to.Ptr("Microsoft.MobileNetwork/packetCoreControlPlane"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armmobilenetwork.PacketCoreControlPlanePropertiesFormat{ + // ControlPlaneAccessInterface: &armmobilenetwork.InterfaceProperties{ + // Name: to.Ptr("N2"), + // }, + // CoreNetworkTechnology: to.Ptr(armmobilenetwork.CoreNetworkTypeFiveGC), + // Installation: &armmobilenetwork.Installation{ + // State: to.Ptr(armmobilenetwork.InstallationStateInstalled), + // }, + // LocalDiagnosticsAccess: &armmobilenetwork.LocalDiagnosticsAccessConfiguration{ + // AuthenticationType: to.Ptr(armmobilenetwork.AuthenticationTypePassword), + // HTTPSServerCertificate: &armmobilenetwork.HTTPSServerCertificate{ + // CertificateURL: to.Ptr("https://contosovault.vault.azure.net/certificates/ingress"), + // Provisioning: &armmobilenetwork.CertificateProvisioning{ + // State: to.Ptr(armmobilenetwork.CertificateProvisioningStateNotProvisioned), + // }, + // }, + // }, + // Platform: &armmobilenetwork.PlatformConfiguration{ + // Type: to.Ptr(armmobilenetwork.PlatformTypeAKSHCI), + // AzureStackEdgeDevice: &armmobilenetwork.AzureStackEdgeDeviceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice"), + // }, + // AzureStackEdgeDevices: []*armmobilenetwork.AzureStackEdgeDeviceResourceID{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice"), + // }, + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice2"), + // }}, + // ConnectedCluster: &armmobilenetwork.ConnectedClusterResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Kubernetes/connectedClusters/TestConnectedCluster"), + // }, + // CustomLocation: &armmobilenetwork.CustomLocationResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ExtendedLocation/customLocations/TestCustomLocation"), + // }, + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // RollbackVersion: to.Ptr("0.1.0"), + // Sites: []*armmobilenetwork.SiteResourceID{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite"), + // }}, + // SKU: to.Ptr(armmobilenetwork.BillingSKUG0), + // UeMtu: to.Ptr[int32](1600), + // Version: to.Ptr("0.2.0"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneListBySubscription.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneListBySubscription.json func ExamplePacketCoreControlPlanesClient_NewListBySubscriptionPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreControlPlanesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySubscriptionPager(nil) + pager := clientFactory.NewPacketCoreControlPlanesClient().NewListBySubscriptionPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PacketCoreControlPlaneListResult = armmobilenetwork.PacketCoreControlPlaneListResult{ + // Value: []*armmobilenetwork.PacketCoreControlPlane{ + // { + // Name: to.Ptr("TestPacketCoreCP"), + // Type: to.Ptr("Microsoft.MobileNetwork/packetCoreControlPlane"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.PacketCoreControlPlanePropertiesFormat{ + // ControlPlaneAccessInterface: &armmobilenetwork.InterfaceProperties{ + // Name: to.Ptr("N2"), + // }, + // CoreNetworkTechnology: to.Ptr(armmobilenetwork.CoreNetworkTypeFiveGC), + // Installation: &armmobilenetwork.Installation{ + // State: to.Ptr(armmobilenetwork.InstallationStateInstalled), + // }, + // LocalDiagnosticsAccess: &armmobilenetwork.LocalDiagnosticsAccessConfiguration{ + // AuthenticationType: to.Ptr(armmobilenetwork.AuthenticationTypePassword), + // HTTPSServerCertificate: &armmobilenetwork.HTTPSServerCertificate{ + // CertificateURL: to.Ptr("https://contosovault.vault.azure.net/certificates/ingress"), + // Provisioning: &armmobilenetwork.CertificateProvisioning{ + // State: to.Ptr(armmobilenetwork.CertificateProvisioningStateNotProvisioned), + // }, + // }, + // }, + // Platform: &armmobilenetwork.PlatformConfiguration{ + // Type: to.Ptr(armmobilenetwork.PlatformTypeAKSHCI), + // AzureStackEdgeDevice: &armmobilenetwork.AzureStackEdgeDeviceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice"), + // }, + // AzureStackEdgeDevices: []*armmobilenetwork.AzureStackEdgeDeviceResourceID{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice"), + // }, + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice2"), + // }}, + // ConnectedCluster: &armmobilenetwork.ConnectedClusterResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Kubernetes/connectedClusters/TestConnectedCluster"), + // }, + // CustomLocation: &armmobilenetwork.CustomLocationResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ExtendedLocation/customLocations/TestCustomLocation"), + // }, + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // RollbackVersion: to.Ptr("0.1.0"), + // Sites: []*armmobilenetwork.SiteResourceID{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite"), + // }}, + // SKU: to.Ptr(armmobilenetwork.BillingSKUG0), + // UeMtu: to.Ptr[int32](1600), + // Version: to.Ptr("0.2.0"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneListByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneListByResourceGroup.json func ExamplePacketCoreControlPlanesClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreControlPlanesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("rg1", nil) + pager := clientFactory.NewPacketCoreControlPlanesClient().NewListByResourceGroupPager("rg1", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PacketCoreControlPlaneListResult = armmobilenetwork.PacketCoreControlPlaneListResult{ + // Value: []*armmobilenetwork.PacketCoreControlPlane{ + // { + // Name: to.Ptr("TestPacketCoreCP"), + // Type: to.Ptr("Microsoft.MobileNetwork/packetCoreControlPlane"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.PacketCoreControlPlanePropertiesFormat{ + // ControlPlaneAccessInterface: &armmobilenetwork.InterfaceProperties{ + // Name: to.Ptr("N2"), + // }, + // CoreNetworkTechnology: to.Ptr(armmobilenetwork.CoreNetworkTypeFiveGC), + // Installation: &armmobilenetwork.Installation{ + // State: to.Ptr(armmobilenetwork.InstallationStateInstalled), + // }, + // LocalDiagnosticsAccess: &armmobilenetwork.LocalDiagnosticsAccessConfiguration{ + // AuthenticationType: to.Ptr(armmobilenetwork.AuthenticationTypePassword), + // HTTPSServerCertificate: &armmobilenetwork.HTTPSServerCertificate{ + // CertificateURL: to.Ptr("https://contosovault.vault.azure.net/certificates/ingress"), + // Provisioning: &armmobilenetwork.CertificateProvisioning{ + // State: to.Ptr(armmobilenetwork.CertificateProvisioningStateNotProvisioned), + // }, + // }, + // }, + // Platform: &armmobilenetwork.PlatformConfiguration{ + // Type: to.Ptr(armmobilenetwork.PlatformTypeAKSHCI), + // AzureStackEdgeDevice: &armmobilenetwork.AzureStackEdgeDeviceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice"), + // }, + // AzureStackEdgeDevices: []*armmobilenetwork.AzureStackEdgeDeviceResourceID{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice"), + // }, + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice2"), + // }}, + // ConnectedCluster: &armmobilenetwork.ConnectedClusterResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Kubernetes/connectedClusters/TestConnectedCluster"), + // }, + // CustomLocation: &armmobilenetwork.CustomLocationResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ExtendedLocation/customLocations/TestCustomLocation"), + // }, + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // RollbackVersion: to.Ptr("0.1.0"), + // Sites: []*armmobilenetwork.SiteResourceID{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite"), + // }}, + // SKU: to.Ptr(armmobilenetwork.BillingSKUG0), + // UeMtu: to.Ptr[int32](1600), + // Version: to.Ptr("0.2.0"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneRollback.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneRollback.json func ExamplePacketCoreControlPlanesClient_BeginRollback() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreControlPlanesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginRollback(ctx, "rg1", "TestPacketCoreCP", nil) + poller, err := clientFactory.NewPacketCoreControlPlanesClient().BeginRollback(ctx, "rg1", "TestPacketCoreCP", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -204,22 +530,30 @@ func ExamplePacketCoreControlPlanesClient_BeginRollback() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AsyncOperationStatus = armmobilenetwork.AsyncOperationStatus{ + // Name: to.Ptr("testOperation"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-19T03:38:07.000Z"); return t}()), + // ID: to.Ptr("/providers/Microsoft.MobileNetwork/locations/testLocation/operationStatuses/testOperation"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-19T03:36:07.000Z"); return t}()), + // Status: to.Ptr("Succeeded"), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneReinstall.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneReinstall.json func ExamplePacketCoreControlPlanesClient_BeginReinstall() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreControlPlanesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginReinstall(ctx, "rg1", "TestPacketCoreCP", nil) + poller, err := clientFactory.NewPacketCoreControlPlanesClient().BeginReinstall(ctx, "rg1", "TestPacketCoreCP", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -227,22 +561,30 @@ func ExamplePacketCoreControlPlanesClient_BeginReinstall() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AsyncOperationStatus = armmobilenetwork.AsyncOperationStatus{ + // Name: to.Ptr("testOperation"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-19T03:38:07.000Z"); return t}()), + // ID: to.Ptr("/providers/Microsoft.MobileNetwork/locations/testLocation/operationStatuses/testOperation"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-19T03:36:07.000Z"); return t}()), + // Status: to.Ptr("Succeeded"), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneCollectDiagnosticsPackage.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneCollectDiagnosticsPackage.json func ExamplePacketCoreControlPlanesClient_BeginCollectDiagnosticsPackage() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreControlPlanesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCollectDiagnosticsPackage(ctx, "rg1", "TestPacketCoreCP", armmobilenetwork.PacketCoreControlPlaneCollectDiagnosticsPackage{ + poller, err := clientFactory.NewPacketCoreControlPlanesClient().BeginCollectDiagnosticsPackage(ctx, "rg1", "TestPacketCoreCP", armmobilenetwork.PacketCoreControlPlaneCollectDiagnosticsPackage{ StorageAccountBlobURL: to.Ptr("https://contosoaccount.blob.core.windows.net/container/diagnosticsPackage.zip"), }, nil) if err != nil { @@ -252,6 +594,14 @@ func ExamplePacketCoreControlPlanesClient_BeginCollectDiagnosticsPackage() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AsyncOperationStatus = armmobilenetwork.AsyncOperationStatus{ + // Name: to.Ptr("testOperation"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-19T03:38:07.000Z"); return t}()), + // ID: to.Ptr("/providers/Microsoft.MobileNetwork/locations/testLocation/operationStatuses/testOperation"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-19T03:36:07.000Z"); return t}()), + // Status: to.Ptr("Succeeded"), + // } } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplaneversions_client.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplaneversions_client.go index 5c4894b75809..fa74d0127a0a 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplaneversions_client.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplaneversions_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,44 +24,36 @@ import ( // PacketCoreControlPlaneVersionsClient contains the methods for the PacketCoreControlPlaneVersions group. // Don't use this type directly, use NewPacketCoreControlPlaneVersionsClient() instead. type PacketCoreControlPlaneVersionsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewPacketCoreControlPlaneVersionsClient creates a new instance of PacketCoreControlPlaneVersionsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPacketCoreControlPlaneVersionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*PacketCoreControlPlaneVersionsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PacketCoreControlPlaneVersionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PacketCoreControlPlaneVersionsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets information about the specified packet core control plane version. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// versionName - The name of the packet core control plane version. -// options - PacketCoreControlPlaneVersionsClientGetOptions contains the optional parameters for the PacketCoreControlPlaneVersionsClient.Get -// method. +// - versionName - The name of the packet core control plane version. +// - options - PacketCoreControlPlaneVersionsClientGetOptions contains the optional parameters for the PacketCoreControlPlaneVersionsClient.Get +// method. func (client *PacketCoreControlPlaneVersionsClient) Get(ctx context.Context, versionName string, options *PacketCoreControlPlaneVersionsClientGetOptions) (PacketCoreControlPlaneVersionsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, versionName, options) if err != nil { return PacketCoreControlPlaneVersionsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PacketCoreControlPlaneVersionsClientGetResponse{}, err } @@ -80,7 +70,7 @@ func (client *PacketCoreControlPlaneVersionsClient) getCreateRequest(ctx context return nil, errors.New("parameter versionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{versionName}", url.PathEscape(versionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -101,9 +91,10 @@ func (client *PacketCoreControlPlaneVersionsClient) getHandleResponse(resp *http } // NewListPager - Lists all supported packet core control planes versions. +// // Generated from API version 2022-11-01 -// options - PacketCoreControlPlaneVersionsClientListOptions contains the optional parameters for the PacketCoreControlPlaneVersionsClient.List -// method. +// - options - PacketCoreControlPlaneVersionsClientListOptions contains the optional parameters for the PacketCoreControlPlaneVersionsClient.NewListPager +// method. func (client *PacketCoreControlPlaneVersionsClient) NewListPager(options *PacketCoreControlPlaneVersionsClientListOptions) *runtime.Pager[PacketCoreControlPlaneVersionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[PacketCoreControlPlaneVersionsClientListResponse]{ More: func(page PacketCoreControlPlaneVersionsClientListResponse) bool { @@ -120,7 +111,7 @@ func (client *PacketCoreControlPlaneVersionsClient) NewListPager(options *Packet if err != nil { return PacketCoreControlPlaneVersionsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PacketCoreControlPlaneVersionsClientListResponse{}, err } @@ -135,7 +126,7 @@ func (client *PacketCoreControlPlaneVersionsClient) NewListPager(options *Packet // listCreateRequest creates the List request. func (client *PacketCoreControlPlaneVersionsClient) listCreateRequest(ctx context.Context, options *PacketCoreControlPlaneVersionsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplaneversions_client_example_test.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplaneversions_client_example_test.go index 4e74f653f9c5..f2d150b2f59e 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplaneversions_client_example_test.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcorecontrolplaneversions_client_example_test.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 armmobilenetwork_test @@ -16,45 +17,110 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mobilenetwork/armmobilenetwork/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneVersionGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneVersionGet.json func ExamplePacketCoreControlPlaneVersionsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreControlPlaneVersionsClient(cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "PMN-4-11-1", nil) + res, err := clientFactory.NewPacketCoreControlPlaneVersionsClient().Get(ctx, "PMN-4-11-1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PacketCoreControlPlaneVersion = armmobilenetwork.PacketCoreControlPlaneVersion{ + // Name: to.Ptr("PMN-4-11-1"), + // Type: to.Ptr("Microsoft.MobileNetwork/packetCoreControlPlaneVersions"), + // ID: to.Ptr("/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/PMN-4-11-1"), + // Properties: &armmobilenetwork.PacketCoreControlPlaneVersionPropertiesFormat{ + // Platforms: []*armmobilenetwork.Platform{ + // { + // MaximumPlatformSoftwareVersion: to.Ptr("2211"), + // MinimumPlatformSoftwareVersion: to.Ptr("2209"), + // PlatformType: to.Ptr(armmobilenetwork.PlatformTypeAKSHCI), + // RecommendedVersion: to.Ptr(armmobilenetwork.RecommendedVersionRecommended), + // VersionState: to.Ptr(armmobilenetwork.VersionStateActive), + // }}, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneVersionList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneVersionList.json func ExamplePacketCoreControlPlaneVersionsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreControlPlaneVersionsClient(cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewPacketCoreControlPlaneVersionsClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PacketCoreControlPlaneVersionListResult = armmobilenetwork.PacketCoreControlPlaneVersionListResult{ + // Value: []*armmobilenetwork.PacketCoreControlPlaneVersion{ + // { + // Name: to.Ptr("PMN-4-9-4"), + // Type: to.Ptr("Microsoft.MobileNetwork/packetCoreControlPlaneVersions"), + // ID: to.Ptr("/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/PMN-4-9-4"), + // Properties: &armmobilenetwork.PacketCoreControlPlaneVersionPropertiesFormat{ + // Platforms: []*armmobilenetwork.Platform{ + // { + // MaximumPlatformSoftwareVersion: to.Ptr("2211"), + // MinimumPlatformSoftwareVersion: to.Ptr("2209"), + // PlatformType: to.Ptr(armmobilenetwork.PlatformTypeAKSHCI), + // RecommendedVersion: to.Ptr(armmobilenetwork.RecommendedVersionNotRecommended), + // VersionState: to.Ptr(armmobilenetwork.VersionStateActive), + // }}, + // }, + // }, + // { + // Name: to.Ptr("PMN-4-10-2"), + // Type: to.Ptr("Microsoft.MobileNetwork/packetCoreControlPlaneVersions"), + // ID: to.Ptr("/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/PMN-4-10-2"), + // Properties: &armmobilenetwork.PacketCoreControlPlaneVersionPropertiesFormat{ + // Platforms: []*armmobilenetwork.Platform{ + // { + // MaximumPlatformSoftwareVersion: to.Ptr("2212"), + // MinimumPlatformSoftwareVersion: to.Ptr("2210"), + // PlatformType: to.Ptr(armmobilenetwork.PlatformTypeAKSHCI), + // RecommendedVersion: to.Ptr(armmobilenetwork.RecommendedVersionNotRecommended), + // VersionState: to.Ptr(armmobilenetwork.VersionStateActive), + // }}, + // }, + // }, + // { + // Name: to.Ptr("PMN-4-11-1"), + // Type: to.Ptr("Microsoft.MobileNetwork/packetCoreControlPlaneVersions"), + // ID: to.Ptr("/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/PMN-4-11-1"), + // Properties: &armmobilenetwork.PacketCoreControlPlaneVersionPropertiesFormat{ + // Platforms: []*armmobilenetwork.Platform{ + // { + // MaximumPlatformSoftwareVersion: to.Ptr("2301"), + // MinimumPlatformSoftwareVersion: to.Ptr("2211"), + // PlatformType: to.Ptr(armmobilenetwork.PlatformTypeAKSHCI), + // RecommendedVersion: to.Ptr(armmobilenetwork.RecommendedVersionRecommended), + // VersionState: to.Ptr(armmobilenetwork.VersionStateActive), + // }}, + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcoredataplanes_client.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcoredataplanes_client.go index 0ef225a0e13b..f1d546449d2f 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcoredataplanes_client.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcoredataplanes_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,31 +24,22 @@ import ( // PacketCoreDataPlanesClient contains the methods for the PacketCoreDataPlanes group. // Don't use this type directly, use NewPacketCoreDataPlanesClient() instead. type PacketCoreDataPlanesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPacketCoreDataPlanesClient creates a new instance of PacketCoreDataPlanesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPacketCoreDataPlanesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PacketCoreDataPlanesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PacketCoreDataPlanesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PacketCoreDataPlanesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,37 +47,39 @@ func NewPacketCoreDataPlanesClient(subscriptionID string, credential azcore.Toke // BeginCreateOrUpdate - Creates or updates a packet core data plane. Must be created in the same location as its parent packet // core control plane. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// packetCoreDataPlaneName - The name of the packet core data plane. -// parameters - Parameters supplied to the create or update packet core data plane operation. -// options - PacketCoreDataPlanesClientBeginCreateOrUpdateOptions contains the optional parameters for the PacketCoreDataPlanesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - packetCoreDataPlaneName - The name of the packet core data plane. +// - parameters - Parameters supplied to the create or update packet core data plane operation. +// - options - PacketCoreDataPlanesClientBeginCreateOrUpdateOptions contains the optional parameters for the PacketCoreDataPlanesClient.BeginCreateOrUpdate +// method. func (client *PacketCoreDataPlanesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, parameters PacketCoreDataPlane, options *PacketCoreDataPlanesClientBeginCreateOrUpdateOptions) (*runtime.Poller[PacketCoreDataPlanesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PacketCoreDataPlanesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PacketCoreDataPlanesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[PacketCoreDataPlanesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PacketCoreDataPlanesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a packet core data plane. Must be created in the same location as its parent packet // core control plane. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *PacketCoreDataPlanesClient) createOrUpdate(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, parameters PacketCoreDataPlane, options *PacketCoreDataPlanesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -117,7 +108,7 @@ func (client *PacketCoreDataPlanesClient) createOrUpdateCreateRequest(ctx contex return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -130,35 +121,37 @@ func (client *PacketCoreDataPlanesClient) createOrUpdateCreateRequest(ctx contex // BeginDelete - Deletes the specified packet core data plane. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// packetCoreDataPlaneName - The name of the packet core data plane. -// options - PacketCoreDataPlanesClientBeginDeleteOptions contains the optional parameters for the PacketCoreDataPlanesClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - packetCoreDataPlaneName - The name of the packet core data plane. +// - options - PacketCoreDataPlanesClientBeginDeleteOptions contains the optional parameters for the PacketCoreDataPlanesClient.BeginDelete +// method. func (client *PacketCoreDataPlanesClient) BeginDelete(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, options *PacketCoreDataPlanesClientBeginDeleteOptions) (*runtime.Poller[PacketCoreDataPlanesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PacketCoreDataPlanesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PacketCoreDataPlanesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[PacketCoreDataPlanesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PacketCoreDataPlanesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the specified packet core data plane. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *PacketCoreDataPlanesClient) deleteOperation(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, options *PacketCoreDataPlanesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -187,7 +180,7 @@ func (client *PacketCoreDataPlanesClient) deleteCreateRequest(ctx context.Contex return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -200,18 +193,19 @@ func (client *PacketCoreDataPlanesClient) deleteCreateRequest(ctx context.Contex // Get - Gets information about the specified packet core data plane. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// packetCoreDataPlaneName - The name of the packet core data plane. -// options - PacketCoreDataPlanesClientGetOptions contains the optional parameters for the PacketCoreDataPlanesClient.Get -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - packetCoreDataPlaneName - The name of the packet core data plane. +// - options - PacketCoreDataPlanesClientGetOptions contains the optional parameters for the PacketCoreDataPlanesClient.Get +// method. func (client *PacketCoreDataPlanesClient) Get(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, options *PacketCoreDataPlanesClientGetOptions) (PacketCoreDataPlanesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, options) if err != nil { return PacketCoreDataPlanesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PacketCoreDataPlanesClientGetResponse{}, err } @@ -240,7 +234,7 @@ func (client *PacketCoreDataPlanesClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -261,11 +255,12 @@ func (client *PacketCoreDataPlanesClient) getHandleResponse(resp *http.Response) } // NewListByPacketCoreControlPlanePager - Lists all the packet core data planes associated with a packet core control plane. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// options - PacketCoreDataPlanesClientListByPacketCoreControlPlaneOptions contains the optional parameters for the PacketCoreDataPlanesClient.ListByPacketCoreControlPlane -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - options - PacketCoreDataPlanesClientListByPacketCoreControlPlaneOptions contains the optional parameters for the PacketCoreDataPlanesClient.NewListByPacketCoreControlPlanePager +// method. func (client *PacketCoreDataPlanesClient) NewListByPacketCoreControlPlanePager(resourceGroupName string, packetCoreControlPlaneName string, options *PacketCoreDataPlanesClientListByPacketCoreControlPlaneOptions) *runtime.Pager[PacketCoreDataPlanesClientListByPacketCoreControlPlaneResponse] { return runtime.NewPager(runtime.PagingHandler[PacketCoreDataPlanesClientListByPacketCoreControlPlaneResponse]{ More: func(page PacketCoreDataPlanesClientListByPacketCoreControlPlaneResponse) bool { @@ -282,7 +277,7 @@ func (client *PacketCoreDataPlanesClient) NewListByPacketCoreControlPlanePager(r if err != nil { return PacketCoreDataPlanesClientListByPacketCoreControlPlaneResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PacketCoreDataPlanesClientListByPacketCoreControlPlaneResponse{}, err } @@ -309,7 +304,7 @@ func (client *PacketCoreDataPlanesClient) listByPacketCoreControlPlaneCreateRequ return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -331,19 +326,20 @@ func (client *PacketCoreDataPlanesClient) listByPacketCoreControlPlaneHandleResp // UpdateTags - Updates packet core data planes tags. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// packetCoreControlPlaneName - The name of the packet core control plane. -// packetCoreDataPlaneName - The name of the packet core data plane. -// parameters - Parameters supplied to update packet core data plane tags. -// options - PacketCoreDataPlanesClientUpdateTagsOptions contains the optional parameters for the PacketCoreDataPlanesClient.UpdateTags -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - packetCoreControlPlaneName - The name of the packet core control plane. +// - packetCoreDataPlaneName - The name of the packet core data plane. +// - parameters - Parameters supplied to update packet core data plane tags. +// - options - PacketCoreDataPlanesClientUpdateTagsOptions contains the optional parameters for the PacketCoreDataPlanesClient.UpdateTags +// method. func (client *PacketCoreDataPlanesClient) UpdateTags(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, parameters TagsObject, options *PacketCoreDataPlanesClientUpdateTagsOptions) (PacketCoreDataPlanesClientUpdateTagsResponse, error) { req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, parameters, options) if err != nil { return PacketCoreDataPlanesClientUpdateTagsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PacketCoreDataPlanesClientUpdateTagsResponse{}, err } @@ -372,7 +368,7 @@ func (client *PacketCoreDataPlanesClient) updateTagsCreateRequest(ctx context.Co return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcoredataplanes_client_example_test.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcoredataplanes_client_example_test.go index ae484af2204b..1941bb085eca 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcoredataplanes_client_example_test.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/packetcoredataplanes_client_example_test.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 armmobilenetwork_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mobilenetwork/armmobilenetwork/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreDataPlaneDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreDataPlaneDelete.json func ExamplePacketCoreDataPlanesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreDataPlanesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rg1", "testPacketCoreCP", "testPacketCoreDP", nil) + poller, err := clientFactory.NewPacketCoreDataPlanesClient().BeginDelete(ctx, "rg1", "testPacketCoreCP", "testPacketCoreDP", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -38,37 +39,60 @@ func ExamplePacketCoreDataPlanesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreDataPlaneGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreDataPlaneGet.json func ExamplePacketCoreDataPlanesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreDataPlanesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rg1", "testPacketCoreCP", "testPacketCoreDP", nil) + res, err := clientFactory.NewPacketCoreDataPlanesClient().Get(ctx, "rg1", "testPacketCoreCP", "testPacketCoreDP", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PacketCoreDataPlane = armmobilenetwork.PacketCoreDataPlane{ + // Name: to.Ptr("TestPacketCoreDP"), + // Type: to.Ptr("Microsoft.MobileNetwork/packetCoreDataPlane"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.PacketCoreDataPlanePropertiesFormat{ + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // UserPlaneAccessInterface: &armmobilenetwork.InterfaceProperties{ + // Name: to.Ptr("N3"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreDataPlaneCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreDataPlaneCreate.json func ExamplePacketCoreDataPlanesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreDataPlanesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "testPacketCoreCP", "testPacketCoreDP", armmobilenetwork.PacketCoreDataPlane{ + poller, err := clientFactory.NewPacketCoreDataPlanesClient().BeginCreateOrUpdate(ctx, "rg1", "testPacketCoreCP", "testPacketCoreDP", armmobilenetwork.PacketCoreDataPlane{ Location: to.Ptr("eastus"), Properties: &armmobilenetwork.PacketCoreDataPlanePropertiesFormat{ UserPlaneAccessInterface: &armmobilenetwork.InterfaceProperties{ @@ -83,22 +107,45 @@ func ExamplePacketCoreDataPlanesClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PacketCoreDataPlane = armmobilenetwork.PacketCoreDataPlane{ + // Name: to.Ptr("TestPacketCoreDP"), + // Type: to.Ptr("Microsoft.MobileNetwork/packetCoreDataPlane"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.PacketCoreDataPlanePropertiesFormat{ + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // UserPlaneAccessInterface: &armmobilenetwork.InterfaceProperties{ + // Name: to.Ptr("N3"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreDataPlaneUpdateTags.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreDataPlaneUpdateTags.json func ExamplePacketCoreDataPlanesClient_UpdateTags() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreDataPlanesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.UpdateTags(ctx, "rg1", "testPacketCoreCP", "testPacketCoreDP", armmobilenetwork.TagsObject{ + res, err := clientFactory.NewPacketCoreDataPlanesClient().UpdateTags(ctx, "rg1", "testPacketCoreCP", "testPacketCoreDP", armmobilenetwork.TagsObject{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -107,30 +154,81 @@ func ExamplePacketCoreDataPlanesClient_UpdateTags() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PacketCoreDataPlane = armmobilenetwork.PacketCoreDataPlane{ + // Name: to.Ptr("TestPacketCoreDP"), + // Type: to.Ptr("Microsoft.MobileNetwork/packetCoreDataPlane"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armmobilenetwork.PacketCoreDataPlanePropertiesFormat{ + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // UserPlaneAccessInterface: &armmobilenetwork.InterfaceProperties{ + // Name: to.Ptr("N3"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreDataPlaneListByPacketCoreControlPlane.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreDataPlaneListByPacketCoreControlPlane.json func ExamplePacketCoreDataPlanesClient_NewListByPacketCoreControlPlanePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewPacketCoreDataPlanesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByPacketCoreControlPlanePager("rg1", "testPacketCoreCP", nil) + pager := clientFactory.NewPacketCoreDataPlanesClient().NewListByPacketCoreControlPlanePager("rg1", "testPacketCoreCP", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PacketCoreDataPlaneListResult = armmobilenetwork.PacketCoreDataPlaneListResult{ + // Value: []*armmobilenetwork.PacketCoreDataPlane{ + // { + // Name: to.Ptr("TestPacketCoreDP"), + // Type: to.Ptr("Microsoft.MobileNetwork/packetCoreDataPlane"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.PacketCoreDataPlanePropertiesFormat{ + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // UserPlaneAccessInterface: &armmobilenetwork.InterfaceProperties{ + // Name: to.Ptr("N3"), + // }, + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/response_types.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/response_types.go index f80771060115..834a5fd912eb 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/response_types.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/response_types.go @@ -9,12 +9,12 @@ package armmobilenetwork -// AttachedDataNetworksClientCreateOrUpdateResponse contains the response from method AttachedDataNetworksClient.CreateOrUpdate. +// AttachedDataNetworksClientCreateOrUpdateResponse contains the response from method AttachedDataNetworksClient.BeginCreateOrUpdate. type AttachedDataNetworksClientCreateOrUpdateResponse struct { AttachedDataNetwork } -// AttachedDataNetworksClientDeleteResponse contains the response from method AttachedDataNetworksClient.Delete. +// AttachedDataNetworksClientDeleteResponse contains the response from method AttachedDataNetworksClient.BeginDelete. type AttachedDataNetworksClientDeleteResponse struct { // placeholder for future response values } @@ -24,7 +24,7 @@ type AttachedDataNetworksClientGetResponse struct { AttachedDataNetwork } -// AttachedDataNetworksClientListByPacketCoreDataPlaneResponse contains the response from method AttachedDataNetworksClient.ListByPacketCoreDataPlane. +// AttachedDataNetworksClientListByPacketCoreDataPlaneResponse contains the response from method AttachedDataNetworksClient.NewListByPacketCoreDataPlanePager. type AttachedDataNetworksClientListByPacketCoreDataPlaneResponse struct { AttachedDataNetworkListResult } @@ -34,12 +34,12 @@ type AttachedDataNetworksClientUpdateTagsResponse struct { AttachedDataNetwork } -// DataNetworksClientCreateOrUpdateResponse contains the response from method DataNetworksClient.CreateOrUpdate. +// DataNetworksClientCreateOrUpdateResponse contains the response from method DataNetworksClient.BeginCreateOrUpdate. type DataNetworksClientCreateOrUpdateResponse struct { DataNetwork } -// DataNetworksClientDeleteResponse contains the response from method DataNetworksClient.Delete. +// DataNetworksClientDeleteResponse contains the response from method DataNetworksClient.BeginDelete. type DataNetworksClientDeleteResponse struct { // placeholder for future response values } @@ -49,7 +49,7 @@ type DataNetworksClientGetResponse struct { DataNetwork } -// DataNetworksClientListByMobileNetworkResponse contains the response from method DataNetworksClient.ListByMobileNetwork. +// DataNetworksClientListByMobileNetworkResponse contains the response from method DataNetworksClient.NewListByMobileNetworkPager. type DataNetworksClientListByMobileNetworkResponse struct { DataNetworkListResult } @@ -59,12 +59,12 @@ type DataNetworksClientUpdateTagsResponse struct { DataNetwork } -// MobileNetworksClientCreateOrUpdateResponse contains the response from method MobileNetworksClient.CreateOrUpdate. +// MobileNetworksClientCreateOrUpdateResponse contains the response from method MobileNetworksClient.BeginCreateOrUpdate. type MobileNetworksClientCreateOrUpdateResponse struct { MobileNetwork } -// MobileNetworksClientDeleteResponse contains the response from method MobileNetworksClient.Delete. +// MobileNetworksClientDeleteResponse contains the response from method MobileNetworksClient.BeginDelete. type MobileNetworksClientDeleteResponse struct { // placeholder for future response values } @@ -74,12 +74,12 @@ type MobileNetworksClientGetResponse struct { MobileNetwork } -// MobileNetworksClientListByResourceGroupResponse contains the response from method MobileNetworksClient.ListByResourceGroup. +// MobileNetworksClientListByResourceGroupResponse contains the response from method MobileNetworksClient.NewListByResourceGroupPager. type MobileNetworksClientListByResourceGroupResponse struct { ListResult } -// MobileNetworksClientListBySubscriptionResponse contains the response from method MobileNetworksClient.ListBySubscription. +// MobileNetworksClientListBySubscriptionResponse contains the response from method MobileNetworksClient.NewListBySubscriptionPager. type MobileNetworksClientListBySubscriptionResponse struct { ListResult } @@ -89,7 +89,7 @@ type MobileNetworksClientUpdateTagsResponse struct { MobileNetwork } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationList } @@ -99,22 +99,22 @@ type PacketCoreControlPlaneVersionsClientGetResponse struct { PacketCoreControlPlaneVersion } -// PacketCoreControlPlaneVersionsClientListResponse contains the response from method PacketCoreControlPlaneVersionsClient.List. +// PacketCoreControlPlaneVersionsClientListResponse contains the response from method PacketCoreControlPlaneVersionsClient.NewListPager. type PacketCoreControlPlaneVersionsClientListResponse struct { PacketCoreControlPlaneVersionListResult } -// PacketCoreControlPlanesClientCollectDiagnosticsPackageResponse contains the response from method PacketCoreControlPlanesClient.CollectDiagnosticsPackage. +// PacketCoreControlPlanesClientCollectDiagnosticsPackageResponse contains the response from method PacketCoreControlPlanesClient.BeginCollectDiagnosticsPackage. type PacketCoreControlPlanesClientCollectDiagnosticsPackageResponse struct { AsyncOperationStatus } -// PacketCoreControlPlanesClientCreateOrUpdateResponse contains the response from method PacketCoreControlPlanesClient.CreateOrUpdate. +// PacketCoreControlPlanesClientCreateOrUpdateResponse contains the response from method PacketCoreControlPlanesClient.BeginCreateOrUpdate. type PacketCoreControlPlanesClientCreateOrUpdateResponse struct { PacketCoreControlPlane } -// PacketCoreControlPlanesClientDeleteResponse contains the response from method PacketCoreControlPlanesClient.Delete. +// PacketCoreControlPlanesClientDeleteResponse contains the response from method PacketCoreControlPlanesClient.BeginDelete. type PacketCoreControlPlanesClientDeleteResponse struct { // placeholder for future response values } @@ -124,22 +124,22 @@ type PacketCoreControlPlanesClientGetResponse struct { PacketCoreControlPlane } -// PacketCoreControlPlanesClientListByResourceGroupResponse contains the response from method PacketCoreControlPlanesClient.ListByResourceGroup. +// PacketCoreControlPlanesClientListByResourceGroupResponse contains the response from method PacketCoreControlPlanesClient.NewListByResourceGroupPager. type PacketCoreControlPlanesClientListByResourceGroupResponse struct { PacketCoreControlPlaneListResult } -// PacketCoreControlPlanesClientListBySubscriptionResponse contains the response from method PacketCoreControlPlanesClient.ListBySubscription. +// PacketCoreControlPlanesClientListBySubscriptionResponse contains the response from method PacketCoreControlPlanesClient.NewListBySubscriptionPager. type PacketCoreControlPlanesClientListBySubscriptionResponse struct { PacketCoreControlPlaneListResult } -// PacketCoreControlPlanesClientReinstallResponse contains the response from method PacketCoreControlPlanesClient.Reinstall. +// PacketCoreControlPlanesClientReinstallResponse contains the response from method PacketCoreControlPlanesClient.BeginReinstall. type PacketCoreControlPlanesClientReinstallResponse struct { AsyncOperationStatus } -// PacketCoreControlPlanesClientRollbackResponse contains the response from method PacketCoreControlPlanesClient.Rollback. +// PacketCoreControlPlanesClientRollbackResponse contains the response from method PacketCoreControlPlanesClient.BeginRollback. type PacketCoreControlPlanesClientRollbackResponse struct { AsyncOperationStatus } @@ -149,12 +149,12 @@ type PacketCoreControlPlanesClientUpdateTagsResponse struct { PacketCoreControlPlane } -// PacketCoreDataPlanesClientCreateOrUpdateResponse contains the response from method PacketCoreDataPlanesClient.CreateOrUpdate. +// PacketCoreDataPlanesClientCreateOrUpdateResponse contains the response from method PacketCoreDataPlanesClient.BeginCreateOrUpdate. type PacketCoreDataPlanesClientCreateOrUpdateResponse struct { PacketCoreDataPlane } -// PacketCoreDataPlanesClientDeleteResponse contains the response from method PacketCoreDataPlanesClient.Delete. +// PacketCoreDataPlanesClientDeleteResponse contains the response from method PacketCoreDataPlanesClient.BeginDelete. type PacketCoreDataPlanesClientDeleteResponse struct { // placeholder for future response values } @@ -164,7 +164,7 @@ type PacketCoreDataPlanesClientGetResponse struct { PacketCoreDataPlane } -// PacketCoreDataPlanesClientListByPacketCoreControlPlaneResponse contains the response from method PacketCoreDataPlanesClient.ListByPacketCoreControlPlane. +// PacketCoreDataPlanesClientListByPacketCoreControlPlaneResponse contains the response from method PacketCoreDataPlanesClient.NewListByPacketCoreControlPlanePager. type PacketCoreDataPlanesClientListByPacketCoreControlPlaneResponse struct { PacketCoreDataPlaneListResult } @@ -174,12 +174,12 @@ type PacketCoreDataPlanesClientUpdateTagsResponse struct { PacketCoreDataPlane } -// ServicesClientCreateOrUpdateResponse contains the response from method ServicesClient.CreateOrUpdate. +// ServicesClientCreateOrUpdateResponse contains the response from method ServicesClient.BeginCreateOrUpdate. type ServicesClientCreateOrUpdateResponse struct { Service } -// ServicesClientDeleteResponse contains the response from method ServicesClient.Delete. +// ServicesClientDeleteResponse contains the response from method ServicesClient.BeginDelete. type ServicesClientDeleteResponse struct { // placeholder for future response values } @@ -189,7 +189,7 @@ type ServicesClientGetResponse struct { Service } -// ServicesClientListByMobileNetworkResponse contains the response from method ServicesClient.ListByMobileNetwork. +// ServicesClientListByMobileNetworkResponse contains the response from method ServicesClient.NewListByMobileNetworkPager. type ServicesClientListByMobileNetworkResponse struct { ServiceListResult } @@ -199,12 +199,12 @@ type ServicesClientUpdateTagsResponse struct { Service } -// SimGroupsClientCreateOrUpdateResponse contains the response from method SimGroupsClient.CreateOrUpdate. +// SimGroupsClientCreateOrUpdateResponse contains the response from method SimGroupsClient.BeginCreateOrUpdate. type SimGroupsClientCreateOrUpdateResponse struct { SimGroup } -// SimGroupsClientDeleteResponse contains the response from method SimGroupsClient.Delete. +// SimGroupsClientDeleteResponse contains the response from method SimGroupsClient.BeginDelete. type SimGroupsClientDeleteResponse struct { // placeholder for future response values } @@ -214,12 +214,12 @@ type SimGroupsClientGetResponse struct { SimGroup } -// SimGroupsClientListByResourceGroupResponse contains the response from method SimGroupsClient.ListByResourceGroup. +// SimGroupsClientListByResourceGroupResponse contains the response from method SimGroupsClient.NewListByResourceGroupPager. type SimGroupsClientListByResourceGroupResponse struct { SimGroupListResult } -// SimGroupsClientListBySubscriptionResponse contains the response from method SimGroupsClient.ListBySubscription. +// SimGroupsClientListBySubscriptionResponse contains the response from method SimGroupsClient.NewListBySubscriptionPager. type SimGroupsClientListBySubscriptionResponse struct { SimGroupListResult } @@ -229,12 +229,12 @@ type SimGroupsClientUpdateTagsResponse struct { SimGroup } -// SimPoliciesClientCreateOrUpdateResponse contains the response from method SimPoliciesClient.CreateOrUpdate. +// SimPoliciesClientCreateOrUpdateResponse contains the response from method SimPoliciesClient.BeginCreateOrUpdate. type SimPoliciesClientCreateOrUpdateResponse struct { SimPolicy } -// SimPoliciesClientDeleteResponse contains the response from method SimPoliciesClient.Delete. +// SimPoliciesClientDeleteResponse contains the response from method SimPoliciesClient.BeginDelete. type SimPoliciesClientDeleteResponse struct { // placeholder for future response values } @@ -244,7 +244,7 @@ type SimPoliciesClientGetResponse struct { SimPolicy } -// SimPoliciesClientListByMobileNetworkResponse contains the response from method SimPoliciesClient.ListByMobileNetwork. +// SimPoliciesClientListByMobileNetworkResponse contains the response from method SimPoliciesClient.NewListByMobileNetworkPager. type SimPoliciesClientListByMobileNetworkResponse struct { SimPolicyListResult } @@ -254,27 +254,27 @@ type SimPoliciesClientUpdateTagsResponse struct { SimPolicy } -// SimsClientBulkDeleteResponse contains the response from method SimsClient.BulkDelete. +// SimsClientBulkDeleteResponse contains the response from method SimsClient.BeginBulkDelete. type SimsClientBulkDeleteResponse struct { AsyncOperationStatus } -// SimsClientBulkUploadEncryptedResponse contains the response from method SimsClient.BulkUploadEncrypted. +// SimsClientBulkUploadEncryptedResponse contains the response from method SimsClient.BeginBulkUploadEncrypted. type SimsClientBulkUploadEncryptedResponse struct { AsyncOperationStatus } -// SimsClientBulkUploadResponse contains the response from method SimsClient.BulkUpload. +// SimsClientBulkUploadResponse contains the response from method SimsClient.BeginBulkUpload. type SimsClientBulkUploadResponse struct { AsyncOperationStatus } -// SimsClientCreateOrUpdateResponse contains the response from method SimsClient.CreateOrUpdate. +// SimsClientCreateOrUpdateResponse contains the response from method SimsClient.BeginCreateOrUpdate. type SimsClientCreateOrUpdateResponse struct { Sim } -// SimsClientDeleteResponse contains the response from method SimsClient.Delete. +// SimsClientDeleteResponse contains the response from method SimsClient.BeginDelete. type SimsClientDeleteResponse struct { // placeholder for future response values } @@ -284,17 +284,17 @@ type SimsClientGetResponse struct { Sim } -// SimsClientListByGroupResponse contains the response from method SimsClient.ListByGroup. +// SimsClientListByGroupResponse contains the response from method SimsClient.NewListByGroupPager. type SimsClientListByGroupResponse struct { SimListResult } -// SitesClientCreateOrUpdateResponse contains the response from method SitesClient.CreateOrUpdate. +// SitesClientCreateOrUpdateResponse contains the response from method SitesClient.BeginCreateOrUpdate. type SitesClientCreateOrUpdateResponse struct { Site } -// SitesClientDeleteResponse contains the response from method SitesClient.Delete. +// SitesClientDeleteResponse contains the response from method SitesClient.BeginDelete. type SitesClientDeleteResponse struct { // placeholder for future response values } @@ -304,7 +304,7 @@ type SitesClientGetResponse struct { Site } -// SitesClientListByMobileNetworkResponse contains the response from method SitesClient.ListByMobileNetwork. +// SitesClientListByMobileNetworkResponse contains the response from method SitesClient.NewListByMobileNetworkPager. type SitesClientListByMobileNetworkResponse struct { SiteListResult } @@ -314,12 +314,12 @@ type SitesClientUpdateTagsResponse struct { Site } -// SlicesClientCreateOrUpdateResponse contains the response from method SlicesClient.CreateOrUpdate. +// SlicesClientCreateOrUpdateResponse contains the response from method SlicesClient.BeginCreateOrUpdate. type SlicesClientCreateOrUpdateResponse struct { Slice } -// SlicesClientDeleteResponse contains the response from method SlicesClient.Delete. +// SlicesClientDeleteResponse contains the response from method SlicesClient.BeginDelete. type SlicesClientDeleteResponse struct { // placeholder for future response values } @@ -329,7 +329,7 @@ type SlicesClientGetResponse struct { Slice } -// SlicesClientListByMobileNetworkResponse contains the response from method SlicesClient.ListByMobileNetwork. +// SlicesClientListByMobileNetworkResponse contains the response from method SlicesClient.NewListByMobileNetworkPager. type SlicesClientListByMobileNetworkResponse struct { SliceListResult } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/services_client.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/services_client.go index 2a1c36477701..d52948998765 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/services_client.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/services_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,67 +24,60 @@ import ( // ServicesClient contains the methods for the Services group. // Don't use this type directly, use NewServicesClient() instead. type ServicesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServicesClient creates a new instance of ServicesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServicesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServicesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ServicesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServicesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a service. Must be created in the same location as its parent mobile network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// serviceName - The name of the service. You must not use any of the following reserved strings - default, requested or service -// parameters - Parameters supplied to the create or update service operation. -// options - ServicesClientBeginCreateOrUpdateOptions contains the optional parameters for the ServicesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - serviceName - The name of the service. You must not use any of the following reserved strings - default, requested or service +// - parameters - Parameters supplied to the create or update service operation. +// - options - ServicesClientBeginCreateOrUpdateOptions contains the optional parameters for the ServicesClient.BeginCreateOrUpdate +// method. func (client *ServicesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, mobileNetworkName string, serviceName string, parameters Service, options *ServicesClientBeginCreateOrUpdateOptions) (*runtime.Poller[ServicesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, mobileNetworkName, serviceName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ServicesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ServicesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[ServicesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServicesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a service. Must be created in the same location as its parent mobile network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *ServicesClient) createOrUpdate(ctx context.Context, resourceGroupName string, mobileNetworkName string, serviceName string, parameters Service, options *ServicesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, mobileNetworkName, serviceName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -115,7 +106,7 @@ func (client *ServicesClient) createOrUpdateCreateRequest(ctx context.Context, r return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -128,34 +119,36 @@ func (client *ServicesClient) createOrUpdateCreateRequest(ctx context.Context, r // BeginDelete - Deletes the specified service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// serviceName - The name of the service. You must not use any of the following reserved strings - default, requested or service -// options - ServicesClientBeginDeleteOptions contains the optional parameters for the ServicesClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - serviceName - The name of the service. You must not use any of the following reserved strings - default, requested or service +// - options - ServicesClientBeginDeleteOptions contains the optional parameters for the ServicesClient.BeginDelete method. func (client *ServicesClient) BeginDelete(ctx context.Context, resourceGroupName string, mobileNetworkName string, serviceName string, options *ServicesClientBeginDeleteOptions) (*runtime.Poller[ServicesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, mobileNetworkName, serviceName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ServicesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ServicesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[ServicesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServicesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the specified service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *ServicesClient) deleteOperation(ctx context.Context, resourceGroupName string, mobileNetworkName string, serviceName string, options *ServicesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, mobileNetworkName, serviceName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -184,7 +177,7 @@ func (client *ServicesClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -197,17 +190,18 @@ func (client *ServicesClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Gets information about the specified service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// serviceName - The name of the service. You must not use any of the following reserved strings - default, requested or service -// options - ServicesClientGetOptions contains the optional parameters for the ServicesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - serviceName - The name of the service. You must not use any of the following reserved strings - default, requested or service +// - options - ServicesClientGetOptions contains the optional parameters for the ServicesClient.Get method. func (client *ServicesClient) Get(ctx context.Context, resourceGroupName string, mobileNetworkName string, serviceName string, options *ServicesClientGetOptions) (ServicesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, mobileNetworkName, serviceName, options) if err != nil { return ServicesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServicesClientGetResponse{}, err } @@ -236,7 +230,7 @@ func (client *ServicesClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -257,11 +251,12 @@ func (client *ServicesClient) getHandleResponse(resp *http.Response) (ServicesCl } // NewListByMobileNetworkPager - Gets all the services in a mobile network. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// options - ServicesClientListByMobileNetworkOptions contains the optional parameters for the ServicesClient.ListByMobileNetwork -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - options - ServicesClientListByMobileNetworkOptions contains the optional parameters for the ServicesClient.NewListByMobileNetworkPager +// method. func (client *ServicesClient) NewListByMobileNetworkPager(resourceGroupName string, mobileNetworkName string, options *ServicesClientListByMobileNetworkOptions) *runtime.Pager[ServicesClientListByMobileNetworkResponse] { return runtime.NewPager(runtime.PagingHandler[ServicesClientListByMobileNetworkResponse]{ More: func(page ServicesClientListByMobileNetworkResponse) bool { @@ -278,7 +273,7 @@ func (client *ServicesClient) NewListByMobileNetworkPager(resourceGroupName stri if err != nil { return ServicesClientListByMobileNetworkResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServicesClientListByMobileNetworkResponse{}, err } @@ -305,7 +300,7 @@ func (client *ServicesClient) listByMobileNetworkCreateRequest(ctx context.Conte return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -327,18 +322,19 @@ func (client *ServicesClient) listByMobileNetworkHandleResponse(resp *http.Respo // UpdateTags - Updates service tags. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// serviceName - The name of the service. You must not use any of the following reserved strings - default, requested or service -// parameters - Parameters supplied to update service tags. -// options - ServicesClientUpdateTagsOptions contains the optional parameters for the ServicesClient.UpdateTags method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - serviceName - The name of the service. You must not use any of the following reserved strings - default, requested or service +// - parameters - Parameters supplied to update service tags. +// - options - ServicesClientUpdateTagsOptions contains the optional parameters for the ServicesClient.UpdateTags method. func (client *ServicesClient) UpdateTags(ctx context.Context, resourceGroupName string, mobileNetworkName string, serviceName string, parameters TagsObject, options *ServicesClientUpdateTagsOptions) (ServicesClientUpdateTagsResponse, error) { req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, mobileNetworkName, serviceName, parameters, options) if err != nil { return ServicesClientUpdateTagsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServicesClientUpdateTagsResponse{}, err } @@ -367,7 +363,7 @@ func (client *ServicesClient) updateTagsCreateRequest(ctx context.Context, resou return nil, errors.New("parameter serviceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/services_client_example_test.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/services_client_example_test.go index 46fa0dc0d027..d488a409fb9e 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/services_client_example_test.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/services_client_example_test.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 armmobilenetwork_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mobilenetwork/armmobilenetwork/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/ServiceDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/ServiceDelete.json func ExampleServicesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewServicesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rg1", "testMobileNetwork", "TestService", nil) + poller, err := clientFactory.NewServicesClient().BeginDelete(ctx, "rg1", "testMobileNetwork", "TestService", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -38,37 +39,95 @@ func ExampleServicesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/ServiceGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/ServiceGet.json func ExampleServicesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewServicesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rg1", "testMobileNetwork", "TestService", nil) + res, err := clientFactory.NewServicesClient().Get(ctx, "rg1", "testMobileNetwork", "TestService", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Service = armmobilenetwork.Service{ + // Name: to.Ptr("testPolicy"), + // Type: to.Ptr("Microsoft.MobileNetwork/service"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/services/TestService"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.ServicePropertiesFormat{ + // PccRules: []*armmobilenetwork.PccRuleConfiguration{ + // { + // RuleName: to.Ptr("default-rule"), + // RulePrecedence: to.Ptr[int32](255), + // RuleQosPolicy: &armmobilenetwork.PccRuleQosPolicy{ + // FiveQi: to.Ptr[int32](9), + // AllocationAndRetentionPriorityLevel: to.Ptr[int32](9), + // MaximumBitRate: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // PreemptionCapability: to.Ptr(armmobilenetwork.PreemptionCapabilityNotPreempt), + // PreemptionVulnerability: to.Ptr(armmobilenetwork.PreemptionVulnerabilityPreemptable), + // }, + // ServiceDataFlowTemplates: []*armmobilenetwork.ServiceDataFlowTemplate{ + // { + // Direction: to.Ptr(armmobilenetwork.SdfDirectionUplink), + // Ports: []*string{ + // }, + // RemoteIPList: []*string{ + // to.Ptr("10.3.4.0/24")}, + // TemplateName: to.Ptr("IP-to-server"), + // Protocol: []*string{ + // to.Ptr("ip")}, + // }}, + // TrafficControl: to.Ptr(armmobilenetwork.TrafficControlPermissionEnabled), + // }}, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // ServicePrecedence: to.Ptr[int32](255), + // ServiceQosPolicy: &armmobilenetwork.QosPolicy{ + // FiveQi: to.Ptr[int32](9), + // AllocationAndRetentionPriorityLevel: to.Ptr[int32](9), + // MaximumBitRate: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // PreemptionCapability: to.Ptr(armmobilenetwork.PreemptionCapabilityNotPreempt), + // PreemptionVulnerability: to.Ptr(armmobilenetwork.PreemptionVulnerabilityPreemptable), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/ServiceCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/ServiceCreate.json func ExampleServicesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewServicesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "testMobileNetwork", "TestService", armmobilenetwork.Service{ + poller, err := clientFactory.NewServicesClient().BeginCreateOrUpdate(ctx, "rg1", "testMobileNetwork", "TestService", armmobilenetwork.Service{ Location: to.Ptr("eastus"), Properties: &armmobilenetwork.ServicePropertiesFormat{ PccRules: []*armmobilenetwork.PccRuleConfiguration{ @@ -117,22 +176,80 @@ func ExampleServicesClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Service = armmobilenetwork.Service{ + // Name: to.Ptr("testPolicy"), + // Type: to.Ptr("Microsoft.MobileNetwork/service"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/services/TestService"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.ServicePropertiesFormat{ + // PccRules: []*armmobilenetwork.PccRuleConfiguration{ + // { + // RuleName: to.Ptr("default-rule"), + // RulePrecedence: to.Ptr[int32](255), + // RuleQosPolicy: &armmobilenetwork.PccRuleQosPolicy{ + // FiveQi: to.Ptr[int32](9), + // AllocationAndRetentionPriorityLevel: to.Ptr[int32](9), + // MaximumBitRate: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // PreemptionCapability: to.Ptr(armmobilenetwork.PreemptionCapabilityNotPreempt), + // PreemptionVulnerability: to.Ptr(armmobilenetwork.PreemptionVulnerabilityPreemptable), + // }, + // ServiceDataFlowTemplates: []*armmobilenetwork.ServiceDataFlowTemplate{ + // { + // Direction: to.Ptr(armmobilenetwork.SdfDirectionUplink), + // Ports: []*string{ + // }, + // RemoteIPList: []*string{ + // to.Ptr("10.3.4.0/24")}, + // TemplateName: to.Ptr("IP-to-server"), + // Protocol: []*string{ + // to.Ptr("ip")}, + // }}, + // TrafficControl: to.Ptr(armmobilenetwork.TrafficControlPermissionEnabled), + // }}, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // ServicePrecedence: to.Ptr[int32](255), + // ServiceQosPolicy: &armmobilenetwork.QosPolicy{ + // FiveQi: to.Ptr[int32](9), + // AllocationAndRetentionPriorityLevel: to.Ptr[int32](9), + // MaximumBitRate: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // PreemptionCapability: to.Ptr(armmobilenetwork.PreemptionCapabilityNotPreempt), + // PreemptionVulnerability: to.Ptr(armmobilenetwork.PreemptionVulnerabilityPreemptable), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/ServiceUpdateTags.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/ServiceUpdateTags.json func ExampleServicesClient_UpdateTags() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewServicesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.UpdateTags(ctx, "rg1", "testMobileNetwork", "TestService", armmobilenetwork.TagsObject{ + res, err := clientFactory.NewServicesClient().UpdateTags(ctx, "rg1", "testMobileNetwork", "TestService", armmobilenetwork.TagsObject{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -141,30 +258,150 @@ func ExampleServicesClient_UpdateTags() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Service = armmobilenetwork.Service{ + // Name: to.Ptr("TestService"), + // Type: to.Ptr("Microsoft.MobileNetwork/service"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/services/TestService"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armmobilenetwork.ServicePropertiesFormat{ + // PccRules: []*armmobilenetwork.PccRuleConfiguration{ + // { + // RuleName: to.Ptr("default-rule"), + // RulePrecedence: to.Ptr[int32](255), + // RuleQosPolicy: &armmobilenetwork.PccRuleQosPolicy{ + // FiveQi: to.Ptr[int32](9), + // AllocationAndRetentionPriorityLevel: to.Ptr[int32](9), + // MaximumBitRate: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // PreemptionCapability: to.Ptr(armmobilenetwork.PreemptionCapabilityNotPreempt), + // PreemptionVulnerability: to.Ptr(armmobilenetwork.PreemptionVulnerabilityPreemptable), + // }, + // ServiceDataFlowTemplates: []*armmobilenetwork.ServiceDataFlowTemplate{ + // { + // Direction: to.Ptr(armmobilenetwork.SdfDirectionUplink), + // Ports: []*string{ + // }, + // RemoteIPList: []*string{ + // to.Ptr("10.3.4.0/24")}, + // TemplateName: to.Ptr("IP-to-server"), + // Protocol: []*string{ + // to.Ptr("ip")}, + // }}, + // TrafficControl: to.Ptr(armmobilenetwork.TrafficControlPermissionEnabled), + // }}, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // ServicePrecedence: to.Ptr[int32](255), + // ServiceQosPolicy: &armmobilenetwork.QosPolicy{ + // FiveQi: to.Ptr[int32](9), + // AllocationAndRetentionPriorityLevel: to.Ptr[int32](9), + // MaximumBitRate: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // PreemptionCapability: to.Ptr(armmobilenetwork.PreemptionCapabilityNotPreempt), + // PreemptionVulnerability: to.Ptr(armmobilenetwork.PreemptionVulnerabilityPreemptable), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/ServiceListByMobileNetwork.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/ServiceListByMobileNetwork.json func ExampleServicesClient_NewListByMobileNetworkPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewServicesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByMobileNetworkPager("testResourceGroupName", "testMobileNetwork", nil) + pager := clientFactory.NewServicesClient().NewListByMobileNetworkPager("testResourceGroupName", "testMobileNetwork", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ServiceListResult = armmobilenetwork.ServiceListResult{ + // Value: []*armmobilenetwork.Service{ + // { + // Type: to.Ptr("Microsoft.MobileNetwork/service"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/services/TestService"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.ServicePropertiesFormat{ + // PccRules: []*armmobilenetwork.PccRuleConfiguration{ + // { + // RuleName: to.Ptr("default-rule"), + // RulePrecedence: to.Ptr[int32](255), + // RuleQosPolicy: &armmobilenetwork.PccRuleQosPolicy{ + // FiveQi: to.Ptr[int32](9), + // AllocationAndRetentionPriorityLevel: to.Ptr[int32](9), + // MaximumBitRate: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // PreemptionCapability: to.Ptr(armmobilenetwork.PreemptionCapabilityNotPreempt), + // PreemptionVulnerability: to.Ptr(armmobilenetwork.PreemptionVulnerabilityPreemptable), + // }, + // ServiceDataFlowTemplates: []*armmobilenetwork.ServiceDataFlowTemplate{ + // { + // Direction: to.Ptr(armmobilenetwork.SdfDirectionUplink), + // Ports: []*string{ + // }, + // RemoteIPList: []*string{ + // to.Ptr("10.3.4.0/24")}, + // TemplateName: to.Ptr("IP-to-server"), + // Protocol: []*string{ + // to.Ptr("ip")}, + // }}, + // TrafficControl: to.Ptr(armmobilenetwork.TrafficControlPermissionEnabled), + // }}, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // ServicePrecedence: to.Ptr[int32](255), + // ServiceQosPolicy: &armmobilenetwork.QosPolicy{ + // FiveQi: to.Ptr[int32](9), + // AllocationAndRetentionPriorityLevel: to.Ptr[int32](9), + // MaximumBitRate: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // PreemptionCapability: to.Ptr(armmobilenetwork.PreemptionCapabilityNotPreempt), + // PreemptionVulnerability: to.Ptr(armmobilenetwork.PreemptionVulnerabilityPreemptable), + // }, + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simgroups_client.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simgroups_client.go index c5c4140406eb..50ce00c392cd 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simgroups_client.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simgroups_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,66 +24,59 @@ import ( // SimGroupsClient contains the methods for the SimGroups group. // Don't use this type directly, use NewSimGroupsClient() instead. type SimGroupsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSimGroupsClient creates a new instance of SimGroupsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSimGroupsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SimGroupsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SimGroupsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SimGroupsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a SIM group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// simGroupName - The name of the SIM Group. -// parameters - Parameters supplied to the create or update SIM group operation. -// options - SimGroupsClientBeginCreateOrUpdateOptions contains the optional parameters for the SimGroupsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - simGroupName - The name of the SIM Group. +// - parameters - Parameters supplied to the create or update SIM group operation. +// - options - SimGroupsClientBeginCreateOrUpdateOptions contains the optional parameters for the SimGroupsClient.BeginCreateOrUpdate +// method. func (client *SimGroupsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, simGroupName string, parameters SimGroup, options *SimGroupsClientBeginCreateOrUpdateOptions) (*runtime.Poller[SimGroupsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, simGroupName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SimGroupsClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SimGroupsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[SimGroupsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SimGroupsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a SIM group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *SimGroupsClient) createOrUpdate(ctx context.Context, resourceGroupName string, simGroupName string, parameters SimGroup, options *SimGroupsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, simGroupName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -110,7 +101,7 @@ func (client *SimGroupsClient) createOrUpdateCreateRequest(ctx context.Context, return nil, errors.New("parameter simGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{simGroupName}", url.PathEscape(simGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -123,33 +114,35 @@ func (client *SimGroupsClient) createOrUpdateCreateRequest(ctx context.Context, // BeginDelete - Deletes the specified SIM group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// simGroupName - The name of the SIM Group. -// options - SimGroupsClientBeginDeleteOptions contains the optional parameters for the SimGroupsClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - simGroupName - The name of the SIM Group. +// - options - SimGroupsClientBeginDeleteOptions contains the optional parameters for the SimGroupsClient.BeginDelete method. func (client *SimGroupsClient) BeginDelete(ctx context.Context, resourceGroupName string, simGroupName string, options *SimGroupsClientBeginDeleteOptions) (*runtime.Poller[SimGroupsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, simGroupName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SimGroupsClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SimGroupsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SimGroupsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SimGroupsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the specified SIM group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *SimGroupsClient) deleteOperation(ctx context.Context, resourceGroupName string, simGroupName string, options *SimGroupsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, simGroupName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -174,7 +167,7 @@ func (client *SimGroupsClient) deleteCreateRequest(ctx context.Context, resource return nil, errors.New("parameter simGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{simGroupName}", url.PathEscape(simGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -187,16 +180,17 @@ func (client *SimGroupsClient) deleteCreateRequest(ctx context.Context, resource // Get - Gets information about the specified SIM group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// simGroupName - The name of the SIM Group. -// options - SimGroupsClientGetOptions contains the optional parameters for the SimGroupsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - simGroupName - The name of the SIM Group. +// - options - SimGroupsClientGetOptions contains the optional parameters for the SimGroupsClient.Get method. func (client *SimGroupsClient) Get(ctx context.Context, resourceGroupName string, simGroupName string, options *SimGroupsClientGetOptions) (SimGroupsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, simGroupName, options) if err != nil { return SimGroupsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SimGroupsClientGetResponse{}, err } @@ -221,7 +215,7 @@ func (client *SimGroupsClient) getCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter simGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{simGroupName}", url.PathEscape(simGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -242,10 +236,11 @@ func (client *SimGroupsClient) getHandleResponse(resp *http.Response) (SimGroups } // NewListByResourceGroupPager - Gets all the SIM groups in a resource group. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - SimGroupsClientListByResourceGroupOptions contains the optional parameters for the SimGroupsClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - SimGroupsClientListByResourceGroupOptions contains the optional parameters for the SimGroupsClient.NewListByResourceGroupPager +// method. func (client *SimGroupsClient) NewListByResourceGroupPager(resourceGroupName string, options *SimGroupsClientListByResourceGroupOptions) *runtime.Pager[SimGroupsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[SimGroupsClientListByResourceGroupResponse]{ More: func(page SimGroupsClientListByResourceGroupResponse) bool { @@ -262,7 +257,7 @@ func (client *SimGroupsClient) NewListByResourceGroupPager(resourceGroupName str if err != nil { return SimGroupsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SimGroupsClientListByResourceGroupResponse{}, err } @@ -285,7 +280,7 @@ func (client *SimGroupsClient) listByResourceGroupCreateRequest(ctx context.Cont return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -306,9 +301,10 @@ func (client *SimGroupsClient) listByResourceGroupHandleResponse(resp *http.Resp } // NewListBySubscriptionPager - Gets all the SIM groups in a subscription. +// // Generated from API version 2022-11-01 -// options - SimGroupsClientListBySubscriptionOptions contains the optional parameters for the SimGroupsClient.ListBySubscription -// method. +// - options - SimGroupsClientListBySubscriptionOptions contains the optional parameters for the SimGroupsClient.NewListBySubscriptionPager +// method. func (client *SimGroupsClient) NewListBySubscriptionPager(options *SimGroupsClientListBySubscriptionOptions) *runtime.Pager[SimGroupsClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[SimGroupsClientListBySubscriptionResponse]{ More: func(page SimGroupsClientListBySubscriptionResponse) bool { @@ -325,7 +321,7 @@ func (client *SimGroupsClient) NewListBySubscriptionPager(options *SimGroupsClie if err != nil { return SimGroupsClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SimGroupsClientListBySubscriptionResponse{}, err } @@ -344,7 +340,7 @@ func (client *SimGroupsClient) listBySubscriptionCreateRequest(ctx context.Conte return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -366,17 +362,18 @@ func (client *SimGroupsClient) listBySubscriptionHandleResponse(resp *http.Respo // UpdateTags - Updates SIM group tags. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// simGroupName - The name of the SIM Group. -// parameters - Parameters supplied to update SIM group tags. -// options - SimGroupsClientUpdateTagsOptions contains the optional parameters for the SimGroupsClient.UpdateTags method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - simGroupName - The name of the SIM Group. +// - parameters - Parameters supplied to update SIM group tags. +// - options - SimGroupsClientUpdateTagsOptions contains the optional parameters for the SimGroupsClient.UpdateTags method. func (client *SimGroupsClient) UpdateTags(ctx context.Context, resourceGroupName string, simGroupName string, parameters TagsObject, options *SimGroupsClientUpdateTagsOptions) (SimGroupsClientUpdateTagsResponse, error) { req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, simGroupName, parameters, options) if err != nil { return SimGroupsClientUpdateTagsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SimGroupsClientUpdateTagsResponse{}, err } @@ -401,7 +398,7 @@ func (client *SimGroupsClient) updateTagsCreateRequest(ctx context.Context, reso return nil, errors.New("parameter simGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{simGroupName}", url.PathEscape(simGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simgroups_client_example_test.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simgroups_client_example_test.go index 4ab8b09a060c..2c6784b4a903 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simgroups_client_example_test.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simgroups_client_example_test.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 armmobilenetwork_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mobilenetwork/armmobilenetwork/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupDelete.json func ExampleSimGroupsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimGroupsClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "testResourceGroupName", "testSimGroup", nil) + poller, err := clientFactory.NewSimGroupsClient().BeginDelete(ctx, "testResourceGroupName", "testSimGroup", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -38,37 +39,72 @@ func ExampleSimGroupsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupGet.json func ExampleSimGroupsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimGroupsClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "testResourceGroupName", "testSimGroupName", nil) + res, err := clientFactory.NewSimGroupsClient().Get(ctx, "testResourceGroupName", "testSimGroupName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SimGroup = armmobilenetwork.SimGroup{ + // Name: to.Ptr("testSimGroup"), + // Type: to.Ptr("Microsoft.MobileNetwork/simGroups"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/simGroups/testSimGroup"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Identity: &armmobilenetwork.ManagedServiceIdentity{ + // Type: to.Ptr(armmobilenetwork.ManagedServiceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armmobilenetwork.UserAssignedIdentity{ + // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testUserAssignedManagedIdentity": &armmobilenetwork.UserAssignedIdentity{ + // ClientID: to.Ptr("12345678-abcd-dcba-abcd-0123456789ef"), + // PrincipalID: to.Ptr("12345678-abcd-dcba-abcd-0123456789ef"), + // }, + // }, + // }, + // Properties: &armmobilenetwork.SimGroupPropertiesFormat{ + // EncryptionKey: &armmobilenetwork.KeyVaultKey{ + // KeyURL: to.Ptr("https://contosovault.vault.azure.net/keys/azureKey"), + // }, + // MobileNetwork: &armmobilenetwork.ResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork"), + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupCreate.json func ExampleSimGroupsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimGroupsClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "testSimGroup", armmobilenetwork.SimGroup{ + poller, err := clientFactory.NewSimGroupsClient().BeginCreateOrUpdate(ctx, "rg1", "testSimGroup", armmobilenetwork.SimGroup{ Location: to.Ptr("eastus"), Identity: &armmobilenetwork.ManagedServiceIdentity{ Type: to.Ptr(armmobilenetwork.ManagedServiceIdentityTypeUserAssigned), @@ -92,22 +128,57 @@ func ExampleSimGroupsClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SimGroup = armmobilenetwork.SimGroup{ + // Name: to.Ptr("testSimGroup"), + // Type: to.Ptr("Microsoft.MobileNetwork/simGroups"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/simGroups/testSimGroup"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Identity: &armmobilenetwork.ManagedServiceIdentity{ + // Type: to.Ptr(armmobilenetwork.ManagedServiceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armmobilenetwork.UserAssignedIdentity{ + // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testUserAssignedManagedIdentity": &armmobilenetwork.UserAssignedIdentity{ + // ClientID: to.Ptr("12345678-abcd-dcba-abcd-0123456789ef"), + // PrincipalID: to.Ptr("12345678-abcd-dcba-abcd-0123456789ef"), + // }, + // }, + // }, + // Properties: &armmobilenetwork.SimGroupPropertiesFormat{ + // EncryptionKey: &armmobilenetwork.KeyVaultKey{ + // KeyURL: to.Ptr("https://contosovault.vault.azure.net/keys/azureKey"), + // }, + // MobileNetwork: &armmobilenetwork.ResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork"), + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupUpdateTags.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupUpdateTags.json func ExampleSimGroupsClient_UpdateTags() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimGroupsClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.UpdateTags(ctx, "rg1", "testSimGroup", armmobilenetwork.TagsObject{ + res, err := clientFactory.NewSimGroupsClient().UpdateTags(ctx, "rg1", "testSimGroup", armmobilenetwork.TagsObject{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -116,54 +187,167 @@ func ExampleSimGroupsClient_UpdateTags() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SimGroup = armmobilenetwork.SimGroup{ + // Name: to.Ptr("testSimGroup"), + // Type: to.Ptr("Microsoft.MobileNetwork/simGroups"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/simGroups/testSimGroup"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Identity: &armmobilenetwork.ManagedServiceIdentity{ + // Type: to.Ptr(armmobilenetwork.ManagedServiceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armmobilenetwork.UserAssignedIdentity{ + // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testUserAssignedManagedIdentity": &armmobilenetwork.UserAssignedIdentity{ + // ClientID: to.Ptr("12345678-abcd-dcba-abcd-0123456789ef"), + // PrincipalID: to.Ptr("12345678-abcd-dcba-abcd-0123456789ef"), + // }, + // }, + // }, + // Properties: &armmobilenetwork.SimGroupPropertiesFormat{ + // EncryptionKey: &armmobilenetwork.KeyVaultKey{ + // KeyURL: to.Ptr("https://contosovault.vault.azure.net/keys/azureKey"), + // }, + // MobileNetwork: &armmobilenetwork.ResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork"), + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupListBySubscription.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupListBySubscription.json func ExampleSimGroupsClient_NewListBySubscriptionPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimGroupsClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySubscriptionPager(nil) + pager := clientFactory.NewSimGroupsClient().NewListBySubscriptionPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SimGroupListResult = armmobilenetwork.SimGroupListResult{ + // Value: []*armmobilenetwork.SimGroup{ + // { + // Name: to.Ptr("testSimGroup"), + // Type: to.Ptr("Microsoft.MobileNetwork/simGroups"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/simGroups/testSimGroup"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Identity: &armmobilenetwork.ManagedServiceIdentity{ + // Type: to.Ptr(armmobilenetwork.ManagedServiceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armmobilenetwork.UserAssignedIdentity{ + // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testUserAssignedManagedIdentity": &armmobilenetwork.UserAssignedIdentity{ + // ClientID: to.Ptr("12345678-abcd-dcba-abcd-0123456789ef"), + // PrincipalID: to.Ptr("12345678-abcd-dcba-abcd-0123456789ef"), + // }, + // }, + // }, + // Properties: &armmobilenetwork.SimGroupPropertiesFormat{ + // EncryptionKey: &armmobilenetwork.KeyVaultKey{ + // KeyURL: to.Ptr("https://contosovault.vault.azure.net/keys/azureKey"), + // }, + // MobileNetwork: &armmobilenetwork.ResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork"), + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupListByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupListByResourceGroup.json func ExampleSimGroupsClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimGroupsClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("rg1", nil) + pager := clientFactory.NewSimGroupsClient().NewListByResourceGroupPager("rg1", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SimGroupListResult = armmobilenetwork.SimGroupListResult{ + // Value: []*armmobilenetwork.SimGroup{ + // { + // Name: to.Ptr("testSimGroup"), + // Type: to.Ptr("Microsoft.MobileNetwork/simGroups"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/simGroups/testSimGroup"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Identity: &armmobilenetwork.ManagedServiceIdentity{ + // Type: to.Ptr(armmobilenetwork.ManagedServiceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armmobilenetwork.UserAssignedIdentity{ + // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testUserAssignedManagedIdentity": &armmobilenetwork.UserAssignedIdentity{ + // ClientID: to.Ptr("12345678-abcd-dcba-abcd-0123456789ef"), + // PrincipalID: to.Ptr("12345678-abcd-dcba-abcd-0123456789ef"), + // }, + // }, + // }, + // Properties: &armmobilenetwork.SimGroupPropertiesFormat{ + // EncryptionKey: &armmobilenetwork.KeyVaultKey{ + // KeyURL: to.Ptr("https://contosovault.vault.azure.net/keys/azureKey"), + // }, + // MobileNetwork: &armmobilenetwork.ResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork"), + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simpolicies_client.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simpolicies_client.go index 7a0dde17e67f..2e63e02dcc1f 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simpolicies_client.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simpolicies_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,67 +24,60 @@ import ( // SimPoliciesClient contains the methods for the SimPolicies group. // Don't use this type directly, use NewSimPoliciesClient() instead. type SimPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSimPoliciesClient creates a new instance of SimPoliciesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSimPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SimPoliciesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SimPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SimPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a SIM policy. Must be created in the same location as its parent mobile network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// simPolicyName - The name of the SIM policy. -// parameters - Parameters supplied to the create or update SIM policy operation. -// options - SimPoliciesClientBeginCreateOrUpdateOptions contains the optional parameters for the SimPoliciesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - simPolicyName - The name of the SIM policy. +// - parameters - Parameters supplied to the create or update SIM policy operation. +// - options - SimPoliciesClientBeginCreateOrUpdateOptions contains the optional parameters for the SimPoliciesClient.BeginCreateOrUpdate +// method. func (client *SimPoliciesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, mobileNetworkName string, simPolicyName string, parameters SimPolicy, options *SimPoliciesClientBeginCreateOrUpdateOptions) (*runtime.Poller[SimPoliciesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, mobileNetworkName, simPolicyName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SimPoliciesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SimPoliciesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[SimPoliciesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SimPoliciesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a SIM policy. Must be created in the same location as its parent mobile network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *SimPoliciesClient) createOrUpdate(ctx context.Context, resourceGroupName string, mobileNetworkName string, simPolicyName string, parameters SimPolicy, options *SimPoliciesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, mobileNetworkName, simPolicyName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -115,7 +106,7 @@ func (client *SimPoliciesClient) createOrUpdateCreateRequest(ctx context.Context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -128,34 +119,36 @@ func (client *SimPoliciesClient) createOrUpdateCreateRequest(ctx context.Context // BeginDelete - Deletes the specified SIM policy. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// simPolicyName - The name of the SIM policy. -// options - SimPoliciesClientBeginDeleteOptions contains the optional parameters for the SimPoliciesClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - simPolicyName - The name of the SIM policy. +// - options - SimPoliciesClientBeginDeleteOptions contains the optional parameters for the SimPoliciesClient.BeginDelete method. func (client *SimPoliciesClient) BeginDelete(ctx context.Context, resourceGroupName string, mobileNetworkName string, simPolicyName string, options *SimPoliciesClientBeginDeleteOptions) (*runtime.Poller[SimPoliciesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, mobileNetworkName, simPolicyName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SimPoliciesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SimPoliciesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SimPoliciesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SimPoliciesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the specified SIM policy. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *SimPoliciesClient) deleteOperation(ctx context.Context, resourceGroupName string, mobileNetworkName string, simPolicyName string, options *SimPoliciesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, mobileNetworkName, simPolicyName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -184,7 +177,7 @@ func (client *SimPoliciesClient) deleteCreateRequest(ctx context.Context, resour return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -197,17 +190,18 @@ func (client *SimPoliciesClient) deleteCreateRequest(ctx context.Context, resour // Get - Gets information about the specified SIM policy. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// simPolicyName - The name of the SIM policy. -// options - SimPoliciesClientGetOptions contains the optional parameters for the SimPoliciesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - simPolicyName - The name of the SIM policy. +// - options - SimPoliciesClientGetOptions contains the optional parameters for the SimPoliciesClient.Get method. func (client *SimPoliciesClient) Get(ctx context.Context, resourceGroupName string, mobileNetworkName string, simPolicyName string, options *SimPoliciesClientGetOptions) (SimPoliciesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, mobileNetworkName, simPolicyName, options) if err != nil { return SimPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SimPoliciesClientGetResponse{}, err } @@ -236,7 +230,7 @@ func (client *SimPoliciesClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -257,11 +251,12 @@ func (client *SimPoliciesClient) getHandleResponse(resp *http.Response) (SimPoli } // NewListByMobileNetworkPager - Gets all the SIM policies in a mobile network. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// options - SimPoliciesClientListByMobileNetworkOptions contains the optional parameters for the SimPoliciesClient.ListByMobileNetwork -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - options - SimPoliciesClientListByMobileNetworkOptions contains the optional parameters for the SimPoliciesClient.NewListByMobileNetworkPager +// method. func (client *SimPoliciesClient) NewListByMobileNetworkPager(resourceGroupName string, mobileNetworkName string, options *SimPoliciesClientListByMobileNetworkOptions) *runtime.Pager[SimPoliciesClientListByMobileNetworkResponse] { return runtime.NewPager(runtime.PagingHandler[SimPoliciesClientListByMobileNetworkResponse]{ More: func(page SimPoliciesClientListByMobileNetworkResponse) bool { @@ -278,7 +273,7 @@ func (client *SimPoliciesClient) NewListByMobileNetworkPager(resourceGroupName s if err != nil { return SimPoliciesClientListByMobileNetworkResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SimPoliciesClientListByMobileNetworkResponse{}, err } @@ -305,7 +300,7 @@ func (client *SimPoliciesClient) listByMobileNetworkCreateRequest(ctx context.Co return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -327,18 +322,19 @@ func (client *SimPoliciesClient) listByMobileNetworkHandleResponse(resp *http.Re // UpdateTags - Updates SIM policy tags. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// simPolicyName - The name of the SIM policy. -// parameters - Parameters supplied to update SIM policy tags. -// options - SimPoliciesClientUpdateTagsOptions contains the optional parameters for the SimPoliciesClient.UpdateTags method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - simPolicyName - The name of the SIM policy. +// - parameters - Parameters supplied to update SIM policy tags. +// - options - SimPoliciesClientUpdateTagsOptions contains the optional parameters for the SimPoliciesClient.UpdateTags method. func (client *SimPoliciesClient) UpdateTags(ctx context.Context, resourceGroupName string, mobileNetworkName string, simPolicyName string, parameters TagsObject, options *SimPoliciesClientUpdateTagsOptions) (SimPoliciesClientUpdateTagsResponse, error) { req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, mobileNetworkName, simPolicyName, parameters, options) if err != nil { return SimPoliciesClientUpdateTagsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SimPoliciesClientUpdateTagsResponse{}, err } @@ -367,7 +363,7 @@ func (client *SimPoliciesClient) updateTagsCreateRequest(ctx context.Context, re return nil, errors.New("parameter simPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{simPolicyName}", url.PathEscape(simPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simpolicies_client_example_test.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simpolicies_client_example_test.go index 9ee4775a54ca..481d08a420d7 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simpolicies_client_example_test.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/simpolicies_client_example_test.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 armmobilenetwork_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mobilenetwork/armmobilenetwork/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimPolicyDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimPolicyDelete.json func ExampleSimPoliciesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimPoliciesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rg1", "testMobileNetwork", "testPolicy", nil) + poller, err := clientFactory.NewSimPoliciesClient().BeginDelete(ctx, "rg1", "testMobileNetwork", "testPolicy", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -38,37 +39,100 @@ func ExampleSimPoliciesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimPolicyGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimPolicyGet.json func ExampleSimPoliciesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimPoliciesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rg1", "testMobileNetwork", "testPolicy", nil) + res, err := clientFactory.NewSimPoliciesClient().Get(ctx, "rg1", "testMobileNetwork", "testPolicy", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SimPolicy = armmobilenetwork.SimPolicy{ + // Name: to.Ptr("testPolicy"), + // Type: to.Ptr("Microsoft.MobileNetwork/simPolicy"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/testPolicy"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.SimPolicyPropertiesFormat{ + // DefaultSlice: &armmobilenetwork.SliceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // RegistrationTimer: to.Ptr[int32](3240), + // SiteProvisioningState: map[string]*armmobilenetwork.SiteProvisioningState{ + // "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite": to.Ptr(armmobilenetwork.SiteProvisioningStateAdding), + // "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite2": to.Ptr(armmobilenetwork.SiteProvisioningStateAdding), + // }, + // SliceConfigurations: []*armmobilenetwork.SliceConfiguration{ + // { + // DataNetworkConfigurations: []*armmobilenetwork.DataNetworkConfiguration{ + // { + // FiveQi: to.Ptr[int32](9), + // AdditionalAllowedSessionTypes: []*armmobilenetwork.PduSessionType{ + // }, + // AllocationAndRetentionPriorityLevel: to.Ptr[int32](9), + // AllowedServices: []*armmobilenetwork.ServiceResourceID{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/services/testService"), + // }}, + // DataNetwork: &armmobilenetwork.DataNetworkResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testdataNetwork"), + // }, + // DefaultSessionType: to.Ptr(armmobilenetwork.PduSessionTypeIPv4), + // MaximumNumberOfBufferedPackets: to.Ptr[int32](200), + // PreemptionCapability: to.Ptr(armmobilenetwork.PreemptionCapabilityNotPreempt), + // PreemptionVulnerability: to.Ptr(armmobilenetwork.PreemptionVulnerabilityPreemptable), + // SessionAmbr: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // }}, + // DefaultDataNetwork: &armmobilenetwork.DataNetworkResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testdataNetwork"), + // }, + // Slice: &armmobilenetwork.SliceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + // }, + // }}, + // UeAmbr: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimPolicyCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimPolicyCreate.json func ExampleSimPoliciesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimPoliciesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "testMobileNetwork", "testPolicy", armmobilenetwork.SimPolicy{ + poller, err := clientFactory.NewSimPoliciesClient().BeginCreateOrUpdate(ctx, "rg1", "testMobileNetwork", "testPolicy", armmobilenetwork.SimPolicy{ Location: to.Ptr("eastus"), Properties: &armmobilenetwork.SimPolicyPropertiesFormat{ DefaultSlice: &armmobilenetwork.SliceResourceID{ @@ -118,22 +182,85 @@ func ExampleSimPoliciesClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SimPolicy = armmobilenetwork.SimPolicy{ + // Name: to.Ptr("testPolicy"), + // Type: to.Ptr("Microsoft.MobileNetwork/simPolicy"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/testPolicy"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.SimPolicyPropertiesFormat{ + // DefaultSlice: &armmobilenetwork.SliceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // RegistrationTimer: to.Ptr[int32](3240), + // SiteProvisioningState: map[string]*armmobilenetwork.SiteProvisioningState{ + // "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite": to.Ptr(armmobilenetwork.SiteProvisioningStateProvisioned), + // "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite2": to.Ptr(armmobilenetwork.SiteProvisioningStateProvisioned), + // }, + // SliceConfigurations: []*armmobilenetwork.SliceConfiguration{ + // { + // DataNetworkConfigurations: []*armmobilenetwork.DataNetworkConfiguration{ + // { + // FiveQi: to.Ptr[int32](9), + // AdditionalAllowedSessionTypes: []*armmobilenetwork.PduSessionType{ + // }, + // AllocationAndRetentionPriorityLevel: to.Ptr[int32](9), + // AllowedServices: []*armmobilenetwork.ServiceResourceID{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/services/testService"), + // }}, + // DataNetwork: &armmobilenetwork.DataNetworkResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testdataNetwork"), + // }, + // DefaultSessionType: to.Ptr(armmobilenetwork.PduSessionTypeIPv4), + // MaximumNumberOfBufferedPackets: to.Ptr[int32](200), + // PreemptionCapability: to.Ptr(armmobilenetwork.PreemptionCapabilityNotPreempt), + // PreemptionVulnerability: to.Ptr(armmobilenetwork.PreemptionVulnerabilityPreemptable), + // SessionAmbr: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // }}, + // DefaultDataNetwork: &armmobilenetwork.DataNetworkResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testdataNetwork"), + // }, + // Slice: &armmobilenetwork.SliceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + // }, + // }}, + // UeAmbr: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimPolicyUpdateTags.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimPolicyUpdateTags.json func ExampleSimPoliciesClient_UpdateTags() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimPoliciesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.UpdateTags(ctx, "rg1", "testMobileNetwork", "testPolicy", armmobilenetwork.TagsObject{ + res, err := clientFactory.NewSimPoliciesClient().UpdateTags(ctx, "rg1", "testMobileNetwork", "testPolicy", armmobilenetwork.TagsObject{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -142,30 +269,152 @@ func ExampleSimPoliciesClient_UpdateTags() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SimPolicy = armmobilenetwork.SimPolicy{ + // Name: to.Ptr("testPolicy"), + // Type: to.Ptr("Microsoft.MobileNetwork/simPolicy"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/testPolicy"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armmobilenetwork.SimPolicyPropertiesFormat{ + // DefaultSlice: &armmobilenetwork.SliceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // RegistrationTimer: to.Ptr[int32](3240), + // SliceConfigurations: []*armmobilenetwork.SliceConfiguration{ + // { + // DataNetworkConfigurations: []*armmobilenetwork.DataNetworkConfiguration{ + // { + // FiveQi: to.Ptr[int32](9), + // AdditionalAllowedSessionTypes: []*armmobilenetwork.PduSessionType{ + // }, + // AllocationAndRetentionPriorityLevel: to.Ptr[int32](9), + // AllowedServices: []*armmobilenetwork.ServiceResourceID{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/services/testService"), + // }}, + // DataNetwork: &armmobilenetwork.DataNetworkResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testdataNetwork"), + // }, + // DefaultSessionType: to.Ptr(armmobilenetwork.PduSessionTypeIPv4), + // MaximumNumberOfBufferedPackets: to.Ptr[int32](200), + // PreemptionCapability: to.Ptr(armmobilenetwork.PreemptionCapabilityNotPreempt), + // PreemptionVulnerability: to.Ptr(armmobilenetwork.PreemptionVulnerabilityPreemptable), + // SessionAmbr: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // }}, + // DefaultDataNetwork: &armmobilenetwork.DataNetworkResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testdataNetwork"), + // }, + // Slice: &armmobilenetwork.SliceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + // }, + // }}, + // UeAmbr: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimPolicyListByMobileNetwork.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimPolicyListByMobileNetwork.json func ExampleSimPoliciesClient_NewListByMobileNetworkPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimPoliciesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByMobileNetworkPager("testResourceGroupName", "testMobileNetwork", nil) + pager := clientFactory.NewSimPoliciesClient().NewListByMobileNetworkPager("testResourceGroupName", "testMobileNetwork", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SimPolicyListResult = armmobilenetwork.SimPolicyListResult{ + // Value: []*armmobilenetwork.SimPolicy{ + // { + // Type: to.Ptr("Microsoft.MobileNetwork/simPolicy"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/testPolicy"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.SimPolicyPropertiesFormat{ + // DefaultSlice: &armmobilenetwork.SliceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // RegistrationTimer: to.Ptr[int32](3240), + // SliceConfigurations: []*armmobilenetwork.SliceConfiguration{ + // { + // DataNetworkConfigurations: []*armmobilenetwork.DataNetworkConfiguration{ + // { + // FiveQi: to.Ptr[int32](9), + // AdditionalAllowedSessionTypes: []*armmobilenetwork.PduSessionType{ + // }, + // AllocationAndRetentionPriorityLevel: to.Ptr[int32](9), + // AllowedServices: []*armmobilenetwork.ServiceResourceID{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/services/testService"), + // }}, + // DataNetwork: &armmobilenetwork.DataNetworkResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testdataNetwork"), + // }, + // DefaultSessionType: to.Ptr(armmobilenetwork.PduSessionTypeIPv4), + // MaximumNumberOfBufferedPackets: to.Ptr[int32](200), + // PreemptionCapability: to.Ptr(armmobilenetwork.PreemptionCapabilityNotPreempt), + // PreemptionVulnerability: to.Ptr(armmobilenetwork.PreemptionVulnerabilityPreemptable), + // SessionAmbr: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // }}, + // DefaultDataNetwork: &armmobilenetwork.DataNetworkResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testdataNetwork"), + // }, + // Slice: &armmobilenetwork.SliceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + // }, + // }}, + // UeAmbr: &armmobilenetwork.Ambr{ + // Downlink: to.Ptr("1 Gbps"), + // Uplink: to.Ptr("500 Mbps"), + // }, + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sims_client.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sims_client.go index e4f594053418..ccec7a263977 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sims_client.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sims_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,65 +24,58 @@ import ( // SimsClient contains the methods for the Sims group. // Don't use this type directly, use NewSimsClient() instead. type SimsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSimsClient creates a new instance of SimsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSimsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SimsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SimsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SimsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginBulkDelete - Bulk delete SIMs from a SIM group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// simGroupName - The name of the SIM Group. -// parameters - Parameters supplied to the bulk SIM delete operation. -// options - SimsClientBeginBulkDeleteOptions contains the optional parameters for the SimsClient.BeginBulkDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - simGroupName - The name of the SIM Group. +// - parameters - Parameters supplied to the bulk SIM delete operation. +// - options - SimsClientBeginBulkDeleteOptions contains the optional parameters for the SimsClient.BeginBulkDelete method. func (client *SimsClient) BeginBulkDelete(ctx context.Context, resourceGroupName string, simGroupName string, parameters SimDeleteList, options *SimsClientBeginBulkDeleteOptions) (*runtime.Poller[SimsClientBulkDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.bulkDelete(ctx, resourceGroupName, simGroupName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SimsClientBulkDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SimsClientBulkDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SimsClientBulkDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SimsClientBulkDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // BulkDelete - Bulk delete SIMs from a SIM group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *SimsClient) bulkDelete(ctx context.Context, resourceGroupName string, simGroupName string, parameters SimDeleteList, options *SimsClientBeginBulkDeleteOptions) (*http.Response, error) { req, err := client.bulkDeleteCreateRequest(ctx, resourceGroupName, simGroupName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -109,7 +100,7 @@ func (client *SimsClient) bulkDeleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter simGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{simGroupName}", url.PathEscape(simGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -122,34 +113,36 @@ func (client *SimsClient) bulkDeleteCreateRequest(ctx context.Context, resourceG // BeginBulkUpload - Bulk upload SIMs to a SIM group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// simGroupName - The name of the SIM Group. -// parameters - Parameters supplied to the bulk SIM upload operation. -// options - SimsClientBeginBulkUploadOptions contains the optional parameters for the SimsClient.BeginBulkUpload method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - simGroupName - The name of the SIM Group. +// - parameters - Parameters supplied to the bulk SIM upload operation. +// - options - SimsClientBeginBulkUploadOptions contains the optional parameters for the SimsClient.BeginBulkUpload method. func (client *SimsClient) BeginBulkUpload(ctx context.Context, resourceGroupName string, simGroupName string, parameters SimUploadList, options *SimsClientBeginBulkUploadOptions) (*runtime.Poller[SimsClientBulkUploadResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.bulkUpload(ctx, resourceGroupName, simGroupName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SimsClientBulkUploadResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SimsClientBulkUploadResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SimsClientBulkUploadResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SimsClientBulkUploadResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // BulkUpload - Bulk upload SIMs to a SIM group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *SimsClient) bulkUpload(ctx context.Context, resourceGroupName string, simGroupName string, parameters SimUploadList, options *SimsClientBeginBulkUploadOptions) (*http.Response, error) { req, err := client.bulkUploadCreateRequest(ctx, resourceGroupName, simGroupName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -174,7 +167,7 @@ func (client *SimsClient) bulkUploadCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter simGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{simGroupName}", url.PathEscape(simGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -187,35 +180,37 @@ func (client *SimsClient) bulkUploadCreateRequest(ctx context.Context, resourceG // BeginBulkUploadEncrypted - Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// simGroupName - The name of the SIM Group. -// parameters - Parameters supplied to the encrypted SIMs upload operation. -// options - SimsClientBeginBulkUploadEncryptedOptions contains the optional parameters for the SimsClient.BeginBulkUploadEncrypted -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - simGroupName - The name of the SIM Group. +// - parameters - Parameters supplied to the encrypted SIMs upload operation. +// - options - SimsClientBeginBulkUploadEncryptedOptions contains the optional parameters for the SimsClient.BeginBulkUploadEncrypted +// method. func (client *SimsClient) BeginBulkUploadEncrypted(ctx context.Context, resourceGroupName string, simGroupName string, parameters EncryptedSimUploadList, options *SimsClientBeginBulkUploadEncryptedOptions) (*runtime.Poller[SimsClientBulkUploadEncryptedResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.bulkUploadEncrypted(ctx, resourceGroupName, simGroupName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SimsClientBulkUploadEncryptedResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SimsClientBulkUploadEncryptedResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SimsClientBulkUploadEncryptedResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SimsClientBulkUploadEncryptedResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // BulkUploadEncrypted - Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *SimsClient) bulkUploadEncrypted(ctx context.Context, resourceGroupName string, simGroupName string, parameters EncryptedSimUploadList, options *SimsClientBeginBulkUploadEncryptedOptions) (*http.Response, error) { req, err := client.bulkUploadEncryptedCreateRequest(ctx, resourceGroupName, simGroupName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -240,7 +235,7 @@ func (client *SimsClient) bulkUploadEncryptedCreateRequest(ctx context.Context, return nil, errors.New("parameter simGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{simGroupName}", url.PathEscape(simGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -253,36 +248,38 @@ func (client *SimsClient) bulkUploadEncryptedCreateRequest(ctx context.Context, // BeginCreateOrUpdate - Creates or updates a SIM. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// simGroupName - The name of the SIM Group. -// simName - The name of the SIM. -// parameters - Parameters supplied to the create or update SIM operation. -// options - SimsClientBeginCreateOrUpdateOptions contains the optional parameters for the SimsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - simGroupName - The name of the SIM Group. +// - simName - The name of the SIM. +// - parameters - Parameters supplied to the create or update SIM operation. +// - options - SimsClientBeginCreateOrUpdateOptions contains the optional parameters for the SimsClient.BeginCreateOrUpdate +// method. func (client *SimsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, simGroupName string, simName string, parameters Sim, options *SimsClientBeginCreateOrUpdateOptions) (*runtime.Poller[SimsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, simGroupName, simName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SimsClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SimsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[SimsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SimsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a SIM. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *SimsClient) createOrUpdate(ctx context.Context, resourceGroupName string, simGroupName string, simName string, parameters Sim, options *SimsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, simGroupName, simName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -311,7 +308,7 @@ func (client *SimsClient) createOrUpdateCreateRequest(ctx context.Context, resou return nil, errors.New("parameter simName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{simName}", url.PathEscape(simName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -324,34 +321,36 @@ func (client *SimsClient) createOrUpdateCreateRequest(ctx context.Context, resou // BeginDelete - Deletes the specified SIM. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// simGroupName - The name of the SIM Group. -// simName - The name of the SIM. -// options - SimsClientBeginDeleteOptions contains the optional parameters for the SimsClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - simGroupName - The name of the SIM Group. +// - simName - The name of the SIM. +// - options - SimsClientBeginDeleteOptions contains the optional parameters for the SimsClient.BeginDelete method. func (client *SimsClient) BeginDelete(ctx context.Context, resourceGroupName string, simGroupName string, simName string, options *SimsClientBeginDeleteOptions) (*runtime.Poller[SimsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, simGroupName, simName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SimsClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SimsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SimsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SimsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the specified SIM. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *SimsClient) deleteOperation(ctx context.Context, resourceGroupName string, simGroupName string, simName string, options *SimsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, simGroupName, simName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -380,7 +379,7 @@ func (client *SimsClient) deleteCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter simName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{simName}", url.PathEscape(simName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -393,17 +392,18 @@ func (client *SimsClient) deleteCreateRequest(ctx context.Context, resourceGroup // Get - Gets information about the specified SIM. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// simGroupName - The name of the SIM Group. -// simName - The name of the SIM. -// options - SimsClientGetOptions contains the optional parameters for the SimsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - simGroupName - The name of the SIM Group. +// - simName - The name of the SIM. +// - options - SimsClientGetOptions contains the optional parameters for the SimsClient.Get method. func (client *SimsClient) Get(ctx context.Context, resourceGroupName string, simGroupName string, simName string, options *SimsClientGetOptions) (SimsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, simGroupName, simName, options) if err != nil { return SimsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SimsClientGetResponse{}, err } @@ -432,7 +432,7 @@ func (client *SimsClient) getCreateRequest(ctx context.Context, resourceGroupNam return nil, errors.New("parameter simName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{simName}", url.PathEscape(simName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -453,10 +453,11 @@ func (client *SimsClient) getHandleResponse(resp *http.Response) (SimsClientGetR } // NewListByGroupPager - Gets all the SIMs in a SIM group. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// simGroupName - The name of the SIM Group. -// options - SimsClientListByGroupOptions contains the optional parameters for the SimsClient.ListByGroup method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - simGroupName - The name of the SIM Group. +// - options - SimsClientListByGroupOptions contains the optional parameters for the SimsClient.NewListByGroupPager method. func (client *SimsClient) NewListByGroupPager(resourceGroupName string, simGroupName string, options *SimsClientListByGroupOptions) *runtime.Pager[SimsClientListByGroupResponse] { return runtime.NewPager(runtime.PagingHandler[SimsClientListByGroupResponse]{ More: func(page SimsClientListByGroupResponse) bool { @@ -473,7 +474,7 @@ func (client *SimsClient) NewListByGroupPager(resourceGroupName string, simGroup if err != nil { return SimsClientListByGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SimsClientListByGroupResponse{}, err } @@ -500,7 +501,7 @@ func (client *SimsClient) listByGroupCreateRequest(ctx context.Context, resource return nil, errors.New("parameter simGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{simGroupName}", url.PathEscape(simGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sims_client_example_test.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sims_client_example_test.go index c867b165d333..f84028ec64e1 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sims_client_example_test.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sims_client_example_test.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 armmobilenetwork_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mobilenetwork/armmobilenetwork/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimDelete.json func ExampleSimsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimsClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "testResourceGroupName", "testSimGroup", "testSim", nil) + poller, err := clientFactory.NewSimsClient().BeginDelete(ctx, "testResourceGroupName", "testSimGroup", "testSim", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -38,37 +39,77 @@ func ExampleSimsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGet.json func ExampleSimsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimsClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "testResourceGroupName", "testSimGroup", "testSimName", nil) + res, err := clientFactory.NewSimsClient().Get(ctx, "testResourceGroupName", "testSimGroup", "testSimName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Sim = armmobilenetwork.Sim{ + // Name: to.Ptr("testSim"), + // Type: to.Ptr("Microsoft.MobileNetwork/simGroups/sims"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/simGroups/testSimGroup/sims/testSim"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Properties: &armmobilenetwork.SimPropertiesFormat{ + // DeviceType: to.Ptr("Video camera"), + // IntegratedCircuitCardIdentifier: to.Ptr("8900000000000000000"), + // InternationalMobileSubscriberIdentity: to.Ptr("00000"), + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // SimPolicy: &armmobilenetwork.SimPolicyResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/MySimPolicy"), + // }, + // SimState: to.Ptr(armmobilenetwork.SimStateEnabled), + // SiteProvisioningState: map[string]*armmobilenetwork.SiteProvisioningState{ + // "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite": to.Ptr(armmobilenetwork.SiteProvisioningStateProvisioned), + // "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite2": to.Ptr(armmobilenetwork.SiteProvisioningStateProvisioned), + // }, + // StaticIPConfiguration: []*armmobilenetwork.SimStaticIPProperties{ + // { + // AttachedDataNetwork: &armmobilenetwork.AttachedDataNetworkResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork"), + // }, + // Slice: &armmobilenetwork.SliceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + // }, + // StaticIP: &armmobilenetwork.SimStaticIPPropertiesStaticIP{ + // IPv4Address: to.Ptr("2.4.0.1"), + // }, + // }}, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimCreate.json func ExampleSimsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimsClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "testSimGroup", "testSim", armmobilenetwork.Sim{ + poller, err := clientFactory.NewSimsClient().BeginCreateOrUpdate(ctx, "rg1", "testSimGroup", "testSim", armmobilenetwork.Sim{ Properties: &armmobilenetwork.SimPropertiesFormat{ DeviceType: to.Ptr("Video camera"), IntegratedCircuitCardIdentifier: to.Ptr("8900000000000000000"), @@ -99,46 +140,129 @@ func ExampleSimsClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Sim = armmobilenetwork.Sim{ + // Name: to.Ptr("testSim"), + // Type: to.Ptr("Microsoft.MobileNetwork/simGroups/sims"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/simGroups/testSimGroup/sims/testSim"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Properties: &armmobilenetwork.SimPropertiesFormat{ + // DeviceType: to.Ptr("Video camera"), + // IntegratedCircuitCardIdentifier: to.Ptr("8900000000000000000"), + // InternationalMobileSubscriberIdentity: to.Ptr("00000"), + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // SimPolicy: &armmobilenetwork.SimPolicyResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/MySimPolicy"), + // }, + // SimState: to.Ptr(armmobilenetwork.SimStateEnabled), + // SiteProvisioningState: map[string]*armmobilenetwork.SiteProvisioningState{ + // "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite": to.Ptr(armmobilenetwork.SiteProvisioningStateProvisioned), + // "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite2": to.Ptr(armmobilenetwork.SiteProvisioningStateProvisioned), + // }, + // StaticIPConfiguration: []*armmobilenetwork.SimStaticIPProperties{ + // { + // AttachedDataNetwork: &armmobilenetwork.AttachedDataNetworkResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork"), + // }, + // Slice: &armmobilenetwork.SliceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + // }, + // StaticIP: &armmobilenetwork.SimStaticIPPropertiesStaticIP{ + // IPv4Address: to.Ptr("2.4.0.1"), + // }, + // }}, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimListBySimGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimListBySimGroup.json func ExampleSimsClient_NewListByGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimsClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByGroupPager("rg1", "testSimGroup", nil) + pager := clientFactory.NewSimsClient().NewListByGroupPager("rg1", "testSimGroup", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SimListResult = armmobilenetwork.SimListResult{ + // Value: []*armmobilenetwork.Sim{ + // { + // Name: to.Ptr("testSim"), + // Type: to.Ptr("Microsoft.MobileNetwork/simGroups/sims"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/simGroups/testSimGroup/sims/testSim"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Properties: &armmobilenetwork.SimPropertiesFormat{ + // DeviceType: to.Ptr("Video camera"), + // IntegratedCircuitCardIdentifier: to.Ptr("8900000000000000000"), + // InternationalMobileSubscriberIdentity: to.Ptr("00000"), + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // SimPolicy: &armmobilenetwork.SimPolicyResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/MySimPolicy"), + // }, + // SimState: to.Ptr(armmobilenetwork.SimStateEnabled), + // SiteProvisioningState: map[string]*armmobilenetwork.SiteProvisioningState{ + // "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite": to.Ptr(armmobilenetwork.SiteProvisioningStateProvisioned), + // "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite2": to.Ptr(armmobilenetwork.SiteProvisioningStateProvisioned), + // }, + // StaticIPConfiguration: []*armmobilenetwork.SimStaticIPProperties{ + // { + // AttachedDataNetwork: &armmobilenetwork.AttachedDataNetworkResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork"), + // }, + // Slice: &armmobilenetwork.SliceResourceID{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + // }, + // StaticIP: &armmobilenetwork.SimStaticIPPropertiesStaticIP{ + // IPv4Address: to.Ptr("2.4.0.1"), + // }, + // }}, + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimBulkUpload.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimBulkUpload.json func ExampleSimsClient_BeginBulkUpload() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimsClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginBulkUpload(ctx, "rg1", "testSimGroup", armmobilenetwork.SimUploadList{ + poller, err := clientFactory.NewSimsClient().BeginBulkUpload(ctx, "rg1", "testSimGroup", armmobilenetwork.SimUploadList{ Sims: []*armmobilenetwork.SimNameAndProperties{ { Name: to.Ptr("testSim"), @@ -198,22 +322,30 @@ func ExampleSimsClient_BeginBulkUpload() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AsyncOperationStatus = armmobilenetwork.AsyncOperationStatus{ + // Name: to.Ptr("testOperation"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-19T03:38:07.000Z"); return t}()), + // ID: to.Ptr("/providers/Microsoft.MobileNetwork/locations/testLocation/operationStatuses/testOperation"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-19T03:36:07.000Z"); return t}()), + // Status: to.Ptr("Succeeded"), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimBulkDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimBulkDelete.json func ExampleSimsClient_BeginBulkDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimsClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginBulkDelete(ctx, "testResourceGroupName", "testSimGroup", armmobilenetwork.SimDeleteList{ + poller, err := clientFactory.NewSimsClient().BeginBulkDelete(ctx, "testResourceGroupName", "testSimGroup", armmobilenetwork.SimDeleteList{ Sims: []*string{ to.Ptr("testSim"), to.Ptr("testSim2")}, @@ -225,22 +357,30 @@ func ExampleSimsClient_BeginBulkDelete() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AsyncOperationStatus = armmobilenetwork.AsyncOperationStatus{ + // Name: to.Ptr("testOperation"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-19T03:38:07.000Z"); return t}()), + // ID: to.Ptr("/providers/Microsoft.MobileNetwork/locations/testLocation/operationStatuses/testOperation"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-19T03:36:07.000Z"); return t}()), + // Status: to.Ptr("Succeeded"), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimBulkUploadEncrypted.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimBulkUploadEncrypted.json func ExampleSimsClient_BeginBulkUploadEncrypted() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSimsClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginBulkUploadEncrypted(ctx, "rg1", "testSimGroup", armmobilenetwork.EncryptedSimUploadList{ + poller, err := clientFactory.NewSimsClient().BeginBulkUploadEncrypted(ctx, "rg1", "testSimGroup", armmobilenetwork.EncryptedSimUploadList{ AzureKeyIdentifier: to.Ptr[int32](1), EncryptedTransportKey: to.Ptr("ABC123"), SignedTransportKey: to.Ptr("ABC123"), @@ -303,6 +443,14 @@ func ExampleSimsClient_BeginBulkUploadEncrypted() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AsyncOperationStatus = armmobilenetwork.AsyncOperationStatus{ + // Name: to.Ptr("testOperation"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-19T03:38:07.000Z"); return t}()), + // ID: to.Ptr("/providers/Microsoft.MobileNetwork/locations/testLocation/operationStatuses/testOperation"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-19T03:36:07.000Z"); return t}()), + // Status: to.Ptr("Succeeded"), + // } } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sites_client.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sites_client.go index 175395dea0c7..13dd9ab6d49b 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sites_client.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sites_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,31 +24,22 @@ import ( // SitesClient contains the methods for the Sites group. // Don't use this type directly, use NewSitesClient() instead. type SitesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSitesClient creates a new instance of SitesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSitesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SitesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SitesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SitesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,36 +47,38 @@ func NewSitesClient(subscriptionID string, credential azcore.TokenCredential, op // BeginCreateOrUpdate - Creates or updates a mobile network site. Must be created in the same location as its parent mobile // network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// siteName - The name of the mobile network site. -// parameters - Parameters supplied to the create or update mobile network site operation. -// options - SitesClientBeginCreateOrUpdateOptions contains the optional parameters for the SitesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - siteName - The name of the mobile network site. +// - parameters - Parameters supplied to the create or update mobile network site operation. +// - options - SitesClientBeginCreateOrUpdateOptions contains the optional parameters for the SitesClient.BeginCreateOrUpdate +// method. func (client *SitesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, mobileNetworkName string, siteName string, parameters Site, options *SitesClientBeginCreateOrUpdateOptions) (*runtime.Poller[SitesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, mobileNetworkName, siteName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SitesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SitesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[SitesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SitesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a mobile network site. Must be created in the same location as its parent mobile network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *SitesClient) createOrUpdate(ctx context.Context, resourceGroupName string, mobileNetworkName string, siteName string, parameters Site, options *SitesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, mobileNetworkName, siteName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -116,7 +107,7 @@ func (client *SitesClient) createOrUpdateCreateRequest(ctx context.Context, reso return nil, errors.New("parameter siteName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{siteName}", url.PathEscape(siteName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -130,35 +121,37 @@ func (client *SitesClient) createOrUpdateCreateRequest(ctx context.Context, reso // BeginDelete - Deletes the specified mobile network site. This will also delete any network functions that are a part of // this site. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// siteName - The name of the mobile network site. -// options - SitesClientBeginDeleteOptions contains the optional parameters for the SitesClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - siteName - The name of the mobile network site. +// - options - SitesClientBeginDeleteOptions contains the optional parameters for the SitesClient.BeginDelete method. func (client *SitesClient) BeginDelete(ctx context.Context, resourceGroupName string, mobileNetworkName string, siteName string, options *SitesClientBeginDeleteOptions) (*runtime.Poller[SitesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, mobileNetworkName, siteName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SitesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SitesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SitesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SitesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the specified mobile network site. This will also delete any network functions that are a part of this // site. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *SitesClient) deleteOperation(ctx context.Context, resourceGroupName string, mobileNetworkName string, siteName string, options *SitesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, mobileNetworkName, siteName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -187,7 +180,7 @@ func (client *SitesClient) deleteCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter siteName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{siteName}", url.PathEscape(siteName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -200,17 +193,18 @@ func (client *SitesClient) deleteCreateRequest(ctx context.Context, resourceGrou // Get - Gets information about the specified mobile network site. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// siteName - The name of the mobile network site. -// options - SitesClientGetOptions contains the optional parameters for the SitesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - siteName - The name of the mobile network site. +// - options - SitesClientGetOptions contains the optional parameters for the SitesClient.Get method. func (client *SitesClient) Get(ctx context.Context, resourceGroupName string, mobileNetworkName string, siteName string, options *SitesClientGetOptions) (SitesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, mobileNetworkName, siteName, options) if err != nil { return SitesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SitesClientGetResponse{}, err } @@ -239,7 +233,7 @@ func (client *SitesClient) getCreateRequest(ctx context.Context, resourceGroupNa return nil, errors.New("parameter siteName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{siteName}", url.PathEscape(siteName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -260,11 +254,12 @@ func (client *SitesClient) getHandleResponse(resp *http.Response) (SitesClientGe } // NewListByMobileNetworkPager - Lists all sites in the mobile network. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// options - SitesClientListByMobileNetworkOptions contains the optional parameters for the SitesClient.ListByMobileNetwork -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - options - SitesClientListByMobileNetworkOptions contains the optional parameters for the SitesClient.NewListByMobileNetworkPager +// method. func (client *SitesClient) NewListByMobileNetworkPager(resourceGroupName string, mobileNetworkName string, options *SitesClientListByMobileNetworkOptions) *runtime.Pager[SitesClientListByMobileNetworkResponse] { return runtime.NewPager(runtime.PagingHandler[SitesClientListByMobileNetworkResponse]{ More: func(page SitesClientListByMobileNetworkResponse) bool { @@ -281,7 +276,7 @@ func (client *SitesClient) NewListByMobileNetworkPager(resourceGroupName string, if err != nil { return SitesClientListByMobileNetworkResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SitesClientListByMobileNetworkResponse{}, err } @@ -308,7 +303,7 @@ func (client *SitesClient) listByMobileNetworkCreateRequest(ctx context.Context, return nil, errors.New("parameter mobileNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{mobileNetworkName}", url.PathEscape(mobileNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -330,18 +325,19 @@ func (client *SitesClient) listByMobileNetworkHandleResponse(resp *http.Response // UpdateTags - Updates site tags. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// siteName - The name of the mobile network site. -// parameters - Parameters supplied to update network site tags. -// options - SitesClientUpdateTagsOptions contains the optional parameters for the SitesClient.UpdateTags method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - siteName - The name of the mobile network site. +// - parameters - Parameters supplied to update network site tags. +// - options - SitesClientUpdateTagsOptions contains the optional parameters for the SitesClient.UpdateTags method. func (client *SitesClient) UpdateTags(ctx context.Context, resourceGroupName string, mobileNetworkName string, siteName string, parameters TagsObject, options *SitesClientUpdateTagsOptions) (SitesClientUpdateTagsResponse, error) { req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, mobileNetworkName, siteName, parameters, options) if err != nil { return SitesClientUpdateTagsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SitesClientUpdateTagsResponse{}, err } @@ -370,7 +366,7 @@ func (client *SitesClient) updateTagsCreateRequest(ctx context.Context, resource return nil, errors.New("parameter siteName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{siteName}", url.PathEscape(siteName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sites_client_example_test.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sites_client_example_test.go index 3c263aa162e4..806a55e93baa 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sites_client_example_test.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/sites_client_example_test.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 armmobilenetwork_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mobilenetwork/armmobilenetwork/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SiteDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SiteDelete.json func ExampleSitesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSitesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rg1", "testMobileNetwork", "testSite", nil) + poller, err := clientFactory.NewSitesClient().BeginDelete(ctx, "rg1", "testMobileNetwork", "testSite", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -38,37 +39,59 @@ func ExampleSitesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SiteGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SiteGet.json func ExampleSitesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSitesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rg1", "testMobileNetwork", "testSite", nil) + res, err := clientFactory.NewSitesClient().Get(ctx, "rg1", "testMobileNetwork", "testSite", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Site = armmobilenetwork.Site{ + // Name: to.Ptr("testSite"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks/sites"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("testLocation"), + // Properties: &armmobilenetwork.SitePropertiesFormat{ + // NetworkFunctions: []*armmobilenetwork.SubResource{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HybridNetwork/networkFunctions/testNf"), + // }}, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SiteCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SiteCreate.json func ExampleSitesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSitesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "testMobileNetwork", "testSite", armmobilenetwork.Site{ + poller, err := clientFactory.NewSitesClient().BeginCreateOrUpdate(ctx, "rg1", "testMobileNetwork", "testSite", armmobilenetwork.Site{ Location: to.Ptr("testLocation"), Properties: &armmobilenetwork.SitePropertiesFormat{}, }, nil) @@ -79,22 +102,42 @@ func ExampleSitesClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Site = armmobilenetwork.Site{ + // Name: to.Ptr("testSite"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks/sites"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("testLocation"), + // Properties: &armmobilenetwork.SitePropertiesFormat{ + // NetworkFunctions: []*armmobilenetwork.SubResource{ + // }, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SiteUpdateTags.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SiteUpdateTags.json func ExampleSitesClient_UpdateTags() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSitesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.UpdateTags(ctx, "rg1", "testMobileNetwork", "testSite", armmobilenetwork.TagsObject{ + res, err := clientFactory.NewSitesClient().UpdateTags(ctx, "rg1", "testMobileNetwork", "testSite", armmobilenetwork.TagsObject{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -103,30 +146,81 @@ func ExampleSitesClient_UpdateTags() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Site = armmobilenetwork.Site{ + // Name: to.Ptr("testSite"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks/sites"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("testLocation"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armmobilenetwork.SitePropertiesFormat{ + // NetworkFunctions: []*armmobilenetwork.SubResource{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HybridNetwork/networkFunctions/testNf"), + // }}, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SiteListByMobileNetwork.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SiteListByMobileNetwork.json func ExampleSitesClient_NewListByMobileNetworkPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSitesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByMobileNetworkPager("rg1", "testMobileNetwork", nil) + pager := clientFactory.NewSitesClient().NewListByMobileNetworkPager("rg1", "testMobileNetwork", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SiteListResult = armmobilenetwork.SiteListResult{ + // Value: []*armmobilenetwork.Site{ + // { + // Name: to.Ptr("testSite"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks/sites"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("testLocation"), + // Properties: &armmobilenetwork.SitePropertiesFormat{ + // NetworkFunctions: []*armmobilenetwork.SubResource{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HybridNetwork/networkFunctions/testNf"), + // }}, + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/slices_client.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/slices_client.go index 156bb49efe0c..a7baf0769f0d 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/slices_client.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/slices_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,67 +24,60 @@ import ( // SlicesClient contains the methods for the Slices group. // Don't use this type directly, use NewSlicesClient() instead. type SlicesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSlicesClient creates a new instance of SlicesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSlicesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SlicesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SlicesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SlicesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a network slice. Must be created in the same location as its parent mobile network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// sliceName - The name of the network slice. -// parameters - Parameters supplied to the create or update network slice operation. -// options - SlicesClientBeginCreateOrUpdateOptions contains the optional parameters for the SlicesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - sliceName - The name of the network slice. +// - parameters - Parameters supplied to the create or update network slice operation. +// - options - SlicesClientBeginCreateOrUpdateOptions contains the optional parameters for the SlicesClient.BeginCreateOrUpdate +// method. func (client *SlicesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, mobileNetworkName string, sliceName string, parameters Slice, options *SlicesClientBeginCreateOrUpdateOptions) (*runtime.Poller[SlicesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, mobileNetworkName, sliceName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SlicesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SlicesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[SlicesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SlicesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a network slice. Must be created in the same location as its parent mobile network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *SlicesClient) createOrUpdate(ctx context.Context, resourceGroupName string, mobileNetworkName string, sliceName string, parameters Slice, options *SlicesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, mobileNetworkName, sliceName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -115,7 +106,7 @@ func (client *SlicesClient) createOrUpdateCreateRequest(ctx context.Context, res return nil, errors.New("parameter sliceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sliceName}", url.PathEscape(sliceName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -128,34 +119,36 @@ func (client *SlicesClient) createOrUpdateCreateRequest(ctx context.Context, res // BeginDelete - Deletes the specified network slice. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// sliceName - The name of the network slice. -// options - SlicesClientBeginDeleteOptions contains the optional parameters for the SlicesClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - sliceName - The name of the network slice. +// - options - SlicesClientBeginDeleteOptions contains the optional parameters for the SlicesClient.BeginDelete method. func (client *SlicesClient) BeginDelete(ctx context.Context, resourceGroupName string, mobileNetworkName string, sliceName string, options *SlicesClientBeginDeleteOptions) (*runtime.Poller[SlicesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, mobileNetworkName, sliceName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SlicesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SlicesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SlicesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SlicesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the specified network slice. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *SlicesClient) deleteOperation(ctx context.Context, resourceGroupName string, mobileNetworkName string, sliceName string, options *SlicesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, mobileNetworkName, sliceName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -184,7 +177,7 @@ func (client *SlicesClient) deleteCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter sliceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sliceName}", url.PathEscape(sliceName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -197,17 +190,18 @@ func (client *SlicesClient) deleteCreateRequest(ctx context.Context, resourceGro // Get - Gets information about the specified network slice. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// sliceName - The name of the network slice. -// options - SlicesClientGetOptions contains the optional parameters for the SlicesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - sliceName - The name of the network slice. +// - options - SlicesClientGetOptions contains the optional parameters for the SlicesClient.Get method. func (client *SlicesClient) Get(ctx context.Context, resourceGroupName string, mobileNetworkName string, sliceName string, options *SlicesClientGetOptions) (SlicesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, mobileNetworkName, sliceName, options) if err != nil { return SlicesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SlicesClientGetResponse{}, err } @@ -236,7 +230,7 @@ func (client *SlicesClient) getCreateRequest(ctx context.Context, resourceGroupN return nil, errors.New("parameter sliceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sliceName}", url.PathEscape(sliceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -257,11 +251,12 @@ func (client *SlicesClient) getHandleResponse(resp *http.Response) (SlicesClient } // NewListByMobileNetworkPager - Lists all slices in the mobile network. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// options - SlicesClientListByMobileNetworkOptions contains the optional parameters for the SlicesClient.ListByMobileNetwork -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - options - SlicesClientListByMobileNetworkOptions contains the optional parameters for the SlicesClient.NewListByMobileNetworkPager +// method. func (client *SlicesClient) NewListByMobileNetworkPager(resourceGroupName string, mobileNetworkName string, options *SlicesClientListByMobileNetworkOptions) *runtime.Pager[SlicesClientListByMobileNetworkResponse] { return runtime.NewPager(runtime.PagingHandler[SlicesClientListByMobileNetworkResponse]{ More: func(page SlicesClientListByMobileNetworkResponse) bool { @@ -278,7 +273,7 @@ func (client *SlicesClient) NewListByMobileNetworkPager(resourceGroupName string if err != nil { return SlicesClientListByMobileNetworkResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SlicesClientListByMobileNetworkResponse{}, err } @@ -305,7 +300,7 @@ func (client *SlicesClient) listByMobileNetworkCreateRequest(ctx context.Context return nil, errors.New("parameter mobileNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{mobileNetworkName}", url.PathEscape(mobileNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -327,18 +322,19 @@ func (client *SlicesClient) listByMobileNetworkHandleResponse(resp *http.Respons // UpdateTags - Updates slice tags. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// mobileNetworkName - The name of the mobile network. -// sliceName - The name of the network slice. -// parameters - Parameters supplied to update network slice tags. -// options - SlicesClientUpdateTagsOptions contains the optional parameters for the SlicesClient.UpdateTags method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mobileNetworkName - The name of the mobile network. +// - sliceName - The name of the network slice. +// - parameters - Parameters supplied to update network slice tags. +// - options - SlicesClientUpdateTagsOptions contains the optional parameters for the SlicesClient.UpdateTags method. func (client *SlicesClient) UpdateTags(ctx context.Context, resourceGroupName string, mobileNetworkName string, sliceName string, parameters TagsObject, options *SlicesClientUpdateTagsOptions) (SlicesClientUpdateTagsResponse, error) { req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, mobileNetworkName, sliceName, parameters, options) if err != nil { return SlicesClientUpdateTagsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SlicesClientUpdateTagsResponse{}, err } @@ -367,7 +363,7 @@ func (client *SlicesClient) updateTagsCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter sliceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sliceName}", url.PathEscape(sliceName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/slices_client_example_test.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/slices_client_example_test.go index de61f9c9ad94..b346ac202462 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/slices_client_example_test.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/slices_client_example_test.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 armmobilenetwork_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mobilenetwork/armmobilenetwork/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SliceDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SliceDelete.json func ExampleSlicesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSlicesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rg1", "testMobileNetwork", "testSlice", nil) + poller, err := clientFactory.NewSlicesClient().BeginDelete(ctx, "rg1", "testMobileNetwork", "testSlice", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -38,37 +39,62 @@ func ExampleSlicesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SliceGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SliceGet.json func ExampleSlicesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSlicesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rg1", "testMobileNetwork", "testSlice", nil) + res, err := clientFactory.NewSlicesClient().Get(ctx, "rg1", "testMobileNetwork", "testSlice", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Slice = armmobilenetwork.Slice{ + // Name: to.Ptr("testSlice"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks/slices"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.SlicePropertiesFormat{ + // Description: to.Ptr("myFavouriteSlice"), + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // Snssai: &armmobilenetwork.Snssai{ + // Sd: to.Ptr("1abcde"), + // Sst: to.Ptr[int32](1), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SliceCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SliceCreate.json func ExampleSlicesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSlicesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "testMobileNetwork", "testSlice", armmobilenetwork.Slice{ + poller, err := clientFactory.NewSlicesClient().BeginCreateOrUpdate(ctx, "rg1", "testMobileNetwork", "testSlice", armmobilenetwork.Slice{ Location: to.Ptr("eastus"), Properties: &armmobilenetwork.SlicePropertiesFormat{ Description: to.Ptr("myFavouriteSlice"), @@ -85,22 +111,47 @@ func ExampleSlicesClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Slice = armmobilenetwork.Slice{ + // Name: to.Ptr("testSlice"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks/slices"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.SlicePropertiesFormat{ + // Description: to.Ptr("myFavouriteSlice"), + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // Snssai: &armmobilenetwork.Snssai{ + // Sd: to.Ptr("1abcde"), + // Sst: to.Ptr[int32](1), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SliceUpdateTags.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SliceUpdateTags.json func ExampleSlicesClient_UpdateTags() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSlicesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.UpdateTags(ctx, "rg1", "testMobileNetwork", "testSlice", armmobilenetwork.TagsObject{ + res, err := clientFactory.NewSlicesClient().UpdateTags(ctx, "rg1", "testMobileNetwork", "testSlice", armmobilenetwork.TagsObject{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -109,30 +160,85 @@ func ExampleSlicesClient_UpdateTags() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Slice = armmobilenetwork.Slice{ + // Name: to.Ptr("testSlice"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks/slices"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armmobilenetwork.SlicePropertiesFormat{ + // Description: to.Ptr("myFavouriteSlice"), + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // Snssai: &armmobilenetwork.Snssai{ + // Sd: to.Ptr("1abcde"), + // Sst: to.Ptr[int32](1), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SliceListByMobileNetwork.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/340d577969b7bff5ad0488d79543314bc17daa50/specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SliceListByMobileNetwork.json func ExampleSlicesClient_NewListByMobileNetworkPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmobilenetwork.NewSlicesClient("subid", cred, nil) + clientFactory, err := armmobilenetwork.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByMobileNetworkPager("rg1", "testMobileNetwork", nil) + pager := clientFactory.NewSlicesClient().NewListByMobileNetworkPager("rg1", "testMobileNetwork", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SliceListResult = armmobilenetwork.SliceListResult{ + // Value: []*armmobilenetwork.Slice{ + // { + // Name: to.Ptr("testSlice"), + // Type: to.Ptr("Microsoft.MobileNetwork/mobileNetworks/slices"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + // SystemData: &armmobilenetwork.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmobilenetwork.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armmobilenetwork.SlicePropertiesFormat{ + // Description: to.Ptr("myFavouriteSlice"), + // ProvisioningState: to.Ptr(armmobilenetwork.ProvisioningStateSucceeded), + // Snssai: &armmobilenetwork.Snssai{ + // Sd: to.Ptr("1abcde"), + // Sst: to.Ptr[int32](1), + // }, + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/time_rfc3339.go b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/time_rfc3339.go index 30077a7e0625..ccc57ce01d61 100644 --- a/sdk/resourcemanager/mobilenetwork/armmobilenetwork/time_rfc3339.go +++ b/sdk/resourcemanager/mobilenetwork/armmobilenetwork/time_rfc3339.go @@ -62,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/msi/armmsi/CHANGELOG.md b/sdk/resourcemanager/msi/armmsi/CHANGELOG.md index 00982eba9674..0e65652ebff9 100644 --- a/sdk/resourcemanager/msi/armmsi/CHANGELOG.md +++ b/sdk/resourcemanager/msi/armmsi/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2023-02-24) ### Breaking Changes diff --git a/sdk/resourcemanager/msi/armmsi/README.md b/sdk/resourcemanager/msi/armmsi/README.md index e87ff422d0c1..1d32fb502d32 100644 --- a/sdk/resourcemanager/msi/armmsi/README.md +++ b/sdk/resourcemanager/msi/armmsi/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Managed Service Identity modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Managed Service Identity module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armmsi.NewUserAssignedIdentitiesClient(, cred, nil) +clientFactory, err := armmsi.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armmsi.NewUserAssignedIdentitiesClient(, cred, &options) +clientFactory, err := armmsi.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewSystemAssignedIdentitiesClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/msi/armmsi/autorest.md b/sdk/resourcemanager/msi/armmsi/autorest.md index 9a46816003cc..de88a14dcebd 100644 --- a/sdk/resourcemanager/msi/armmsi/autorest.md +++ b/sdk/resourcemanager/msi/armmsi/autorest.md @@ -8,5 +8,5 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/3d7a3848106b831a4a7f46976fe38aa605c4f44d/specification/msi/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/3d7a3848106b831a4a7f46976fe38aa605c4f44d/specification/msi/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/msi/armmsi/client_factory.go b/sdk/resourcemanager/msi/armmsi/client_factory.go new file mode 100644 index 000000000000..16e6a70b1a25 --- /dev/null +++ b/sdk/resourcemanager/msi/armmsi/client_factory.go @@ -0,0 +1,59 @@ +//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 armmsi + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The Id of the Subscription to which the identity belongs. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewSystemAssignedIdentitiesClient() *SystemAssignedIdentitiesClient { + subClient, _ := NewSystemAssignedIdentitiesClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewUserAssignedIdentitiesClient() *UserAssignedIdentitiesClient { + subClient, _ := NewUserAssignedIdentitiesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewFederatedIdentityCredentialsClient() *FederatedIdentityCredentialsClient { + subClient, _ := NewFederatedIdentityCredentialsClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/msi/armmsi/constants.go b/sdk/resourcemanager/msi/armmsi/constants.go index 18b59eb71338..d27b04469f9d 100644 --- a/sdk/resourcemanager/msi/armmsi/constants.go +++ b/sdk/resourcemanager/msi/armmsi/constants.go @@ -11,7 +11,7 @@ package armmsi const ( moduleName = "armmsi" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/msi/armmsi/federatedidentitycredentials_client.go b/sdk/resourcemanager/msi/armmsi/federatedidentitycredentials_client.go index 119c68eb981b..931cb609b076 100644 --- a/sdk/resourcemanager/msi/armmsi/federatedidentitycredentials_client.go +++ b/sdk/resourcemanager/msi/armmsi/federatedidentitycredentials_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,9 +25,8 @@ import ( // FederatedIdentityCredentialsClient contains the methods for the FederatedIdentityCredentials group. // Don't use this type directly, use NewFederatedIdentityCredentialsClient() instead. type FederatedIdentityCredentialsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewFederatedIdentityCredentialsClient creates a new instance of FederatedIdentityCredentialsClient with the specified values. @@ -37,21 +34,13 @@ type FederatedIdentityCredentialsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewFederatedIdentityCredentialsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FederatedIdentityCredentialsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".FederatedIdentityCredentialsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &FederatedIdentityCredentialsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,7 +60,7 @@ func (client *FederatedIdentityCredentialsClient) CreateOrUpdate(ctx context.Con if err != nil { return FederatedIdentityCredentialsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FederatedIdentityCredentialsClientCreateOrUpdateResponse{}, err } @@ -100,7 +89,7 @@ func (client *FederatedIdentityCredentialsClient) createOrUpdateCreateRequest(ct return nil, errors.New("parameter federatedIdentityCredentialResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{federatedIdentityCredentialResourceName}", url.PathEscape(federatedIdentityCredentialResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -134,7 +123,7 @@ func (client *FederatedIdentityCredentialsClient) Delete(ctx context.Context, re if err != nil { return FederatedIdentityCredentialsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FederatedIdentityCredentialsClientDeleteResponse{}, err } @@ -163,7 +152,7 @@ func (client *FederatedIdentityCredentialsClient) deleteCreateRequest(ctx contex return nil, errors.New("parameter federatedIdentityCredentialResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{federatedIdentityCredentialResourceName}", url.PathEscape(federatedIdentityCredentialResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -188,7 +177,7 @@ func (client *FederatedIdentityCredentialsClient) Get(ctx context.Context, resou if err != nil { return FederatedIdentityCredentialsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FederatedIdentityCredentialsClientGetResponse{}, err } @@ -217,7 +206,7 @@ func (client *FederatedIdentityCredentialsClient) getCreateRequest(ctx context.C return nil, errors.New("parameter federatedIdentityCredentialResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{federatedIdentityCredentialResourceName}", url.PathEscape(federatedIdentityCredentialResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -260,7 +249,7 @@ func (client *FederatedIdentityCredentialsClient) NewListPager(resourceGroupName if err != nil { return FederatedIdentityCredentialsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FederatedIdentityCredentialsClientListResponse{}, err } @@ -287,7 +276,7 @@ func (client *FederatedIdentityCredentialsClient) listCreateRequest(ctx context. return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/msi/armmsi/federatedidentitycredentials_client_example_test.go b/sdk/resourcemanager/msi/armmsi/federatedidentitycredentials_client_example_test.go index 7f201af08586..853b41415beb 100644 --- a/sdk/resourcemanager/msi/armmsi/federatedidentitycredentials_client_example_test.go +++ b/sdk/resourcemanager/msi/armmsi/federatedidentitycredentials_client_example_test.go @@ -25,11 +25,11 @@ func ExampleFederatedIdentityCredentialsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmsi.NewFederatedIdentityCredentialsClient("c267c0e7-0a73-4789-9e17-d26aeb0904e5", cred, nil) + clientFactory, err := armmsi.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("rgName", "resourceName", &armmsi.FederatedIdentityCredentialsClientListOptions{Top: nil, + pager := clientFactory.NewFederatedIdentityCredentialsClient().NewListPager("rgName", "resourceName", &armmsi.FederatedIdentityCredentialsClientListOptions{Top: nil, Skiptoken: nil, }) for pager.More() { @@ -66,11 +66,11 @@ func ExampleFederatedIdentityCredentialsClient_CreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmsi.NewFederatedIdentityCredentialsClient("c267c0e7-0a73-4789-9e17-d26aeb0904e5", cred, nil) + clientFactory, err := armmsi.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "rgName", "resourceName", "ficResourceName", armmsi.FederatedIdentityCredential{ + res, err := clientFactory.NewFederatedIdentityCredentialsClient().CreateOrUpdate(ctx, "rgName", "resourceName", "ficResourceName", armmsi.FederatedIdentityCredential{ Properties: &armmsi.FederatedIdentityCredentialProperties{ Audiences: []*string{ to.Ptr("api://AzureADTokenExchange")}, @@ -104,11 +104,11 @@ func ExampleFederatedIdentityCredentialsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmsi.NewFederatedIdentityCredentialsClient("c267c0e7-0a73-4789-9e17-d26aeb0904e5", cred, nil) + clientFactory, err := armmsi.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rgName", "resourceName", "ficResourceName", nil) + res, err := clientFactory.NewFederatedIdentityCredentialsClient().Get(ctx, "rgName", "resourceName", "ficResourceName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -135,11 +135,11 @@ func ExampleFederatedIdentityCredentialsClient_Delete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmsi.NewFederatedIdentityCredentialsClient("c267c0e7-0a73-4789-9e17-d26aeb0904e5", cred, nil) + clientFactory, err := armmsi.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "rgName", "resourceName", "ficResourceName", nil) + _, err = clientFactory.NewFederatedIdentityCredentialsClient().Delete(ctx, "rgName", "resourceName", "ficResourceName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/msi/armmsi/go.mod b/sdk/resourcemanager/msi/armmsi/go.mod index 2ebcfd6ee16d..4568d373931d 100644 --- a/sdk/resourcemanager/msi/armmsi/go.mod +++ b/sdk/resourcemanager/msi/armmsi/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/msi/armmsi 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.2.1 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 // indirect - github.com/golang-jwt/jwt/v4 v4.4.2 // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/msi/armmsi/go.sum b/sdk/resourcemanager/msi/armmsi/go.sum index 67cfef6bdf6e..8ba445a8c4da 100644 --- a/sdk/resourcemanager/msi/armmsi/go.sum +++ b/sdk/resourcemanager/msi/armmsi/go.sum @@ -1,30 +1,31 @@ -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.2.1 h1:T8quHYlUGyb/oqtSTwqlCr1ilJHrDv+ZtpSfo+hm1BU= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1/go.mod h1:gLa1CL2RNE4s7M3yopJ/p0iq5DdY6Yv5ZUt9MTRZOQM= -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.8.1 h1:oPdPEZFSbl7oSPEAIPMPBMUmiL+mqgzBJwM/9qYcwNg= -github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1/go.mod h1:4qFor3D/HDsvBME35Xy9rwW9DecL+M2sNw1ybjPtwA0= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= 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/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= -github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -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/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/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/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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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-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= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/msi/armmsi/operations_client.go b/sdk/resourcemanager/msi/armmsi/operations_client.go index c67566e3333f..0d90dfaef3d4 100644 --- a/sdk/resourcemanager/msi/armmsi/operations_client.go +++ b/sdk/resourcemanager/msi/armmsi/operations_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,28 +21,19 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -84,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.ManagedIdentity/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/msi/armmsi/operations_client_example_test.go b/sdk/resourcemanager/msi/armmsi/operations_client_example_test.go index fe7a435c31ee..328a0857608b 100644 --- a/sdk/resourcemanager/msi/armmsi/operations_client_example_test.go +++ b/sdk/resourcemanager/msi/armmsi/operations_client_example_test.go @@ -24,11 +24,11 @@ func ExampleOperationsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmsi.NewOperationsClient(cred, nil) + clientFactory, err := armmsi.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewOperationsClient().NewListPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/msi/armmsi/systemassignedidentities_client.go b/sdk/resourcemanager/msi/armmsi/systemassignedidentities_client.go index 38f427487d81..18126fc2b93b 100644 --- a/sdk/resourcemanager/msi/armmsi/systemassignedidentities_client.go +++ b/sdk/resourcemanager/msi/armmsi/systemassignedidentities_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -24,28 +22,19 @@ import ( // SystemAssignedIdentitiesClient contains the methods for the SystemAssignedIdentities group. // Don't use this type directly, use NewSystemAssignedIdentitiesClient() instead. type SystemAssignedIdentitiesClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewSystemAssignedIdentitiesClient creates a new instance of SystemAssignedIdentitiesClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSystemAssignedIdentitiesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SystemAssignedIdentitiesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SystemAssignedIdentitiesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SystemAssignedIdentitiesClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -62,7 +51,7 @@ func (client *SystemAssignedIdentitiesClient) GetByScope(ctx context.Context, sc if err != nil { return SystemAssignedIdentitiesClientGetByScopeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SystemAssignedIdentitiesClientGetByScopeResponse{}, err } @@ -76,7 +65,7 @@ func (client *SystemAssignedIdentitiesClient) GetByScope(ctx context.Context, sc func (client *SystemAssignedIdentitiesClient) getByScopeCreateRequest(ctx context.Context, scope string, options *SystemAssignedIdentitiesClientGetByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.ManagedIdentity/identities/default" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/msi/armmsi/systemassignedidentities_client_example_test.go b/sdk/resourcemanager/msi/armmsi/systemassignedidentities_client_example_test.go index 64a80a9ac0ff..857febd180de 100644 --- a/sdk/resourcemanager/msi/armmsi/systemassignedidentities_client_example_test.go +++ b/sdk/resourcemanager/msi/armmsi/systemassignedidentities_client_example_test.go @@ -24,11 +24,11 @@ func ExampleSystemAssignedIdentitiesClient_GetByScope() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmsi.NewSystemAssignedIdentitiesClient(cred, nil) + clientFactory, err := armmsi.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GetByScope(ctx, "scope", nil) + res, err := clientFactory.NewSystemAssignedIdentitiesClient().GetByScope(ctx, "scope", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/msi/armmsi/userassignedidentities_client.go b/sdk/resourcemanager/msi/armmsi/userassignedidentities_client.go index 598ee2da393a..ea059ae8c6ea 100644 --- a/sdk/resourcemanager/msi/armmsi/userassignedidentities_client.go +++ b/sdk/resourcemanager/msi/armmsi/userassignedidentities_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // UserAssignedIdentitiesClient contains the methods for the UserAssignedIdentities group. // Don't use this type directly, use NewUserAssignedIdentitiesClient() instead. type UserAssignedIdentitiesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewUserAssignedIdentitiesClient creates a new instance of UserAssignedIdentitiesClient with the specified values. @@ -36,21 +33,13 @@ type UserAssignedIdentitiesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewUserAssignedIdentitiesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UserAssignedIdentitiesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".UserAssignedIdentitiesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &UserAssignedIdentitiesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *UserAssignedIdentitiesClient) CreateOrUpdate(ctx context.Context, if err != nil { return UserAssignedIdentitiesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UserAssignedIdentitiesClientCreateOrUpdateResponse{}, err } @@ -94,7 +83,7 @@ func (client *UserAssignedIdentitiesClient) createOrUpdateCreateRequest(ctx cont return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -127,7 +116,7 @@ func (client *UserAssignedIdentitiesClient) Delete(ctx context.Context, resource if err != nil { return UserAssignedIdentitiesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UserAssignedIdentitiesClientDeleteResponse{}, err } @@ -152,7 +141,7 @@ func (client *UserAssignedIdentitiesClient) deleteCreateRequest(ctx context.Cont return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -176,7 +165,7 @@ func (client *UserAssignedIdentitiesClient) Get(ctx context.Context, resourceGro if err != nil { return UserAssignedIdentitiesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UserAssignedIdentitiesClientGetResponse{}, err } @@ -201,7 +190,7 @@ func (client *UserAssignedIdentitiesClient) getCreateRequest(ctx context.Context return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -243,7 +232,7 @@ func (client *UserAssignedIdentitiesClient) NewListByResourceGroupPager(resource if err != nil { return UserAssignedIdentitiesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UserAssignedIdentitiesClientListByResourceGroupResponse{}, err } @@ -266,7 +255,7 @@ func (client *UserAssignedIdentitiesClient) listByResourceGroupCreateRequest(ctx return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -307,7 +296,7 @@ func (client *UserAssignedIdentitiesClient) NewListBySubscriptionPager(options * if err != nil { return UserAssignedIdentitiesClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UserAssignedIdentitiesClientListBySubscriptionResponse{}, err } @@ -326,7 +315,7 @@ func (client *UserAssignedIdentitiesClient) listBySubscriptionCreateRequest(ctx return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -360,7 +349,7 @@ func (client *UserAssignedIdentitiesClient) Update(ctx context.Context, resource if err != nil { return UserAssignedIdentitiesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UserAssignedIdentitiesClientUpdateResponse{}, err } @@ -385,7 +374,7 @@ func (client *UserAssignedIdentitiesClient) updateCreateRequest(ctx context.Cont return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/msi/armmsi/userassignedidentities_client_example_test.go b/sdk/resourcemanager/msi/armmsi/userassignedidentities_client_example_test.go index 37c851d5bb76..5b69e14dd4b0 100644 --- a/sdk/resourcemanager/msi/armmsi/userassignedidentities_client_example_test.go +++ b/sdk/resourcemanager/msi/armmsi/userassignedidentities_client_example_test.go @@ -25,11 +25,11 @@ func ExampleUserAssignedIdentitiesClient_NewListBySubscriptionPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmsi.NewUserAssignedIdentitiesClient("subid", cred, nil) + clientFactory, err := armmsi.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySubscriptionPager(nil) + pager := clientFactory.NewUserAssignedIdentitiesClient().NewListBySubscriptionPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -68,11 +68,11 @@ func ExampleUserAssignedIdentitiesClient_NewListByResourceGroupPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmsi.NewUserAssignedIdentitiesClient("subid", cred, nil) + clientFactory, err := armmsi.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("rgName", nil) + pager := clientFactory.NewUserAssignedIdentitiesClient().NewListByResourceGroupPager("rgName", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -111,11 +111,11 @@ func ExampleUserAssignedIdentitiesClient_CreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmsi.NewUserAssignedIdentitiesClient("subid", cred, nil) + clientFactory, err := armmsi.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "rgName", "resourceName", armmsi.Identity{ + res, err := clientFactory.NewUserAssignedIdentitiesClient().CreateOrUpdate(ctx, "rgName", "resourceName", armmsi.Identity{ Location: to.Ptr("eastus"), Tags: map[string]*string{ "key1": to.Ptr("value1"), @@ -152,11 +152,11 @@ func ExampleUserAssignedIdentitiesClient_Update() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmsi.NewUserAssignedIdentitiesClient("subid", cred, nil) + clientFactory, err := armmsi.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "rgName", "resourceName", armmsi.IdentityUpdate{ + res, err := clientFactory.NewUserAssignedIdentitiesClient().Update(ctx, "rgName", "resourceName", armmsi.IdentityUpdate{ Location: to.Ptr("eastus"), Tags: map[string]*string{ "key1": to.Ptr("value1"), @@ -193,11 +193,11 @@ func ExampleUserAssignedIdentitiesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmsi.NewUserAssignedIdentitiesClient("subid", cred, nil) + clientFactory, err := armmsi.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rgName", "resourceName", nil) + res, err := clientFactory.NewUserAssignedIdentitiesClient().Get(ctx, "rgName", "resourceName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -228,11 +228,11 @@ func ExampleUserAssignedIdentitiesClient_Delete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmsi.NewUserAssignedIdentitiesClient("subid", cred, nil) + clientFactory, err := armmsi.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "rgName", "resourceName", nil) + _, err = clientFactory.NewUserAssignedIdentitiesClient().Delete(ctx, "rgName", "resourceName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/mysql/armmysql/CHANGELOG.md b/sdk/resourcemanager/mysql/armmysql/CHANGELOG.md index a6e2ec9ea5f8..23be4cc88872 100644 --- a/sdk/resourcemanager/mysql/armmysql/CHANGELOG.md +++ b/sdk/resourcemanager/mysql/armmysql/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-05-17) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql` 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/mysql/armmysql/README.md b/sdk/resourcemanager/mysql/armmysql/README.md index 891f1a9847f8..7310b1e1edba 100644 --- a/sdk/resourcemanager/mysql/armmysql/README.md +++ b/sdk/resourcemanager/mysql/armmysql/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Database for MySQL modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Database for MySQL module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armmysql.NewDatabasesClient(, cred, nil) +clientFactory, err := armmysql.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armmysql.NewDatabasesClient(, cred, &options) +clientFactory, err := armmysql.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewDatabasesClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_advisors_client.go b/sdk/resourcemanager/mysql/armmysql/advisors_client.go similarity index 81% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_advisors_client.go rename to sdk/resourcemanager/mysql/armmysql/advisors_client.go index 1385be9c9e8e..1d3d1b284c15 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_advisors_client.go +++ b/sdk/resourcemanager/mysql/armmysql/advisors_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // AdvisorsClient contains the methods for the Advisors group. // Don't use this type directly, use NewAdvisorsClient() instead. type AdvisorsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAdvisorsClient creates a new instance of AdvisorsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAdvisorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AdvisorsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AdvisorsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AdvisorsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get a recommendation action advisor. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// advisorName - The advisor name for recommendation action. -// options - AdvisorsClientGetOptions contains the optional parameters for the AdvisorsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - advisorName - The advisor name for recommendation action. +// - options - AdvisorsClientGetOptions contains the optional parameters for the AdvisorsClient.Get method. func (client *AdvisorsClient) Get(ctx context.Context, resourceGroupName string, serverName string, advisorName string, options *AdvisorsClientGetOptions) (AdvisorsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, advisorName, options) if err != nil { return AdvisorsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AdvisorsClientGetResponse{}, err } @@ -95,7 +86,7 @@ func (client *AdvisorsClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter advisorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{advisorName}", url.PathEscape(advisorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -116,11 +107,12 @@ func (client *AdvisorsClient) getHandleResponse(resp *http.Response) (AdvisorsCl } // NewListByServerPager - List recommendation action advisors. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - AdvisorsClientListByServerOptions contains the optional parameters for the AdvisorsClient.ListByServer method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - AdvisorsClientListByServerOptions contains the optional parameters for the AdvisorsClient.NewListByServerPager +// method. func (client *AdvisorsClient) NewListByServerPager(resourceGroupName string, serverName string, options *AdvisorsClientListByServerOptions) *runtime.Pager[AdvisorsClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[AdvisorsClientListByServerResponse]{ More: func(page AdvisorsClientListByServerResponse) bool { @@ -137,7 +129,7 @@ func (client *AdvisorsClient) NewListByServerPager(resourceGroupName string, ser if err != nil { return AdvisorsClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AdvisorsClientListByServerResponse{}, err } @@ -164,7 +156,7 @@ func (client *AdvisorsClient) listByServerCreateRequest(ctx context.Context, res return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/advisors_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/advisors_client_example_test.go new file mode 100644 index 000000000000..5644d7b186b2 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/advisors_client_example_test.go @@ -0,0 +1,80 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/AdvisorsGet.json +func ExampleAdvisorsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAdvisorsClient().Get(ctx, "testResourceGroupName", "testServerName", "Index", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Advisor = armmysql.Advisor{ + // Name: to.Ptr("Index"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/advisors"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.DBforMySQL/servers/testServerName/advisors/Index"), + // Properties: map[string]any{ + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/AdvisorsListByServer.json +func ExampleAdvisorsClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAdvisorsClient().NewListByServerPager("testResourceGroupName", "testServerName", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AdvisorsResultList = armmysql.AdvisorsResultList{ + // Value: []*armmysql.Advisor{ + // { + // Name: to.Ptr("Index"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/advisors"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.DBforMySQL/servers/testServerName/advisors/Index"), + // Properties: map[string]any{ + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/autorest.md b/sdk/resourcemanager/mysql/armmysql/autorest.md index 7e4b88ead5da..38af7efc2a14 100644 --- a/sdk/resourcemanager/mysql/armmysql/autorest.md +++ b/sdk/resourcemanager/mysql/armmysql/autorest.md @@ -8,7 +8,7 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 package-singleservers: true directive: - from: Servers.json diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_checknameavailability_client.go b/sdk/resourcemanager/mysql/armmysql/checknameavailability_client.go similarity index 76% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_checknameavailability_client.go rename to sdk/resourcemanager/mysql/armmysql/checknameavailability_client.go index 809d70d288b7..c716374ca8c6 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_checknameavailability_client.go +++ b/sdk/resourcemanager/mysql/armmysql/checknameavailability_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,47 +24,39 @@ import ( // CheckNameAvailabilityClient contains the methods for the CheckNameAvailability group. // Don't use this type directly, use NewCheckNameAvailabilityClient() instead. type CheckNameAvailabilityClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCheckNameAvailabilityClient creates a new instance of CheckNameAvailabilityClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCheckNameAvailabilityClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CheckNameAvailabilityClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CheckNameAvailabilityClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CheckNameAvailabilityClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Execute - Check the availability of name for resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// nameAvailabilityRequest - The required parameters for checking if resource name is available. -// options - CheckNameAvailabilityClientExecuteOptions contains the optional parameters for the CheckNameAvailabilityClient.Execute -// method. +// - nameAvailabilityRequest - The required parameters for checking if resource name is available. +// - options - CheckNameAvailabilityClientExecuteOptions contains the optional parameters for the CheckNameAvailabilityClient.Execute +// method. func (client *CheckNameAvailabilityClient) Execute(ctx context.Context, nameAvailabilityRequest NameAvailabilityRequest, options *CheckNameAvailabilityClientExecuteOptions) (CheckNameAvailabilityClientExecuteResponse, error) { req, err := client.executeCreateRequest(ctx, nameAvailabilityRequest, options) if err != nil { return CheckNameAvailabilityClientExecuteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CheckNameAvailabilityClientExecuteResponse{}, err } @@ -82,7 +73,7 @@ func (client *CheckNameAvailabilityClient) executeCreateRequest(ctx context.Cont return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_checknameavailability_client_test.go b/sdk/resourcemanager/mysql/armmysql/checknameavailability_client_example_test.go similarity index 52% rename from sdk/resourcemanager/mysql/armmysql/ze_generated_example_checknameavailability_client_test.go rename to sdk/resourcemanager/mysql/armmysql/checknameavailability_client_example_test.go index f16792609c39..292c760c06f1 100644 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_checknameavailability_client_test.go +++ b/sdk/resourcemanager/mysql/armmysql/checknameavailability_client_example_test.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 armmysql_test @@ -17,26 +18,30 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/CheckNameAvailability.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/CheckNameAvailability.json func ExampleCheckNameAvailabilityClient_Execute() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmysql.NewCheckNameAvailabilityClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + clientFactory, err := armmysql.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Execute(ctx, - armmysql.NameAvailabilityRequest{ - Name: to.Ptr("name1"), - Type: to.Ptr("Microsoft.DBforMySQL"), - }, - nil) + res, err := clientFactory.NewCheckNameAvailabilityClient().Execute(ctx, armmysql.NameAvailabilityRequest{ + Name: to.Ptr("name1"), + Type: to.Ptr("Microsoft.DBforMySQL"), + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.NameAvailability = armmysql.NameAvailability{ + // Message: to.Ptr(""), + // NameAvailable: to.Ptr(true), + // Reason: to.Ptr(""), + // } } diff --git a/sdk/resourcemanager/mysql/armmysql/client_factory.go b/sdk/resourcemanager/mysql/armmysql/client_factory.go new file mode 100644 index 000000000000..3e9f10ab16b0 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/client_factory.go @@ -0,0 +1,169 @@ +//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 armmysql + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewServersClient() *ServersClient { + subClient, _ := NewServersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewReplicasClient() *ReplicasClient { + subClient, _ := NewReplicasClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewFirewallRulesClient() *FirewallRulesClient { + subClient, _ := NewFirewallRulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVirtualNetworkRulesClient() *VirtualNetworkRulesClient { + subClient, _ := NewVirtualNetworkRulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDatabasesClient() *DatabasesClient { + subClient, _ := NewDatabasesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewConfigurationsClient() *ConfigurationsClient { + subClient, _ := NewConfigurationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewServerParametersClient() *ServerParametersClient { + subClient, _ := NewServerParametersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLogFilesClient() *LogFilesClient { + subClient, _ := NewLogFilesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewServerAdministratorsClient() *ServerAdministratorsClient { + subClient, _ := NewServerAdministratorsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewRecoverableServersClient() *RecoverableServersClient { + subClient, _ := NewRecoverableServersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewServerBasedPerformanceTierClient() *ServerBasedPerformanceTierClient { + subClient, _ := NewServerBasedPerformanceTierClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLocationBasedPerformanceTierClient() *LocationBasedPerformanceTierClient { + subClient, _ := NewLocationBasedPerformanceTierClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCheckNameAvailabilityClient() *CheckNameAvailabilityClient { + subClient, _ := NewCheckNameAvailabilityClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewServerSecurityAlertPoliciesClient() *ServerSecurityAlertPoliciesClient { + subClient, _ := NewServerSecurityAlertPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewQueryTextsClient() *QueryTextsClient { + subClient, _ := NewQueryTextsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewTopQueryStatisticsClient() *TopQueryStatisticsClient { + subClient, _ := NewTopQueryStatisticsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWaitStatisticsClient() *WaitStatisticsClient { + subClient, _ := NewWaitStatisticsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewManagementClient() *ManagementClient { + subClient, _ := NewManagementClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAdvisorsClient() *AdvisorsClient { + subClient, _ := NewAdvisorsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewRecommendedActionsClient() *RecommendedActionsClient { + subClient, _ := NewRecommendedActionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLocationBasedRecommendedActionSessionsOperationStatusClient() *LocationBasedRecommendedActionSessionsOperationStatusClient { + subClient, _ := NewLocationBasedRecommendedActionSessionsOperationStatusClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLocationBasedRecommendedActionSessionsResultClient() *LocationBasedRecommendedActionSessionsResultClient { + subClient, _ := NewLocationBasedRecommendedActionSessionsResultClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPrivateEndpointConnectionsClient() *PrivateEndpointConnectionsClient { + subClient, _ := NewPrivateEndpointConnectionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPrivateLinkResourcesClient() *PrivateLinkResourcesClient { + subClient, _ := NewPrivateLinkResourcesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewServerKeysClient() *ServerKeysClient { + subClient, _ := NewServerKeysClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_configurations_client.go b/sdk/resourcemanager/mysql/armmysql/configurations_client.go similarity index 82% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_configurations_client.go rename to sdk/resourcemanager/mysql/armmysql/configurations_client.go index 9f1bd137be5f..80189d66d7ea 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_configurations_client.go +++ b/sdk/resourcemanager/mysql/armmysql/configurations_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,65 +24,58 @@ import ( // ConfigurationsClient contains the methods for the Configurations group. // Don't use this type directly, use NewConfigurationsClient() instead. type ConfigurationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewConfigurationsClient creates a new instance of ConfigurationsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ConfigurationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ConfigurationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ConfigurationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Updates a configuration of a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// configurationName - The name of the server configuration. -// parameters - The required parameters for updating a server configuration. -// options - ConfigurationsClientBeginCreateOrUpdateOptions contains the optional parameters for the ConfigurationsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - configurationName - The name of the server configuration. +// - parameters - The required parameters for updating a server configuration. +// - options - ConfigurationsClientBeginCreateOrUpdateOptions contains the optional parameters for the ConfigurationsClient.BeginCreateOrUpdate +// method. func (client *ConfigurationsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ConfigurationsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, serverName, configurationName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[ConfigurationsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[ConfigurationsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ConfigurationsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ConfigurationsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Updates a configuration of a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 func (client *ConfigurationsClient) createOrUpdate(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serverName, configurationName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -112,7 +104,7 @@ func (client *ConfigurationsClient) createOrUpdateCreateRequest(ctx context.Cont return nil, errors.New("parameter configurationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(configurationName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -125,17 +117,18 @@ func (client *ConfigurationsClient) createOrUpdateCreateRequest(ctx context.Cont // Get - Gets information about a configuration of server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// configurationName - The name of the server configuration. -// options - ConfigurationsClientGetOptions contains the optional parameters for the ConfigurationsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - configurationName - The name of the server configuration. +// - options - ConfigurationsClientGetOptions contains the optional parameters for the ConfigurationsClient.Get method. func (client *ConfigurationsClient) Get(ctx context.Context, resourceGroupName string, serverName string, configurationName string, options *ConfigurationsClientGetOptions) (ConfigurationsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, configurationName, options) if err != nil { return ConfigurationsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConfigurationsClientGetResponse{}, err } @@ -164,7 +157,7 @@ func (client *ConfigurationsClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter configurationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(configurationName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -185,12 +178,12 @@ func (client *ConfigurationsClient) getHandleResponse(resp *http.Response) (Conf } // NewListByServerPager - List all the configurations in a given server. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ConfigurationsClientListByServerOptions contains the optional parameters for the ConfigurationsClient.ListByServer -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ConfigurationsClientListByServerOptions contains the optional parameters for the ConfigurationsClient.NewListByServerPager +// method. func (client *ConfigurationsClient) NewListByServerPager(resourceGroupName string, serverName string, options *ConfigurationsClientListByServerOptions) *runtime.Pager[ConfigurationsClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[ConfigurationsClientListByServerResponse]{ More: func(page ConfigurationsClientListByServerResponse) bool { @@ -201,7 +194,7 @@ func (client *ConfigurationsClient) NewListByServerPager(resourceGroupName strin if err != nil { return ConfigurationsClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConfigurationsClientListByServerResponse{}, err } @@ -228,7 +221,7 @@ func (client *ConfigurationsClient) listByServerCreateRequest(ctx context.Contex return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/configurations_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/configurations_client_example_test.go new file mode 100644 index 000000000000..9c741fc4c748 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/configurations_client_example_test.go @@ -0,0 +1,707 @@ +//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 armmysql_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/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ConfigurationCreateOrUpdate.json +func ExampleConfigurationsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewConfigurationsClient().BeginCreateOrUpdate(ctx, "TestGroup", "testserver", "event_scheduler", armmysql.Configuration{ + Properties: &armmysql.ConfigurationProperties{ + Source: to.Ptr("user-override"), + Value: to.Ptr("off"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Configuration = armmysql.Configuration{ + // Name: to.Ptr("event_scheduler"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testserver/configurations/event_scheduler"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Indicates the status of the Event Scheduler."), + // AllowedValues: to.Ptr("ON,OFF,DISABLED"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // Source: to.Ptr("user-override"), + // Value: to.Ptr("ON"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ConfigurationGet.json +func ExampleConfigurationsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewConfigurationsClient().Get(ctx, "TestGroup", "testserver", "event_scheduler", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Configuration = armmysql.Configuration{ + // Name: to.Ptr("event_scheduler"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testserver/configurations/event_scheduler"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Indicates the status of the Event Scheduler."), + // AllowedValues: to.Ptr("ON,OFF,DISABLED"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // Source: to.Ptr("user-override"), + // Value: to.Ptr("ON"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ConfigurationListByServer.json +func ExampleConfigurationsClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewConfigurationsClient().NewListByServerPager("testrg", "mysqltestsvc1", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ConfigurationListResult = armmysql.ConfigurationListResult{ + // Value: []*armmysql.Configuration{ + // { + // Name: to.Ptr("event_scheduler"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/event_scheduler"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Indicates the status of the Event Scheduler."), + // AllowedValues: to.Ptr("ON,OFF,DISABLED"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("OFF"), + // }, + // }, + // { + // Name: to.Ptr("div_precision_increment"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/div_precision_increment"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Number of digits by which to increase the scale of the result of division operations."), + // AllowedValues: to.Ptr("0-30"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("4"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("4"), + // }, + // }, + // { + // Name: to.Ptr("group_concat_max_len"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/group_concat_max_len"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Maximum allowed result length in bytes for the GROUP_CONCAT()."), + // AllowedValues: to.Ptr("4-16777216"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("1024"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("1024"), + // }, + // }, + // { + // Name: to.Ptr("innodb_adaptive_hash_index"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/innodb_adaptive_hash_index"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Whether innodb adaptive hash indexes are enabled or disabled."), + // AllowedValues: to.Ptr("ON,OFF"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("ON"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("ON"), + // }, + // }, + // { + // Name: to.Ptr("innodb_lock_wait_timeout"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/innodb_lock_wait_timeout"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The length of time in seconds an InnoDB transaction waits for a row lock before giving up."), + // AllowedValues: to.Ptr("1-3600"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("50"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("50"), + // }, + // }, + // { + // Name: to.Ptr("interactive_timeout"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/interactive_timeout"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Number of seconds the server waits for activity on an interactive connection before closing it."), + // AllowedValues: to.Ptr("10-1800"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("1800"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("1800"), + // }, + // }, + // { + // Name: to.Ptr("log_queries_not_using_indexes"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/log_queries_not_using_indexes"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Logs queries that are expected to retrieve all rows to slow query log."), + // AllowedValues: to.Ptr("ON,OFF"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("OFF"), + // }, + // }, + // { + // Name: to.Ptr("log_throttle_queries_not_using_indexes"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/log_throttle_queries_not_using_indexes"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Limits the number of such queries per minute that can be written to the slow query log."), + // AllowedValues: to.Ptr("0-4294967295"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("0"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("0"), + // }, + // }, + // { + // Name: to.Ptr("log_slow_admin_statements"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/log_slow_admin_statements"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Include slow administrative statements in the statements written to the slow query log."), + // AllowedValues: to.Ptr("ON,OFF"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("OFF"), + // }, + // }, + // { + // Name: to.Ptr("log_slow_slave_statements"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/log_slow_slave_statements"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("When the slow query log is enabled, this variable enables logging for queries that have taken more than long_query_time seconds to execute on the slave."), + // AllowedValues: to.Ptr("ON,OFF"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("OFF"), + // }, + // }, + // { + // Name: to.Ptr("log_bin_trust_function_creators"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/log_bin_trust_function_creators"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("This variable applies when binary logging is enabled. It controls whether stored function creators can be trusted not to create stored functions that will cause unsafe events to be written to the binary log."), + // AllowedValues: to.Ptr("ON,OFF"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("OFF"), + // }, + // }, + // { + // Name: to.Ptr("long_query_time"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/long_query_time"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("If a query takes longer than this many seconds, the server increments the Slow_queries status variable."), + // AllowedValues: to.Ptr("0-1E+100"), + // DataType: to.Ptr("Numeric"), + // DefaultValue: to.Ptr("10"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("10"), + // }, + // }, + // { + // Name: to.Ptr("min_examined_row_limit"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/min_examined_row_limit"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Can be used to cause queries which examine fewer than the stated number of rows not to be logged."), + // AllowedValues: to.Ptr("0-18446744073709551615"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("0"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("0"), + // }, + // }, + // { + // Name: to.Ptr("slow_query_log"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/slow_query_log"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Enable or disable the slow query log"), + // AllowedValues: to.Ptr("ON,OFF"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("OFF"), + // }, + // }, + // { + // Name: to.Ptr("sql_mode"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/sql_mode"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The current server SQL mode."), + // AllowedValues: to.Ptr(",ALLOW_INVALID_DATES,ANSI_QUOTES,ERROR_FOR_DIVISION_BY_ZERO,HIGH_NOT_PRECEDENCE,IGNORE_SPACE,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_BACKSLASH_ESCAPES,NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,NO_FIELD_OPTIONS,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_UNSIGNED_SUBTRACTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY,PAD_CHAR_TO_FULL_LENGTH,PIPES_AS_CONCAT,REAL_AS_FLOAT,STRICT_ALL_TABLES,STRICT_TRANS_TABLES"), + // DataType: to.Ptr("Set"), + // DefaultValue: to.Ptr(""), + // Source: to.Ptr("system-default"), + // Value: to.Ptr(""), + // }, + // }, + // { + // Name: to.Ptr("wait_timeout"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/wait_timeout"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The number of seconds the server waits for activity on a noninteractive connection before closing it."), + // AllowedValues: to.Ptr("60-86400"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("120"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("120"), + // }, + // }, + // { + // Name: to.Ptr("net_read_timeout"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/net_read_timeout"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The number of seconds the server waits for network reading action, especially for LOAD DATA LOCAL FILE."), + // AllowedValues: to.Ptr("10-3600"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("120"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("120"), + // }, + // }, + // { + // Name: to.Ptr("net_write_timeout"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/net_write_timeout"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The number of seconds the server waits for network writing action, especially for LOAD DATA LOCAL FILE."), + // AllowedValues: to.Ptr("10-3600"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("240"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("240"), + // }, + // }, + // { + // Name: to.Ptr("server_id"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/server_id"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The server ID, used in replication to give each master and slave a unique identity."), + // AllowedValues: to.Ptr("1000-4294967295"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("1000"), + // Source: to.Ptr("user-override"), + // Value: to.Ptr("1381286943"), + // }, + // }, + // { + // Name: to.Ptr("max_allowed_packet"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/max_allowed_packet"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The maximum size of one packet or any generated/intermediate string, or any parameter sent by the mysql_stmt_send_long_data() C API function."), + // AllowedValues: to.Ptr("1024-1073741824"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("536870912"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("536870912"), + // }, + // }, + // { + // Name: to.Ptr("slave_net_timeout"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/slave_net_timeout"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The number of seconds to wait for more data from the master before the slave considers the connection broken, aborts the read, and tries to reconnect."), + // AllowedValues: to.Ptr("30-3600"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("60"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("60"), + // }, + // }, + // { + // Name: to.Ptr("time_zone"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/time_zone"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The server time zone"), + // AllowedValues: to.Ptr("[+|-][0]{0,1}[0-9]:[0-5][0-9]|[+|-][1][0-2]:[0-5][0-9]|SYSTEM"), + // DataType: to.Ptr("String"), + // DefaultValue: to.Ptr("SYSTEM"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("SYSTEM"), + // }, + // }, + // { + // Name: to.Ptr("binlog_group_commit_sync_delay"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/binlog_group_commit_sync_delay"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Controls how many microseconds the binary log commit waits before synchronizing the binary log file to disk."), + // AllowedValues: to.Ptr("0,11-1000000"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("1000"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("1000"), + // }, + // }, + // { + // Name: to.Ptr("binlog_group_commit_sync_no_delay_count"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/binlog_group_commit_sync_no_delay_count"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The maximum number of transactions to wait for before aborting the current delay as specified by binlog-group-commit-sync-delay."), + // AllowedValues: to.Ptr("0-1000000"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("0"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("0"), + // }, + // }, + // { + // Name: to.Ptr("character_set_server"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/character_set_server"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Use charset_name as the default server character set."), + // AllowedValues: to.Ptr("BIG5,DEC8,CP850,HP8,KOI8R,LATIN1,LATIN2,SWE7,ASCII,UJIS,SJIS,HEBREW,TIS620,EUCKR,KOI8U,GB2312,GREEK,CP1250,GBK,LATIN5,ARMSCII8,UTF8,UCS2,CP866,KEYBCS2,MACCE,MACROMAN,CP852,LATIN7,UTF8MB4,CP1251,UTF16,CP1256,CP1257,UTF32,BINARY,GEOSTD8,CP932,EUCJPMS"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("latin1"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("latin1"), + // }, + // }, + // { + // Name: to.Ptr("join_buffer_size"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/join_buffer_size"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The minimum size of the buffer that is used for plain index scans, range index scans, and joins that do not use indexes and thus perform full table scans."), + // AllowedValues: to.Ptr("128-2097152"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("262144"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("262144"), + // }, + // }, + // { + // Name: to.Ptr("table_open_cache"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/table_open_cache"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The number of open tables for all threads."), + // AllowedValues: to.Ptr("1-4000"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("2000"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("2000"), + // }, + // }, + // { + // Name: to.Ptr("lower_case_table_names"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/lower_case_table_names"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("If set to 1, table names are stored in lowercase on disk and comparisons are not case sensitive. If set to 2, table names are stored as given but compared in lowercase."), + // AllowedValues: to.Ptr("1,2"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("1"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("1"), + // }, + // }, + // { + // Name: to.Ptr("slave_compressed_protocol"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/slave_compressed_protocol"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("This option places an upper limit on the total size in bytes of all relay logs on the slave."), + // AllowedValues: to.Ptr("ON,OFF"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("OFF"), + // }, + // }, + // { + // Name: to.Ptr("innodb_io_capacity"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/innodb_io_capacity"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Sets an upper limit on I/O activity performed by InnoDB background tasks, such as flushing pages from the buffer pool and merging data from the change buffer."), + // AllowedValues: to.Ptr("100-1500"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("200"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("200"), + // }, + // }, + // { + // Name: to.Ptr("innodb_read_io_threads"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/innodb_read_io_threads"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The number of I/O threads for read operations in InnoDB."), + // AllowedValues: to.Ptr("1-64"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("4"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("4"), + // }, + // }, + // { + // Name: to.Ptr("innodb_thread_concurrency"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/innodb_thread_concurrency"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("InnoDB tries to keep the number of operating system threads concurrently inside InnoDB less than or equal to the limit given by this variable."), + // AllowedValues: to.Ptr("0-1000"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("0"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("0"), + // }, + // }, + // { + // Name: to.Ptr("innodb_write_io_threads"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/innodb_write_io_threads"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The number of I/O threads for write operations in InnoDB."), + // AllowedValues: to.Ptr("1-64"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("4"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("4"), + // }, + // }, + // { + // Name: to.Ptr("innodb_page_cleaners"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/innodb_page_cleaners"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The number of page cleaner threads that flush dirty pages from buffer pool instances."), + // AllowedValues: to.Ptr("1-64"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("4"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("4"), + // }, + // }, + // { + // Name: to.Ptr("innodb_online_alter_log_max_size"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/innodb_online_alter_log_max_size"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Specifies an upper limit on the size of the temporary log files used during online DDL operations for InnoDB tables."), + // AllowedValues: to.Ptr("65536-2147483648"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("134217728"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("134217728"), + // }, + // }, + // { + // Name: to.Ptr("init_connect"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/init_connect"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("A string to be executed by the server for each client that connects."), + // AllowedValues: to.Ptr(""), + // DataType: to.Ptr("String"), + // DefaultValue: to.Ptr(""), + // Source: to.Ptr("system-default"), + // Value: to.Ptr(""), + // }, + // }, + // { + // Name: to.Ptr("tx_isolation"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/tx_isolation"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The default transaction isolation level."), + // AllowedValues: to.Ptr("READ-UNCOMMITTED,READ-COMMITTED,REPEATABLE-READ,SERIALIZABLE"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("REPEATABLE-READ"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("REPEATABLE-READ"), + // }, + // }, + // { + // Name: to.Ptr("eq_range_index_dive_limit"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/eq_range_index_dive_limit"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("This variable indicates the number of equality ranges in an equality comparison condition when the optimizer should switch from using index dives to index statistics in estimating the number of qualifying rows."), + // AllowedValues: to.Ptr("0-4294967295"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("200"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("200"), + // }, + // }, + // { + // Name: to.Ptr("innodb_old_blocks_pct"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/innodb_old_blocks_pct"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Specifies the approximate percentage of the InnoDB buffer pool used for the old block sublist."), + // AllowedValues: to.Ptr("5-95"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("37"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("37"), + // }, + // }, + // { + // Name: to.Ptr("innodb_old_blocks_time"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/innodb_old_blocks_time"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Non-zero values protect against the buffer pool being filled by data that is referenced only for a brief period, such as during a full table scan."), + // AllowedValues: to.Ptr("0-4294967295"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("1000"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("1000"), + // }, + // }, + // { + // Name: to.Ptr("innodb_read_ahead_threshold"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/innodb_read_ahead_threshold"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Controls the sensitivity of linear read-ahead that InnoDB uses to prefetch pages into the buffer pool."), + // AllowedValues: to.Ptr("0-64"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("56"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("56"), + // }, + // }, + // { + // Name: to.Ptr("max_length_for_sort_data"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/max_length_for_sort_data"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("The cutoff on the size of index values that determines which filesort algorithm to use."), + // AllowedValues: to.Ptr("4-8388608"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("1024"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("1024"), + // }, + // }, + // { + // Name: to.Ptr("max_connect_errors"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/max_connect_errors"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("If more than this many successive connection requests from a host are interrupted without a successful connection, the server blocks that host from further connections."), + // AllowedValues: to.Ptr("1-18446744073709551615"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("100"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("100"), + // }, + // }, + // { + // Name: to.Ptr("innodb_thread_sleep_delay"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/innodb_thread_sleep_delay"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Defines how long InnoDB threads sleep before joining the InnoDB queue, in microseconds."), + // AllowedValues: to.Ptr("0-1000000"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("10000"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("10000"), + // }, + // }, + // { + // Name: to.Ptr("innodb_file_format"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/innodb_file_format"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Indicates the InnoDB file format for file-per-table tablespaces."), + // AllowedValues: to.Ptr("Antelope,Barracuda"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("Barracuda"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("Barracuda"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_constants.go b/sdk/resourcemanager/mysql/armmysql/constants.go similarity index 99% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_constants.go rename to sdk/resourcemanager/mysql/armmysql/constants.go index 081c7a9715d7..16fafc3a368f 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_constants.go +++ b/sdk/resourcemanager/mysql/armmysql/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 armmysql const ( moduleName = "armmysql" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // CreateMode - The mode to create a new server. diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_databases_client.go b/sdk/resourcemanager/mysql/armmysql/databases_client.go similarity index 83% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_databases_client.go rename to sdk/resourcemanager/mysql/armmysql/databases_client.go index 2f8cced0e13e..683729241ca9 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_databases_client.go +++ b/sdk/resourcemanager/mysql/armmysql/databases_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,65 +24,58 @@ import ( // DatabasesClient contains the methods for the Databases group. // Don't use this type directly, use NewDatabasesClient() instead. type DatabasesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDatabasesClient creates a new instance of DatabasesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewDatabasesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DatabasesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".DatabasesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DatabasesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates a new database or updates an existing database. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// databaseName - The name of the database. -// parameters - The required parameters for creating or updating a database. -// options - DatabasesClientBeginCreateOrUpdateOptions contains the optional parameters for the DatabasesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - databaseName - The name of the database. +// - parameters - The required parameters for creating or updating a database. +// - options - DatabasesClientBeginCreateOrUpdateOptions contains the optional parameters for the DatabasesClient.BeginCreateOrUpdate +// method. func (client *DatabasesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database, options *DatabasesClientBeginCreateOrUpdateOptions) (*runtime.Poller[DatabasesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, serverName, databaseName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[DatabasesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[DatabasesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DatabasesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DatabasesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates a new database or updates an existing database. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 func (client *DatabasesClient) createOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database, options *DatabasesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serverName, databaseName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -112,7 +104,7 @@ func (client *DatabasesClient) createOrUpdateCreateRequest(ctx context.Context, return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -125,32 +117,34 @@ func (client *DatabasesClient) createOrUpdateCreateRequest(ctx context.Context, // BeginDelete - Deletes a database. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// databaseName - The name of the database. -// options - DatabasesClientBeginDeleteOptions contains the optional parameters for the DatabasesClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - databaseName - The name of the database. +// - options - DatabasesClientBeginDeleteOptions contains the optional parameters for the DatabasesClient.BeginDelete method. func (client *DatabasesClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, options *DatabasesClientBeginDeleteOptions) (*runtime.Poller[DatabasesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, databaseName, options) if err != nil { return nil, err } - return runtime.NewPoller[DatabasesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[DatabasesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DatabasesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DatabasesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a database. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 func (client *DatabasesClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, options *DatabasesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, databaseName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -179,7 +173,7 @@ func (client *DatabasesClient) deleteCreateRequest(ctx context.Context, resource return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -192,17 +186,18 @@ func (client *DatabasesClient) deleteCreateRequest(ctx context.Context, resource // Get - Gets information about a database. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// databaseName - The name of the database. -// options - DatabasesClientGetOptions contains the optional parameters for the DatabasesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - databaseName - The name of the database. +// - options - DatabasesClientGetOptions contains the optional parameters for the DatabasesClient.Get method. func (client *DatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, options *DatabasesClientGetOptions) (DatabasesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, databaseName, options) if err != nil { return DatabasesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DatabasesClientGetResponse{}, err } @@ -231,7 +226,7 @@ func (client *DatabasesClient) getCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -252,11 +247,12 @@ func (client *DatabasesClient) getHandleResponse(resp *http.Response) (Databases } // NewListByServerPager - List all the databases in a given server. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - DatabasesClientListByServerOptions contains the optional parameters for the DatabasesClient.ListByServer method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - DatabasesClientListByServerOptions contains the optional parameters for the DatabasesClient.NewListByServerPager +// method. func (client *DatabasesClient) NewListByServerPager(resourceGroupName string, serverName string, options *DatabasesClientListByServerOptions) *runtime.Pager[DatabasesClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[DatabasesClientListByServerResponse]{ More: func(page DatabasesClientListByServerResponse) bool { @@ -267,7 +263,7 @@ func (client *DatabasesClient) NewListByServerPager(resourceGroupName string, se if err != nil { return DatabasesClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DatabasesClientListByServerResponse{}, err } @@ -294,7 +290,7 @@ func (client *DatabasesClient) listByServerCreateRequest(ctx context.Context, re return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/databases_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/databases_client_example_test.go new file mode 100644 index 000000000000..061c00be4c0a --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/databases_client_example_test.go @@ -0,0 +1,153 @@ +//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 armmysql_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/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/DatabaseCreate.json +func ExampleDatabasesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDatabasesClient().BeginCreateOrUpdate(ctx, "TestGroup", "testserver", "db1", armmysql.Database{ + Properties: &armmysql.DatabaseProperties{ + Charset: to.Ptr("utf8"), + Collation: to.Ptr("utf8_general_ci"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Database = armmysql.Database{ + // Name: to.Ptr("db1"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/databases"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testserver/databases/db1"), + // Properties: &armmysql.DatabaseProperties{ + // Charset: to.Ptr("utf8"), + // Collation: to.Ptr("utf8_general_ci"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/DatabaseDelete.json +func ExampleDatabasesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDatabasesClient().BeginDelete(ctx, "TestGroup", "testserver", "db1", 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/DatabaseGet.json +func ExampleDatabasesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDatabasesClient().Get(ctx, "TestGroup", "testserver", "db1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Database = armmysql.Database{ + // Name: to.Ptr("db1"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/databases"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testserver/databases/db1"), + // Properties: &armmysql.DatabaseProperties{ + // Charset: to.Ptr("utf8"), + // Collation: to.Ptr("utf8_general_ci"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/DatabaseListByServer.json +func ExampleDatabasesClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDatabasesClient().NewListByServerPager("TestGroup", "testserver", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DatabaseListResult = armmysql.DatabaseListResult{ + // Value: []*armmysql.Database{ + // { + // Name: to.Ptr("db1"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/databases"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testserver/databases/db1"), + // Properties: &armmysql.DatabaseProperties{ + // Charset: to.Ptr("utf8"), + // Collation: to.Ptr("utf8_general_ci"), + // }, + // }, + // { + // Name: to.Ptr("db2"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/databases"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testserver/databases/db2"), + // Properties: &armmysql.DatabaseProperties{ + // Charset: to.Ptr("utf8"), + // Collation: to.Ptr("utf8_general_ci"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_firewallrules_client.go b/sdk/resourcemanager/mysql/armmysql/firewallrules_client.go similarity index 83% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_firewallrules_client.go rename to sdk/resourcemanager/mysql/armmysql/firewallrules_client.go index ac51703a362b..5eb49d335cff 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_firewallrules_client.go +++ b/sdk/resourcemanager/mysql/armmysql/firewallrules_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,65 +24,58 @@ import ( // FirewallRulesClient contains the methods for the FirewallRules group. // Don't use this type directly, use NewFirewallRulesClient() instead. type FirewallRulesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewFirewallRulesClient creates a new instance of FirewallRulesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewFirewallRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FirewallRulesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".FirewallRulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &FirewallRulesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates a new firewall rule or updates an existing firewall rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// firewallRuleName - The name of the server firewall rule. -// parameters - The required parameters for creating or updating a firewall rule. -// options - FirewallRulesClientBeginCreateOrUpdateOptions contains the optional parameters for the FirewallRulesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - firewallRuleName - The name of the server firewall rule. +// - parameters - The required parameters for creating or updating a firewall rule. +// - options - FirewallRulesClientBeginCreateOrUpdateOptions contains the optional parameters for the FirewallRulesClient.BeginCreateOrUpdate +// method. func (client *FirewallRulesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule, options *FirewallRulesClientBeginCreateOrUpdateOptions) (*runtime.Poller[FirewallRulesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, serverName, firewallRuleName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[FirewallRulesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[FirewallRulesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[FirewallRulesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[FirewallRulesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates a new firewall rule or updates an existing firewall rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 func (client *FirewallRulesClient) createOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule, options *FirewallRulesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serverName, firewallRuleName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -112,7 +104,7 @@ func (client *FirewallRulesClient) createOrUpdateCreateRequest(ctx context.Conte return nil, errors.New("parameter firewallRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{firewallRuleName}", url.PathEscape(firewallRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -125,33 +117,35 @@ func (client *FirewallRulesClient) createOrUpdateCreateRequest(ctx context.Conte // BeginDelete - Deletes a server firewall rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// firewallRuleName - The name of the server firewall rule. -// options - FirewallRulesClientBeginDeleteOptions contains the optional parameters for the FirewallRulesClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - firewallRuleName - The name of the server firewall rule. +// - options - FirewallRulesClientBeginDeleteOptions contains the optional parameters for the FirewallRulesClient.BeginDelete +// method. func (client *FirewallRulesClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesClientBeginDeleteOptions) (*runtime.Poller[FirewallRulesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, firewallRuleName, options) if err != nil { return nil, err } - return runtime.NewPoller[FirewallRulesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[FirewallRulesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[FirewallRulesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[FirewallRulesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a server firewall rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 func (client *FirewallRulesClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, firewallRuleName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -180,7 +174,7 @@ func (client *FirewallRulesClient) deleteCreateRequest(ctx context.Context, reso return nil, errors.New("parameter firewallRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{firewallRuleName}", url.PathEscape(firewallRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -193,17 +187,18 @@ func (client *FirewallRulesClient) deleteCreateRequest(ctx context.Context, reso // Get - Gets information about a server firewall rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// firewallRuleName - The name of the server firewall rule. -// options - FirewallRulesClientGetOptions contains the optional parameters for the FirewallRulesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - firewallRuleName - The name of the server firewall rule. +// - options - FirewallRulesClientGetOptions contains the optional parameters for the FirewallRulesClient.Get method. func (client *FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesClientGetOptions) (FirewallRulesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, firewallRuleName, options) if err != nil { return FirewallRulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FirewallRulesClientGetResponse{}, err } @@ -232,7 +227,7 @@ func (client *FirewallRulesClient) getCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter firewallRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{firewallRuleName}", url.PathEscape(firewallRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -253,12 +248,12 @@ func (client *FirewallRulesClient) getHandleResponse(resp *http.Response) (Firew } // NewListByServerPager - List all the firewall rules in a given server. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - FirewallRulesClientListByServerOptions contains the optional parameters for the FirewallRulesClient.ListByServer -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - FirewallRulesClientListByServerOptions contains the optional parameters for the FirewallRulesClient.NewListByServerPager +// method. func (client *FirewallRulesClient) NewListByServerPager(resourceGroupName string, serverName string, options *FirewallRulesClientListByServerOptions) *runtime.Pager[FirewallRulesClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[FirewallRulesClientListByServerResponse]{ More: func(page FirewallRulesClientListByServerResponse) bool { @@ -269,7 +264,7 @@ func (client *FirewallRulesClient) NewListByServerPager(resourceGroupName string if err != nil { return FirewallRulesClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FirewallRulesClientListByServerResponse{}, err } @@ -296,7 +291,7 @@ func (client *FirewallRulesClient) listByServerCreateRequest(ctx context.Context return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/firewallrules_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/firewallrules_client_example_test.go new file mode 100644 index 000000000000..f9e1bafc177c --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/firewallrules_client_example_test.go @@ -0,0 +1,153 @@ +//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 armmysql_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/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/FirewallRuleCreate.json +func ExampleFirewallRulesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFirewallRulesClient().BeginCreateOrUpdate(ctx, "TestGroup", "testserver", "rule1", armmysql.FirewallRule{ + Properties: &armmysql.FirewallRuleProperties{ + EndIPAddress: to.Ptr("255.255.255.255"), + StartIPAddress: to.Ptr("0.0.0.0"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.FirewallRule = armmysql.FirewallRule{ + // Name: to.Ptr("rule1"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/firewallRules"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testserver/firewallRules/rule1"), + // Properties: &armmysql.FirewallRuleProperties{ + // EndIPAddress: to.Ptr("255.255.255.255"), + // StartIPAddress: to.Ptr("0.0.0.0"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/FirewallRuleDelete.json +func ExampleFirewallRulesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFirewallRulesClient().BeginDelete(ctx, "TestGroup", "testserver", "rule1", 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/FirewallRuleGet.json +func ExampleFirewallRulesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirewallRulesClient().Get(ctx, "TestGroup", "testserver", "rule1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.FirewallRule = armmysql.FirewallRule{ + // Name: to.Ptr("rule1"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/firewallRules"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testserver/firewallRules/rule1"), + // Properties: &armmysql.FirewallRuleProperties{ + // EndIPAddress: to.Ptr("255.255.255.255"), + // StartIPAddress: to.Ptr("0.0.0.0"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/FirewallRuleListByServer.json +func ExampleFirewallRulesClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirewallRulesClient().NewListByServerPager("TestGroup", "testserver", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.FirewallRuleListResult = armmysql.FirewallRuleListResult{ + // Value: []*armmysql.FirewallRule{ + // { + // Name: to.Ptr("rule1"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/firewallRules"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testserver/firewallRules/rule1"), + // Properties: &armmysql.FirewallRuleProperties{ + // EndIPAddress: to.Ptr("255.255.255.255"), + // StartIPAddress: to.Ptr("0.0.0.0"), + // }, + // }, + // { + // Name: to.Ptr("rule2"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/firewallRules"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testserver/firewallRules/rule2"), + // Properties: &armmysql.FirewallRuleProperties{ + // EndIPAddress: to.Ptr("255.0.0.0"), + // StartIPAddress: to.Ptr("1.0.0.0"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/go.mod b/sdk/resourcemanager/mysql/armmysql/go.mod index fe0c4edaeeef..b2df71c63ef9 100644 --- a/sdk/resourcemanager/mysql/armmysql/go.mod +++ b/sdk/resourcemanager/mysql/armmysql/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) 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/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/mysql/armmysql/go.sum b/sdk/resourcemanager/mysql/armmysql/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/mysql/armmysql/go.sum +++ b/sdk/resourcemanager/mysql/armmysql/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= 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/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_locationbasedperformancetier_client.go b/sdk/resourcemanager/mysql/armmysql/locationbasedperformancetier_client.go similarity index 78% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_locationbasedperformancetier_client.go rename to sdk/resourcemanager/mysql/armmysql/locationbasedperformancetier_client.go index 10a2ae44bdd8..12fa9a6bed55 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_locationbasedperformancetier_client.go +++ b/sdk/resourcemanager/mysql/armmysql/locationbasedperformancetier_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,41 +24,32 @@ import ( // LocationBasedPerformanceTierClient contains the methods for the LocationBasedPerformanceTier group. // Don't use this type directly, use NewLocationBasedPerformanceTierClient() instead. type LocationBasedPerformanceTierClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewLocationBasedPerformanceTierClient creates a new instance of LocationBasedPerformanceTierClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewLocationBasedPerformanceTierClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LocationBasedPerformanceTierClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".LocationBasedPerformanceTierClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LocationBasedPerformanceTierClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - List all the performance tiers at specified location in a given subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// locationName - The name of the location. -// options - LocationBasedPerformanceTierClientListOptions contains the optional parameters for the LocationBasedPerformanceTierClient.List -// method. +// - locationName - The name of the location. +// - options - LocationBasedPerformanceTierClientListOptions contains the optional parameters for the LocationBasedPerformanceTierClient.NewListPager +// method. func (client *LocationBasedPerformanceTierClient) NewListPager(locationName string, options *LocationBasedPerformanceTierClientListOptions) *runtime.Pager[LocationBasedPerformanceTierClientListResponse] { return runtime.NewPager(runtime.PagingHandler[LocationBasedPerformanceTierClientListResponse]{ More: func(page LocationBasedPerformanceTierClientListResponse) bool { @@ -70,7 +60,7 @@ func (client *LocationBasedPerformanceTierClient) NewListPager(locationName stri if err != nil { return LocationBasedPerformanceTierClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LocationBasedPerformanceTierClientListResponse{}, err } @@ -93,7 +83,7 @@ func (client *LocationBasedPerformanceTierClient) listCreateRequest(ctx context. return nil, errors.New("parameter locationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/locationbasedperformancetier_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/locationbasedperformancetier_client_example_test.go new file mode 100644 index 000000000000..8aa5bc724673 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/locationbasedperformancetier_client_example_test.go @@ -0,0 +1,206 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/PerformanceTiersListByLocation.json +func ExampleLocationBasedPerformanceTierClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLocationBasedPerformanceTierClient().NewListPager("WestUS", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PerformanceTierListResult = armmysql.PerformanceTierListResult{ + // Value: []*armmysql.PerformanceTierProperties{ + // { + // ID: to.Ptr("Basic"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxLargeStorageMB: to.Ptr[int32](0), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinLargeStorageMB: to.Ptr[int32](0), + // MinStorageMB: to.Ptr[int32](5120), + // ServiceLevelObjectives: []*armmysql.PerformanceTierServiceLevelObjectives{ + // { + // Edition: to.Ptr("Basic"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("B_Gen5_1"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](1048576), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](1), + // }, + // { + // Edition: to.Ptr("Basic"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("B_Gen5_2"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](1048576), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](2), + // }}, + // }, + // { + // ID: to.Ptr("GeneralPurpose"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxLargeStorageMB: to.Ptr[int32](16777216), + // MaxStorageMB: to.Ptr[int32](16777216), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinLargeStorageMB: to.Ptr[int32](0), + // MinStorageMB: to.Ptr[int32](5120), + // ServiceLevelObjectives: []*armmysql.PerformanceTierServiceLevelObjectives{ + // { + // Edition: to.Ptr("GeneralPurpose"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("GP_Gen5_2"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](2), + // }, + // { + // Edition: to.Ptr("GeneralPurpose"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("GP_Gen5_4"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](4), + // }, + // { + // Edition: to.Ptr("GeneralPurpose"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("GP_Gen5_8"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](8), + // }, + // { + // Edition: to.Ptr("GeneralPurpose"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("GP_Gen5_16"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](16), + // }, + // { + // Edition: to.Ptr("GeneralPurpose"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("GP_Gen5_32"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](32), + // }, + // { + // Edition: to.Ptr("GeneralPurpose"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("GP_Gen5_64"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](32), + // }}, + // }, + // { + // ID: to.Ptr("MemoryOptimized"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxLargeStorageMB: to.Ptr[int32](16777216), + // MaxStorageMB: to.Ptr[int32](16777216), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinLargeStorageMB: to.Ptr[int32](0), + // MinStorageMB: to.Ptr[int32](5120), + // ServiceLevelObjectives: []*armmysql.PerformanceTierServiceLevelObjectives{ + // { + // Edition: to.Ptr("MemoryOptimized"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("MO_Gen5_2"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](2), + // }, + // { + // Edition: to.Ptr("MemoryOptimized"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("MO_Gen5_4"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](4), + // }, + // { + // Edition: to.Ptr("MemoryOptimized"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("MO_Gen5_8"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](8), + // }, + // { + // Edition: to.Ptr("MemoryOptimized"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("MO_Gen5_16"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](16), + // }, + // { + // Edition: to.Ptr("MemoryOptimized"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("MO_Gen5_32"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](32), + // }}, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_locationbasedrecommendedactionsessionsoperationstatus_client.go b/sdk/resourcemanager/mysql/armmysql/locationbasedrecommendedactionsessionsoperationstatus_client.go similarity index 80% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_locationbasedrecommendedactionsessionsoperationstatus_client.go rename to sdk/resourcemanager/mysql/armmysql/locationbasedrecommendedactionsessionsoperationstatus_client.go index 232f9d707390..b33abb0898af 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_locationbasedrecommendedactionsessionsoperationstatus_client.go +++ b/sdk/resourcemanager/mysql/armmysql/locationbasedrecommendedactionsessionsoperationstatus_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // LocationBasedRecommendedActionSessionsOperationStatusClient contains the methods for the LocationBasedRecommendedActionSessionsOperationStatus group. // Don't use this type directly, use NewLocationBasedRecommendedActionSessionsOperationStatusClient() instead. type LocationBasedRecommendedActionSessionsOperationStatusClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewLocationBasedRecommendedActionSessionsOperationStatusClient creates a new instance of LocationBasedRecommendedActionSessionsOperationStatusClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewLocationBasedRecommendedActionSessionsOperationStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LocationBasedRecommendedActionSessionsOperationStatusClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".LocationBasedRecommendedActionSessionsOperationStatusClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LocationBasedRecommendedActionSessionsOperationStatusClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Recommendation action session operation status. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// locationName - The name of the location. -// operationID - The operation identifier. -// options - LocationBasedRecommendedActionSessionsOperationStatusClientGetOptions contains the optional parameters for the -// LocationBasedRecommendedActionSessionsOperationStatusClient.Get method. +// - locationName - The name of the location. +// - operationID - The operation identifier. +// - options - LocationBasedRecommendedActionSessionsOperationStatusClientGetOptions contains the optional parameters for the +// LocationBasedRecommendedActionSessionsOperationStatusClient.Get method. func (client *LocationBasedRecommendedActionSessionsOperationStatusClient) Get(ctx context.Context, locationName string, operationID string, options *LocationBasedRecommendedActionSessionsOperationStatusClientGetOptions) (LocationBasedRecommendedActionSessionsOperationStatusClientGetResponse, error) { req, err := client.getCreateRequest(ctx, locationName, operationID, options) if err != nil { return LocationBasedRecommendedActionSessionsOperationStatusClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LocationBasedRecommendedActionSessionsOperationStatusClientGetResponse{}, err } @@ -91,7 +82,7 @@ func (client *LocationBasedRecommendedActionSessionsOperationStatusClient) getCr return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/locationbasedrecommendedactionsessionsoperationstatus_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/locationbasedrecommendedactionsessionsoperationstatus_client_example_test.go new file mode 100644 index 000000000000..feb7f25fcb94 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/locationbasedrecommendedactionsessionsoperationstatus_client_example_test.go @@ -0,0 +1,43 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/RecommendedActionSessionOperationStatus.json +func ExampleLocationBasedRecommendedActionSessionsOperationStatusClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewLocationBasedRecommendedActionSessionsOperationStatusClient().Get(ctx, "WestUS", "aaaabbbb-cccc-dddd-0000-111122223333", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RecommendedActionSessionsOperationStatus = armmysql.RecommendedActionSessionsOperationStatus{ + // Name: to.Ptr("aaaabbbb-cccc-dddd-0000-111122223333"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-01T17:15:00Z"); return t}()), + // Status: to.Ptr("succeeded"), + // } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_locationbasedrecommendedactionsessionsresult_client.go b/sdk/resourcemanager/mysql/armmysql/locationbasedrecommendedactionsessionsresult_client.go similarity index 80% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_locationbasedrecommendedactionsessionsresult_client.go rename to sdk/resourcemanager/mysql/armmysql/locationbasedrecommendedactionsessionsresult_client.go index 24e857bdf795..c16a44e95289 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_locationbasedrecommendedactionsessionsresult_client.go +++ b/sdk/resourcemanager/mysql/armmysql/locationbasedrecommendedactionsessionsresult_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,42 +24,33 @@ import ( // LocationBasedRecommendedActionSessionsResultClient contains the methods for the LocationBasedRecommendedActionSessionsResult group. // Don't use this type directly, use NewLocationBasedRecommendedActionSessionsResultClient() instead. type LocationBasedRecommendedActionSessionsResultClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewLocationBasedRecommendedActionSessionsResultClient creates a new instance of LocationBasedRecommendedActionSessionsResultClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewLocationBasedRecommendedActionSessionsResultClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LocationBasedRecommendedActionSessionsResultClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".LocationBasedRecommendedActionSessionsResultClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LocationBasedRecommendedActionSessionsResultClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Recommendation action session operation result. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// locationName - The name of the location. -// operationID - The operation identifier. -// options - LocationBasedRecommendedActionSessionsResultClientListOptions contains the optional parameters for the LocationBasedRecommendedActionSessionsResultClient.List -// method. +// - locationName - The name of the location. +// - operationID - The operation identifier. +// - options - LocationBasedRecommendedActionSessionsResultClientListOptions contains the optional parameters for the LocationBasedRecommendedActionSessionsResultClient.NewListPager +// method. func (client *LocationBasedRecommendedActionSessionsResultClient) NewListPager(locationName string, operationID string, options *LocationBasedRecommendedActionSessionsResultClientListOptions) *runtime.Pager[LocationBasedRecommendedActionSessionsResultClientListResponse] { return runtime.NewPager(runtime.PagingHandler[LocationBasedRecommendedActionSessionsResultClientListResponse]{ More: func(page LocationBasedRecommendedActionSessionsResultClientListResponse) bool { @@ -77,7 +67,7 @@ func (client *LocationBasedRecommendedActionSessionsResultClient) NewListPager(l if err != nil { return LocationBasedRecommendedActionSessionsResultClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LocationBasedRecommendedActionSessionsResultClientListResponse{}, err } @@ -104,7 +94,7 @@ func (client *LocationBasedRecommendedActionSessionsResultClient) listCreateRequ return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/locationbasedrecommendedactionsessionsresult_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/locationbasedrecommendedactionsessionsresult_client_example_test.go new file mode 100644 index 000000000000..40c90f5d226b --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/locationbasedrecommendedactionsessionsresult_client_example_test.go @@ -0,0 +1,96 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/RecommendedActionSessionResult.json +func ExampleLocationBasedRecommendedActionSessionsResultClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLocationBasedRecommendedActionSessionsResultClient().NewListPager("WestUS", "aaaabbbb-cccc-dddd-0000-111122223333", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RecommendationActionsResultList = armmysql.RecommendationActionsResultList{ + // Value: []*armmysql.RecommendationAction{ + // { + // Name: to.Ptr("Index-1"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/advisors/recommendedActions"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.Sql/servers/testServerName/advisors/Index/recommendedActions/Index-1"), + // Properties: &armmysql.RecommendationActionProperties{ + // ActionID: to.Ptr[int32](1), + // AdvisorName: to.Ptr("Index"), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-01T23:43:24Z"); return t}()), + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-08T23:43:24Z"); return t}()), + // Reason: to.Ptr("Column `movies_genres`.`movie_id` appear in Join On clause(s)."), + // RecommendationType: to.Ptr("Add"), + // SessionID: to.Ptr("c63c2114-e2a4-4c7a-98c1-85577d1a5d50"), + // Details: map[string]*string{ + // "engine": to.Ptr("InnoDB"), + // "indexColumns": to.Ptr("`movies_genres`.`movie_id`"), + // "indexName": to.Ptr("idx_movie_id"), + // "indexType": to.Ptr("BTREE"), + // "parentTableName": to.Ptr("movies_genres"), + // "queryIds": to.Ptr("779"), + // "schemaName": to.Ptr("movies"), + // "script": to.Ptr("alter table `movies`.`movies_genres` add index `idx_movie_id` (`movie_id`)"), + // "tableName": to.Ptr("movies_genres"), + // }, + // }, + // }, + // { + // Name: to.Ptr("Index-2"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/advisors/recommendedActions"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.Sql/servers/testServerName/advisors/Index/recommendedActions/Index-2"), + // Properties: &armmysql.RecommendationActionProperties{ + // ActionID: to.Ptr[int32](2), + // AdvisorName: to.Ptr("Index"), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-01T23:43:24Z"); return t}()), + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-08T23:43:24Z"); return t}()), + // Reason: to.Ptr("Column `movies_genres`.`genre` appear in Group By clause(s)."), + // RecommendationType: to.Ptr("Add"), + // SessionID: to.Ptr("c63c2114-e2a4-4c7a-98c1-85577d1a5d50"), + // Details: map[string]*string{ + // "engine": to.Ptr("InnoDB"), + // "indexColumns": to.Ptr("`movies_genres`.`genre`"), + // "indexName": to.Ptr("idx_genre"), + // "indexType": to.Ptr("BTREE"), + // "parentTableName": to.Ptr("movies_genres"), + // "queryIds": to.Ptr("779"), + // "schemaName": to.Ptr("movies"), + // "script": to.Ptr("alter table `movies`.`movies_genres` add index `idx_genre` (`genre`)"), + // "tableName": to.Ptr("movies_genres"), + // }, + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_logfiles_client.go b/sdk/resourcemanager/mysql/armmysql/logfiles_client.go similarity index 77% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_logfiles_client.go rename to sdk/resourcemanager/mysql/armmysql/logfiles_client.go index b9a5e256022a..c3542acb31e8 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_logfiles_client.go +++ b/sdk/resourcemanager/mysql/armmysql/logfiles_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,41 +24,33 @@ import ( // LogFilesClient contains the methods for the LogFiles group. // Don't use this type directly, use NewLogFilesClient() instead. type LogFilesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewLogFilesClient creates a new instance of LogFilesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewLogFilesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LogFilesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".LogFilesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LogFilesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListByServerPager - List all the log files in a given server. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - LogFilesClientListByServerOptions contains the optional parameters for the LogFilesClient.ListByServer method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - LogFilesClientListByServerOptions contains the optional parameters for the LogFilesClient.NewListByServerPager +// method. func (client *LogFilesClient) NewListByServerPager(resourceGroupName string, serverName string, options *LogFilesClientListByServerOptions) *runtime.Pager[LogFilesClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[LogFilesClientListByServerResponse]{ More: func(page LogFilesClientListByServerResponse) bool { @@ -70,7 +61,7 @@ func (client *LogFilesClient) NewListByServerPager(resourceGroupName string, ser if err != nil { return LogFilesClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LogFilesClientListByServerResponse{}, err } @@ -97,7 +88,7 @@ func (client *LogFilesClient) listByServerCreateRequest(ctx context.Context, res return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/logfiles_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/logfiles_client_example_test.go new file mode 100644 index 000000000000..93ac8283e600 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/logfiles_client_example_test.go @@ -0,0 +1,58 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/LogFileListByServer.json +func ExampleLogFilesClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLogFilesClient().NewListByServerPager("TestGroup", "testserver", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.LogFileListResult = armmysql.LogFileListResult{ + // Value: []*armmysql.LogFile{ + // { + // Name: to.Ptr("mysql-slow-mysqltestsvc1-2018022823.log"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/logFiles"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/logFiles/mysql-slow-mysqltestsvc1-2018022823.log"), + // Properties: &armmysql.LogFileProperties{ + // Type: to.Ptr("slowlog"), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00+00:00"); return t}()), + // LastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-01T06:09:20+00:00"); return t}()), + // SizeInKB: to.Ptr[int64](1), + // URL: to.Ptr("https://wasd2prodwus1afse42.file.core.windows.net/833c99b2f36c47349e5554b903fe0440/serverlogs/mysql-slow-mysqltestsvc1-2018022823.log?sv=2015-04-05&sr=f&sig=D9Ga4N5Pa%2BPe5Bmjpvs7A0TPD%2FF7IZpk9e4KWR0jgpM%3D&se=2018-03-01T07%3A12%3A13Z&sp=r"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_management_client.go b/sdk/resourcemanager/mysql/armmysql/management_client.go similarity index 81% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_management_client.go rename to sdk/resourcemanager/mysql/armmysql/management_client.go index 7a53eaed72bb..b1b957c3c628 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_management_client.go +++ b/sdk/resourcemanager/mysql/armmysql/management_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,65 +24,58 @@ import ( // ManagementClient contains the methods for the MySQLManagementClient group. // Don't use this type directly, use NewManagementClient() instead. type ManagementClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewManagementClient creates a new instance of ManagementClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewManagementClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ManagementClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ManagementClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ManagementClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateRecommendedActionSession - Create recommendation action session for the advisor. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// advisorName - The advisor name for recommendation action. -// databaseName - The name of the database. -// options - ManagementClientBeginCreateRecommendedActionSessionOptions contains the optional parameters for the ManagementClient.BeginCreateRecommendedActionSession -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - advisorName - The advisor name for recommendation action. +// - databaseName - The name of the database. +// - options - ManagementClientBeginCreateRecommendedActionSessionOptions contains the optional parameters for the ManagementClient.BeginCreateRecommendedActionSession +// method. func (client *ManagementClient) BeginCreateRecommendedActionSession(ctx context.Context, resourceGroupName string, serverName string, advisorName string, databaseName string, options *ManagementClientBeginCreateRecommendedActionSessionOptions) (*runtime.Poller[ManagementClientCreateRecommendedActionSessionResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createRecommendedActionSession(ctx, resourceGroupName, serverName, advisorName, databaseName, options) if err != nil { return nil, err } - return runtime.NewPoller[ManagementClientCreateRecommendedActionSessionResponse](resp, client.pl, nil) + return runtime.NewPoller[ManagementClientCreateRecommendedActionSessionResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ManagementClientCreateRecommendedActionSessionResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ManagementClientCreateRecommendedActionSessionResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateRecommendedActionSession - Create recommendation action session for the advisor. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 func (client *ManagementClient) createRecommendedActionSession(ctx context.Context, resourceGroupName string, serverName string, advisorName string, databaseName string, options *ManagementClientBeginCreateRecommendedActionSessionOptions) (*http.Response, error) { req, err := client.createRecommendedActionSessionCreateRequest(ctx, resourceGroupName, serverName, advisorName, databaseName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -112,7 +104,7 @@ func (client *ManagementClient) createRecommendedActionSessionCreateRequest(ctx return nil, errors.New("parameter advisorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{advisorName}", url.PathEscape(advisorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -125,17 +117,18 @@ func (client *ManagementClient) createRecommendedActionSessionCreateRequest(ctx // ResetQueryPerformanceInsightData - Reset data for Query Performance Insight. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ManagementClientResetQueryPerformanceInsightDataOptions contains the optional parameters for the ManagementClient.ResetQueryPerformanceInsightData -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ManagementClientResetQueryPerformanceInsightDataOptions contains the optional parameters for the ManagementClient.ResetQueryPerformanceInsightData +// method. func (client *ManagementClient) ResetQueryPerformanceInsightData(ctx context.Context, resourceGroupName string, serverName string, options *ManagementClientResetQueryPerformanceInsightDataOptions) (ManagementClientResetQueryPerformanceInsightDataResponse, error) { req, err := client.resetQueryPerformanceInsightDataCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return ManagementClientResetQueryPerformanceInsightDataResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientResetQueryPerformanceInsightDataResponse{}, err } @@ -160,7 +153,7 @@ func (client *ManagementClient) resetQueryPerformanceInsightDataCreateRequest(ct return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_mysqlmanagementclient_client_test.go b/sdk/resourcemanager/mysql/armmysql/management_client_example_test.go similarity index 52% rename from sdk/resourcemanager/mysql/armmysql/ze_generated_example_mysqlmanagementclient_client_test.go rename to sdk/resourcemanager/mysql/armmysql/management_client_example_test.go index 747f76998a42..09fa2c97507f 100644 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_mysqlmanagementclient_client_test.go +++ b/sdk/resourcemanager/mysql/armmysql/management_client_example_test.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 armmysql_test @@ -16,45 +17,42 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/QueryPerformanceInsightResetData.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/QueryPerformanceInsightResetData.json func ExampleManagementClient_ResetQueryPerformanceInsightData() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmysql.NewManagementClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + clientFactory, err := armmysql.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ResetQueryPerformanceInsightData(ctx, - "testResourceGroupName", - "testServerName", - nil) + res, err := clientFactory.NewManagementClient().ResetQueryPerformanceInsightData(ctx, "testResourceGroupName", "testServerName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.QueryPerformanceInsightResetDataResult = armmysql.QueryPerformanceInsightResetDataResult{ + // Message: to.Ptr("QPI reset data successful"), + // Status: to.Ptr(armmysql.QueryPerformanceInsightResetDataResultStateSucceeded), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/RecommendedActionSessionCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/RecommendedActionSessionCreate.json func ExampleManagementClient_BeginCreateRecommendedActionSession() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmysql.NewManagementClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + clientFactory, err := armmysql.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateRecommendedActionSession(ctx, - "testResourceGroupName", - "testServerName", - "Index", - "someDatabaseName", - nil) + poller, err := clientFactory.NewManagementClient().BeginCreateRecommendedActionSession(ctx, "testResourceGroupName", "testServerName", "Index", "someDatabaseName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_models.go b/sdk/resourcemanager/mysql/armmysql/models.go similarity index 97% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_models.go rename to sdk/resourcemanager/mysql/armmysql/models.go index b95b7d2825fc..aa75b8bfdecf 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_models.go +++ b/sdk/resourcemanager/mysql/armmysql/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 armmysql @@ -13,7 +14,7 @@ import "time" // Advisor - Represents a recommendation action advisor. type Advisor struct { // The properties of a recommendation action advisor. - Properties interface{} `json:"properties,omitempty"` + Properties any `json:"properties,omitempty"` // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty" azure:"ro"` @@ -30,7 +31,7 @@ type AdvisorsClientGetOptions struct { // placeholder for future optional parameters } -// AdvisorsClientListByServerOptions contains the optional parameters for the AdvisorsClient.ListByServer method. +// AdvisorsClientListByServerOptions contains the optional parameters for the AdvisorsClient.NewListByServerPager method. type AdvisorsClientListByServerOptions struct { // placeholder for future optional parameters } @@ -50,13 +51,6 @@ type CheckNameAvailabilityClientExecuteOptions struct { // placeholder for future optional parameters } -// CloudError - An error response from the Batch service. -type CloudError struct { - // Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows - // the OData error response format.) - Error *ErrorResponse `json:"error,omitempty"` -} - // Configuration - Represents a Configuration. type Configuration struct { // The properties of a configuration. @@ -111,7 +105,8 @@ type ConfigurationsClientGetOptions struct { // placeholder for future optional parameters } -// ConfigurationsClientListByServerOptions contains the optional parameters for the ConfigurationsClient.ListByServer method. +// ConfigurationsClientListByServerOptions contains the optional parameters for the ConfigurationsClient.NewListByServerPager +// method. type ConfigurationsClientListByServerOptions struct { // placeholder for future optional parameters } @@ -164,7 +159,7 @@ type DatabasesClientGetOptions struct { // placeholder for future optional parameters } -// DatabasesClientListByServerOptions contains the optional parameters for the DatabasesClient.ListByServer method. +// DatabasesClientListByServerOptions contains the optional parameters for the DatabasesClient.NewListByServerPager method. type DatabasesClientListByServerOptions struct { // placeholder for future optional parameters } @@ -172,7 +167,7 @@ type DatabasesClientListByServerOptions struct { // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty" azure:"ro"` + Info any `json:"info,omitempty" azure:"ro"` // READ-ONLY; The additional info type. Type *string `json:"type,omitempty" azure:"ro"` @@ -245,12 +240,13 @@ type FirewallRulesClientGetOptions struct { // placeholder for future optional parameters } -// FirewallRulesClientListByServerOptions contains the optional parameters for the FirewallRulesClient.ListByServer method. +// FirewallRulesClientListByServerOptions contains the optional parameters for the FirewallRulesClient.NewListByServerPager +// method. type FirewallRulesClientListByServerOptions struct { // placeholder for future optional parameters } -// LocationBasedPerformanceTierClientListOptions contains the optional parameters for the LocationBasedPerformanceTierClient.List +// LocationBasedPerformanceTierClientListOptions contains the optional parameters for the LocationBasedPerformanceTierClient.NewListPager // method. type LocationBasedPerformanceTierClientListOptions struct { // placeholder for future optional parameters @@ -262,7 +258,7 @@ type LocationBasedRecommendedActionSessionsOperationStatusClientGetOptions struc // placeholder for future optional parameters } -// LocationBasedRecommendedActionSessionsResultClientListOptions contains the optional parameters for the LocationBasedRecommendedActionSessionsResultClient.List +// LocationBasedRecommendedActionSessionsResultClientListOptions contains the optional parameters for the LocationBasedRecommendedActionSessionsResultClient.NewListPager // method. type LocationBasedRecommendedActionSessionsResultClientListOptions struct { // placeholder for future optional parameters @@ -307,7 +303,7 @@ type LogFileProperties struct { LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty" azure:"ro"` } -// LogFilesClientListByServerOptions contains the optional parameters for the LogFilesClient.ListByServer method. +// LogFilesClientListByServerOptions contains the optional parameters for the LogFilesClient.NewListByServerPager method. type LogFilesClientListByServerOptions struct { // placeholder for future optional parameters } @@ -358,7 +354,7 @@ type Operation struct { Origin *OperationOrigin `json:"origin,omitempty" azure:"ro"` // READ-ONLY; Additional descriptions for the operation. - Properties map[string]interface{} `json:"properties,omitempty" azure:"ro"` + Properties map[string]any `json:"properties,omitempty" azure:"ro"` } // OperationDisplay - Display metadata associated with the operation. @@ -510,7 +506,7 @@ type PrivateEndpointConnectionsClientGetOptions struct { // placeholder for future optional parameters } -// PrivateEndpointConnectionsClientListByServerOptions contains the optional parameters for the PrivateEndpointConnectionsClient.ListByServer +// PrivateEndpointConnectionsClientListByServerOptions contains the optional parameters for the PrivateEndpointConnectionsClient.NewListByServerPager // method. type PrivateEndpointConnectionsClientListByServerOptions struct { // placeholder for future optional parameters @@ -559,7 +555,7 @@ type PrivateLinkResourcesClientGetOptions struct { // placeholder for future optional parameters } -// PrivateLinkResourcesClientListByServerOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByServer +// PrivateLinkResourcesClientListByServerOptions contains the optional parameters for the PrivateLinkResourcesClient.NewListByServerPager // method. type PrivateLinkResourcesClientListByServerOptions struct { // placeholder for future optional parameters @@ -675,7 +671,7 @@ type QueryTextsClientGetOptions struct { // placeholder for future optional parameters } -// QueryTextsClientListByServerOptions contains the optional parameters for the QueryTextsClient.ListByServer method. +// QueryTextsClientListByServerOptions contains the optional parameters for the QueryTextsClient.NewListByServerPager method. type QueryTextsClientListByServerOptions struct { // placeholder for future optional parameters } @@ -757,7 +753,7 @@ type RecommendedActionsClientGetOptions struct { // placeholder for future optional parameters } -// RecommendedActionsClientListByServerOptions contains the optional parameters for the RecommendedActionsClient.ListByServer +// RecommendedActionsClientListByServerOptions contains the optional parameters for the RecommendedActionsClient.NewListByServerPager // method. type RecommendedActionsClientListByServerOptions struct { // The recommendation action session identifier. @@ -805,7 +801,7 @@ type RecoverableServersClientGetOptions struct { // placeholder for future optional parameters } -// ReplicasClientListByServerOptions contains the optional parameters for the ReplicasClient.ListByServer method. +// ReplicasClientListByServerOptions contains the optional parameters for the ReplicasClient.NewListByServerPager method. type ReplicasClientListByServerOptions struct { // placeholder for future optional parameters } @@ -907,7 +903,8 @@ type Server struct { // ServerAdministratorProperties - The properties of an server Administrator. type ServerAdministratorProperties struct { - // REQUIRED; The type of administrator. + // CONSTANT; The type of administrator. + // Field has constant value "ActiveDirectory", any specified value is ignored. AdministratorType *string `json:"administratorType,omitempty"` // REQUIRED; The server administrator login account name. @@ -960,12 +957,13 @@ type ServerAdministratorsClientGetOptions struct { // placeholder for future optional parameters } -// ServerAdministratorsClientListOptions contains the optional parameters for the ServerAdministratorsClient.List method. +// ServerAdministratorsClientListOptions contains the optional parameters for the ServerAdministratorsClient.NewListPager +// method. type ServerAdministratorsClientListOptions struct { // placeholder for future optional parameters } -// ServerBasedPerformanceTierClientListOptions contains the optional parameters for the ServerBasedPerformanceTierClient.List +// ServerBasedPerformanceTierClientListOptions contains the optional parameters for the ServerBasedPerformanceTierClient.NewListPager // method. type ServerBasedPerformanceTierClientListOptions struct { // placeholder for future optional parameters @@ -1046,7 +1044,7 @@ type ServerKeysClientGetOptions struct { // placeholder for future optional parameters } -// ServerKeysClientListOptions contains the optional parameters for the ServerKeysClient.List method. +// ServerKeysClientListOptions contains the optional parameters for the ServerKeysClient.NewListPager method. type ServerKeysClientListOptions struct { // placeholder for future optional parameters } @@ -1371,7 +1369,7 @@ type ServerSecurityAlertPoliciesClientGetOptions struct { // placeholder for future optional parameters } -// ServerSecurityAlertPoliciesClientListByServerOptions contains the optional parameters for the ServerSecurityAlertPoliciesClient.ListByServer +// ServerSecurityAlertPoliciesClientListByServerOptions contains the optional parameters for the ServerSecurityAlertPoliciesClient.NewListByServerPager // method. type ServerSecurityAlertPoliciesClientListByServerOptions struct { // placeholder for future optional parameters @@ -1499,12 +1497,13 @@ type ServersClientGetOptions struct { // placeholder for future optional parameters } -// ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.ListByResourceGroup method. +// ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.NewListByResourceGroupPager +// method. type ServersClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// ServersClientListOptions contains the optional parameters for the ServersClient.List method. +// ServersClientListOptions contains the optional parameters for the ServersClient.NewListPager method. type ServersClientListOptions struct { // placeholder for future optional parameters } @@ -1535,7 +1534,7 @@ type TopQueryStatisticsClientGetOptions struct { // placeholder for future optional parameters } -// TopQueryStatisticsClientListByServerOptions contains the optional parameters for the TopQueryStatisticsClient.ListByServer +// TopQueryStatisticsClientListByServerOptions contains the optional parameters for the TopQueryStatisticsClient.NewListByServerPager // method. type TopQueryStatisticsClientListByServerOptions struct { // placeholder for future optional parameters @@ -1651,7 +1650,7 @@ type VirtualNetworkRulesClientGetOptions struct { // placeholder for future optional parameters } -// VirtualNetworkRulesClientListByServerOptions contains the optional parameters for the VirtualNetworkRulesClient.ListByServer +// VirtualNetworkRulesClientListByServerOptions contains the optional parameters for the VirtualNetworkRulesClient.NewListByServerPager // method. type VirtualNetworkRulesClientListByServerOptions struct { // placeholder for future optional parameters @@ -1707,7 +1706,8 @@ type WaitStatisticsClientGetOptions struct { // placeholder for future optional parameters } -// WaitStatisticsClientListByServerOptions contains the optional parameters for the WaitStatisticsClient.ListByServer method. +// WaitStatisticsClientListByServerOptions contains the optional parameters for the WaitStatisticsClient.NewListByServerPager +// method. type WaitStatisticsClientListByServerOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/mysql/armmysql/models_serde.go b/sdk/resourcemanager/mysql/armmysql/models_serde.go new file mode 100644 index 000000000000..b022ef586459 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/models_serde.go @@ -0,0 +1,3378 @@ +//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 armmysql + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Advisor. +func (a Advisor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", &a.Properties) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Advisor. +func (a *Advisor) 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 "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + 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 AdvisorsResultList. +func (a AdvisorsResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AdvisorsResultList. +func (a *AdvisorsResultList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Configuration. +func (c Configuration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Configuration. +func (c *Configuration) 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 "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + 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 ConfigurationListResult. +func (c ConfigurationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationListResult. +func (c *ConfigurationListResult) 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 "value": + err = unpopulate(val, "Value", &c.Value) + 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 ConfigurationProperties. +func (c ConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allowedValues", c.AllowedValues) + populate(objectMap, "dataType", c.DataType) + populate(objectMap, "defaultValue", c.DefaultValue) + populate(objectMap, "description", c.Description) + populate(objectMap, "source", c.Source) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationProperties. +func (c *ConfigurationProperties) 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 "allowedValues": + err = unpopulate(val, "AllowedValues", &c.AllowedValues) + delete(rawMsg, key) + case "dataType": + err = unpopulate(val, "DataType", &c.DataType) + delete(rawMsg, key) + case "defaultValue": + err = unpopulate(val, "DefaultValue", &c.DefaultValue) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &c.Description) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &c.Source) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + 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 Database. +func (d Database) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Database. +func (d *Database) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DatabaseListResult. +func (d DatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DatabaseListResult. +func (d *DatabaseListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DatabaseProperties. +func (d DatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "charset", d.Charset) + populate(objectMap, "collation", d.Collation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DatabaseProperties. +func (d *DatabaseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "charset": + err = unpopulate(val, "Charset", &d.Charset) + delete(rawMsg, key) + case "collation": + err = unpopulate(val, "Collation", &d.Collation) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "info", &e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FirewallRule. +func (f FirewallRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + populate(objectMap, "name", f.Name) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FirewallRule. +func (f *FirewallRule) 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", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FirewallRuleListResult. +func (f FirewallRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FirewallRuleListResult. +func (f *FirewallRuleListResult) 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", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &f.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FirewallRuleProperties. +func (f FirewallRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "endIpAddress", f.EndIPAddress) + populate(objectMap, "startIpAddress", f.StartIPAddress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FirewallRuleProperties. +func (f *FirewallRuleProperties) 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", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endIpAddress": + err = unpopulate(val, "EndIPAddress", &f.EndIPAddress) + delete(rawMsg, key) + case "startIpAddress": + err = unpopulate(val, "StartIPAddress", &f.StartIPAddress) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LogFile. +func (l LogFile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", l.ID) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogFile. +func (l *LogFile) 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 "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 LogFileListResult. +func (l LogFileListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogFileListResult. +func (l *LogFileListResult) 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 "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 LogFileProperties. +func (l LogFileProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdTime", l.CreatedTime) + populateTimeRFC3339(objectMap, "lastModifiedTime", l.LastModifiedTime) + populate(objectMap, "sizeInKB", l.SizeInKB) + populate(objectMap, "type", l.Type) + populate(objectMap, "url", l.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogFileProperties. +func (l *LogFileProperties) 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 "createdTime": + err = unpopulateTimeRFC3339(val, "CreatedTime", &l.CreatedTime) + delete(rawMsg, key) + case "lastModifiedTime": + err = unpopulateTimeRFC3339(val, "LastModifiedTime", &l.LastModifiedTime) + delete(rawMsg, key) + case "sizeInKB": + err = unpopulate(val, "SizeInKB", &l.SizeInKB) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &l.Type) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &l.URL) + 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 NameAvailability. +func (n NameAvailability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", n.Message) + populate(objectMap, "nameAvailable", n.NameAvailable) + populate(objectMap, "reason", n.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NameAvailability. +func (n *NameAvailability) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &n.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &n.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &n.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NameAvailabilityRequest. +func (n NameAvailabilityRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", n.Name) + populate(objectMap, "type", n.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NameAvailabilityRequest. +func (n *NameAvailabilityRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &n.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + populate(objectMap, "properties", o.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "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]any) + 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 "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 PerformanceTierListResult. +func (p PerformanceTierListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PerformanceTierListResult. +func (p *PerformanceTierListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PerformanceTierProperties. +func (p PerformanceTierProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "maxBackupRetentionDays", p.MaxBackupRetentionDays) + populate(objectMap, "maxLargeStorageMB", p.MaxLargeStorageMB) + populate(objectMap, "maxStorageMB", p.MaxStorageMB) + populate(objectMap, "minBackupRetentionDays", p.MinBackupRetentionDays) + populate(objectMap, "minLargeStorageMB", p.MinLargeStorageMB) + populate(objectMap, "minStorageMB", p.MinStorageMB) + populate(objectMap, "serviceLevelObjectives", p.ServiceLevelObjectives) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PerformanceTierProperties. +func (p *PerformanceTierProperties) 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 "maxBackupRetentionDays": + err = unpopulate(val, "MaxBackupRetentionDays", &p.MaxBackupRetentionDays) + delete(rawMsg, key) + case "maxLargeStorageMB": + err = unpopulate(val, "MaxLargeStorageMB", &p.MaxLargeStorageMB) + delete(rawMsg, key) + case "maxStorageMB": + err = unpopulate(val, "MaxStorageMB", &p.MaxStorageMB) + delete(rawMsg, key) + case "minBackupRetentionDays": + err = unpopulate(val, "MinBackupRetentionDays", &p.MinBackupRetentionDays) + delete(rawMsg, key) + case "minLargeStorageMB": + err = unpopulate(val, "MinLargeStorageMB", &p.MinLargeStorageMB) + delete(rawMsg, key) + case "minStorageMB": + err = unpopulate(val, "MinStorageMB", &p.MinStorageMB) + delete(rawMsg, key) + case "serviceLevelObjectives": + err = unpopulate(val, "ServiceLevelObjectives", &p.ServiceLevelObjectives) + 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 PerformanceTierServiceLevelObjectives. +func (p PerformanceTierServiceLevelObjectives) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "edition", p.Edition) + populate(objectMap, "hardwareGeneration", p.HardwareGeneration) + populate(objectMap, "id", p.ID) + populate(objectMap, "maxBackupRetentionDays", p.MaxBackupRetentionDays) + populate(objectMap, "maxStorageMB", p.MaxStorageMB) + populate(objectMap, "minBackupRetentionDays", p.MinBackupRetentionDays) + populate(objectMap, "minStorageMB", p.MinStorageMB) + populate(objectMap, "vCore", p.VCore) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PerformanceTierServiceLevelObjectives. +func (p *PerformanceTierServiceLevelObjectives) 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 "edition": + err = unpopulate(val, "Edition", &p.Edition) + delete(rawMsg, key) + case "hardwareGeneration": + err = unpopulate(val, "HardwareGeneration", &p.HardwareGeneration) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "maxBackupRetentionDays": + err = unpopulate(val, "MaxBackupRetentionDays", &p.MaxBackupRetentionDays) + delete(rawMsg, key) + case "maxStorageMB": + err = unpopulate(val, "MaxStorageMB", &p.MaxStorageMB) + delete(rawMsg, key) + case "minBackupRetentionDays": + err = unpopulate(val, "MinBackupRetentionDays", &p.MinBackupRetentionDays) + delete(rawMsg, key) + case "minStorageMB": + err = unpopulate(val, "MinStorageMB", &p.MinStorageMB) + delete(rawMsg, key) + case "vCore": + err = unpopulate(val, "VCore", &p.VCore) + 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 PrivateEndpointConnection. +func (p PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnection. +func (p *PrivateEndpointConnection) 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 "properties": + err = unpopulate(val, "Properties", &p.Properties) + 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 PrivateEndpointConnectionListResult. +func (p PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnectionListResult. +func (p *PrivateEndpointConnectionListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionProperties. +func (p PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "privateEndpoint", p.PrivateEndpoint) + populate(objectMap, "privateLinkServiceConnectionState", p.PrivateLinkServiceConnectionState) + populate(objectMap, "provisioningState", p.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnectionProperties. +func (p *PrivateEndpointConnectionProperties) 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 "privateEndpoint": + err = unpopulate(val, "PrivateEndpoint", &p.PrivateEndpoint) + delete(rawMsg, key) + case "privateLinkServiceConnectionState": + err = unpopulate(val, "PrivateLinkServiceConnectionState", &p.PrivateLinkServiceConnectionState) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + 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 PrivateEndpointProperty. +func (p PrivateEndpointProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointProperty. +func (p *PrivateEndpointProperty) 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) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResource. +func (p PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResource. +func (p *PrivateLinkResource) 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 "properties": + err = unpopulate(val, "Properties", &p.Properties) + 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 PrivateLinkResourceListResult. +func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceListResult. +func (p *PrivateLinkResourceListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. +func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "groupId", p.GroupID) + populate(objectMap, "requiredMembers", p.RequiredMembers) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceProperties. +func (p *PrivateLinkResourceProperties) 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 "groupId": + err = unpopulate(val, "GroupID", &p.GroupID) + delete(rawMsg, key) + case "requiredMembers": + err = unpopulate(val, "RequiredMembers", &p.RequiredMembers) + 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 PrivateLinkServiceConnectionStateProperty. +func (p PrivateLinkServiceConnectionStateProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionsRequired", p.ActionsRequired) + populate(objectMap, "description", p.Description) + populate(objectMap, "status", p.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkServiceConnectionStateProperty. +func (p *PrivateLinkServiceConnectionStateProperty) 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 "actionsRequired": + err = unpopulate(val, "ActionsRequired", &p.ActionsRequired) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + 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 ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 QueryPerformanceInsightResetDataResult. +func (q QueryPerformanceInsightResetDataResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", q.Message) + populate(objectMap, "status", q.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryPerformanceInsightResetDataResult. +func (q *QueryPerformanceInsightResetDataResult) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &q.Message) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &q.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryStatistic. +func (q QueryStatistic) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", q.ID) + populate(objectMap, "name", q.Name) + populate(objectMap, "properties", q.Properties) + populate(objectMap, "type", q.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryStatistic. +func (q *QueryStatistic) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &q.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &q.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &q.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &q.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryStatisticProperties. +func (q QueryStatisticProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "aggregationFunction", q.AggregationFunction) + populate(objectMap, "databaseNames", q.DatabaseNames) + populateTimeRFC3339(objectMap, "endTime", q.EndTime) + populate(objectMap, "metricDisplayName", q.MetricDisplayName) + populate(objectMap, "metricName", q.MetricName) + populate(objectMap, "metricValue", q.MetricValue) + populate(objectMap, "metricValueUnit", q.MetricValueUnit) + populate(objectMap, "queryExecutionCount", q.QueryExecutionCount) + populate(objectMap, "queryId", q.QueryID) + populateTimeRFC3339(objectMap, "startTime", q.StartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryStatisticProperties. +func (q *QueryStatisticProperties) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "aggregationFunction": + err = unpopulate(val, "AggregationFunction", &q.AggregationFunction) + delete(rawMsg, key) + case "databaseNames": + err = unpopulate(val, "DatabaseNames", &q.DatabaseNames) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &q.EndTime) + delete(rawMsg, key) + case "metricDisplayName": + err = unpopulate(val, "MetricDisplayName", &q.MetricDisplayName) + delete(rawMsg, key) + case "metricName": + err = unpopulate(val, "MetricName", &q.MetricName) + delete(rawMsg, key) + case "metricValue": + err = unpopulate(val, "MetricValue", &q.MetricValue) + delete(rawMsg, key) + case "metricValueUnit": + err = unpopulate(val, "MetricValueUnit", &q.MetricValueUnit) + delete(rawMsg, key) + case "queryExecutionCount": + err = unpopulate(val, "QueryExecutionCount", &q.QueryExecutionCount) + delete(rawMsg, key) + case "queryId": + err = unpopulate(val, "QueryID", &q.QueryID) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &q.StartTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryText. +func (q QueryText) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", q.ID) + populate(objectMap, "name", q.Name) + populate(objectMap, "properties", q.Properties) + populate(objectMap, "type", q.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryText. +func (q *QueryText) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &q.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &q.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &q.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &q.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryTextProperties. +func (q QueryTextProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "queryId", q.QueryID) + populate(objectMap, "queryText", q.QueryText) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryTextProperties. +func (q *QueryTextProperties) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "queryId": + err = unpopulate(val, "QueryID", &q.QueryID) + delete(rawMsg, key) + case "queryText": + err = unpopulate(val, "QueryText", &q.QueryText) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryTextsResultList. +func (q QueryTextsResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", q.NextLink) + populate(objectMap, "value", q.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryTextsResultList. +func (q *QueryTextsResultList) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &q.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &q.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecommendationAction. +func (r RecommendationAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecommendationAction. +func (r *RecommendationAction) 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 "properties": + err = unpopulate(val, "Properties", &r.Properties) + 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 RecommendationActionProperties. +func (r RecommendationActionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionId", r.ActionID) + populate(objectMap, "advisorName", r.AdvisorName) + populateTimeRFC3339(objectMap, "createdTime", r.CreatedTime) + populate(objectMap, "details", r.Details) + populateTimeRFC3339(objectMap, "expirationTime", r.ExpirationTime) + populate(objectMap, "reason", r.Reason) + populate(objectMap, "recommendationType", r.RecommendationType) + populate(objectMap, "sessionId", r.SessionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecommendationActionProperties. +func (r *RecommendationActionProperties) 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 "actionId": + err = unpopulate(val, "ActionID", &r.ActionID) + delete(rawMsg, key) + case "advisorName": + err = unpopulate(val, "AdvisorName", &r.AdvisorName) + delete(rawMsg, key) + case "createdTime": + err = unpopulateTimeRFC3339(val, "CreatedTime", &r.CreatedTime) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &r.Details) + delete(rawMsg, key) + case "expirationTime": + err = unpopulateTimeRFC3339(val, "ExpirationTime", &r.ExpirationTime) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &r.Reason) + delete(rawMsg, key) + case "recommendationType": + err = unpopulate(val, "RecommendationType", &r.RecommendationType) + delete(rawMsg, key) + case "sessionId": + err = unpopulate(val, "SessionID", &r.SessionID) + 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 RecommendationActionsResultList. +func (r RecommendationActionsResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecommendationActionsResultList. +func (r *RecommendationActionsResultList) 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 "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + 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 RecommendedActionSessionsOperationStatus. +func (r RecommendedActionSessionsOperationStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", r.Name) + populateTimeRFC3339(objectMap, "startTime", r.StartTime) + populate(objectMap, "status", r.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecommendedActionSessionsOperationStatus. +func (r *RecommendedActionSessionsOperationStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &r.StartTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + 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 RecoverableServerProperties. +func (r RecoverableServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "edition", r.Edition) + populate(objectMap, "hardwareGeneration", r.HardwareGeneration) + populate(objectMap, "lastAvailableBackupDateTime", r.LastAvailableBackupDateTime) + populate(objectMap, "serviceLevelObjective", r.ServiceLevelObjective) + populate(objectMap, "vCore", r.VCore) + populate(objectMap, "version", r.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecoverableServerProperties. +func (r *RecoverableServerProperties) 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 "edition": + err = unpopulate(val, "Edition", &r.Edition) + delete(rawMsg, key) + case "hardwareGeneration": + err = unpopulate(val, "HardwareGeneration", &r.HardwareGeneration) + delete(rawMsg, key) + case "lastAvailableBackupDateTime": + err = unpopulate(val, "LastAvailableBackupDateTime", &r.LastAvailableBackupDateTime) + delete(rawMsg, key) + case "serviceLevelObjective": + err = unpopulate(val, "ServiceLevelObjective", &r.ServiceLevelObjective) + delete(rawMsg, key) + case "vCore": + err = unpopulate(val, "VCore", &r.VCore) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &r.Version) + 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 RecoverableServerResource. +func (r RecoverableServerResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecoverableServerResource. +func (r *RecoverableServerResource) 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 "properties": + err = unpopulate(val, "Properties", &r.Properties) + 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 Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 ResourceIdentity. +func (r ResourceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", r.PrincipalID) + populate(objectMap, "tenantId", r.TenantID) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceIdentity. +func (r *ResourceIdentity) 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 "principalId": + err = unpopulate(val, "PrincipalID", &r.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + 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 SKU. +func (s SKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacity", s.Capacity) + populate(objectMap, "family", s.Family) + populate(objectMap, "name", s.Name) + populate(objectMap, "size", s.Size) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKU. +func (s *SKU) 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 "capacity": + err = unpopulate(val, "Capacity", &s.Capacity) + delete(rawMsg, key) + case "family": + err = unpopulate(val, "Family", &s.Family) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "size": + err = unpopulate(val, "Size", &s.Size) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &s.Tier) + 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 SecurityAlertPolicyProperties. +func (s SecurityAlertPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "disabledAlerts", s.DisabledAlerts) + populate(objectMap, "emailAccountAdmins", s.EmailAccountAdmins) + populate(objectMap, "emailAddresses", s.EmailAddresses) + populate(objectMap, "retentionDays", s.RetentionDays) + populate(objectMap, "state", s.State) + populate(objectMap, "storageAccountAccessKey", s.StorageAccountAccessKey) + populate(objectMap, "storageEndpoint", s.StorageEndpoint) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecurityAlertPolicyProperties. +func (s *SecurityAlertPolicyProperties) 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 "disabledAlerts": + err = unpopulate(val, "DisabledAlerts", &s.DisabledAlerts) + delete(rawMsg, key) + case "emailAccountAdmins": + err = unpopulate(val, "EmailAccountAdmins", &s.EmailAccountAdmins) + delete(rawMsg, key) + case "emailAddresses": + err = unpopulate(val, "EmailAddresses", &s.EmailAddresses) + delete(rawMsg, key) + case "retentionDays": + err = unpopulate(val, "RetentionDays", &s.RetentionDays) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &s.State) + delete(rawMsg, key) + case "storageAccountAccessKey": + err = unpopulate(val, "StorageAccountAccessKey", &s.StorageAccountAccessKey) + delete(rawMsg, key) + case "storageEndpoint": + err = unpopulate(val, "StorageEndpoint", &s.StorageEndpoint) + 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 Server. +func (s Server) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "location", s.Location) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Server. +func (s *Server) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerAdministratorProperties. +func (s ServerAdministratorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["administratorType"] = "ActiveDirectory" + populate(objectMap, "login", s.Login) + populate(objectMap, "sid", s.Sid) + populate(objectMap, "tenantId", s.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerAdministratorProperties. +func (s *ServerAdministratorProperties) 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 "administratorType": + err = unpopulate(val, "AdministratorType", &s.AdministratorType) + delete(rawMsg, key) + case "login": + err = unpopulate(val, "Login", &s.Login) + delete(rawMsg, key) + case "sid": + err = unpopulate(val, "Sid", &s.Sid) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &s.TenantID) + 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 ServerAdministratorResource. +func (s ServerAdministratorResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerAdministratorResource. +func (s *ServerAdministratorResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerAdministratorResourceListResult. +func (s ServerAdministratorResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerAdministratorResourceListResult. +func (s *ServerAdministratorResourceListResult) 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 "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 ServerForCreate. +func (s ServerForCreate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "location", s.Location) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerForCreate. +func (s *ServerForCreate) 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 "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "properties": + s.Properties, err = unmarshalServerPropertiesForCreateClassification(val) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + 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 ServerKey. +func (s ServerKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "kind", s.Kind) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerKey. +func (s *ServerKey) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &s.Kind) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerKeyListResult. +func (s ServerKeyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerKeyListResult. +func (s *ServerKeyListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerKeyProperties. +func (s ServerKeyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "creationDate", s.CreationDate) + populate(objectMap, "serverKeyType", s.ServerKeyType) + populate(objectMap, "uri", s.URI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerKeyProperties. +func (s *ServerKeyProperties) 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 "creationDate": + err = unpopulateTimeRFC3339(val, "CreationDate", &s.CreationDate) + delete(rawMsg, key) + case "serverKeyType": + err = unpopulate(val, "ServerKeyType", &s.ServerKeyType) + delete(rawMsg, key) + case "uri": + err = unpopulate(val, "URI", &s.URI) + 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 ServerListResult. +func (s ServerListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerListResult. +func (s *ServerListResult) 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 "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 ServerPrivateEndpointConnection. +func (s ServerPrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerPrivateEndpointConnection. +func (s *ServerPrivateEndpointConnection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + 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 ServerPrivateEndpointConnectionProperties. +func (s ServerPrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "privateEndpoint", s.PrivateEndpoint) + populate(objectMap, "privateLinkServiceConnectionState", s.PrivateLinkServiceConnectionState) + populate(objectMap, "provisioningState", s.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerPrivateEndpointConnectionProperties. +func (s *ServerPrivateEndpointConnectionProperties) 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 "privateEndpoint": + err = unpopulate(val, "PrivateEndpoint", &s.PrivateEndpoint) + delete(rawMsg, key) + case "privateLinkServiceConnectionState": + err = unpopulate(val, "PrivateLinkServiceConnectionState", &s.PrivateLinkServiceConnectionState) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + 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 ServerPrivateLinkServiceConnectionStateProperty. +func (s ServerPrivateLinkServiceConnectionStateProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionsRequired", s.ActionsRequired) + populate(objectMap, "description", s.Description) + populate(objectMap, "status", s.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerPrivateLinkServiceConnectionStateProperty. +func (s *ServerPrivateLinkServiceConnectionStateProperty) 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 "actionsRequired": + err = unpopulate(val, "ActionsRequired", &s.ActionsRequired) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &s.Description) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + 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 ServerProperties. +func (s ServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "administratorLogin", s.AdministratorLogin) + populate(objectMap, "byokEnforcement", s.ByokEnforcement) + populateTimeRFC3339(objectMap, "earliestRestoreDate", s.EarliestRestoreDate) + populate(objectMap, "fullyQualifiedDomainName", s.FullyQualifiedDomainName) + populate(objectMap, "infrastructureEncryption", s.InfrastructureEncryption) + populate(objectMap, "masterServerId", s.MasterServerID) + populate(objectMap, "minimalTlsVersion", s.MinimalTLSVersion) + populate(objectMap, "privateEndpointConnections", s.PrivateEndpointConnections) + populate(objectMap, "publicNetworkAccess", s.PublicNetworkAccess) + populate(objectMap, "replicaCapacity", s.ReplicaCapacity) + populate(objectMap, "replicationRole", s.ReplicationRole) + populate(objectMap, "sslEnforcement", s.SSLEnforcement) + populate(objectMap, "storageProfile", s.StorageProfile) + populate(objectMap, "userVisibleState", s.UserVisibleState) + populate(objectMap, "version", s.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerProperties. +func (s *ServerProperties) 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 "administratorLogin": + err = unpopulate(val, "AdministratorLogin", &s.AdministratorLogin) + delete(rawMsg, key) + case "byokEnforcement": + err = unpopulate(val, "ByokEnforcement", &s.ByokEnforcement) + delete(rawMsg, key) + case "earliestRestoreDate": + err = unpopulateTimeRFC3339(val, "EarliestRestoreDate", &s.EarliestRestoreDate) + delete(rawMsg, key) + case "fullyQualifiedDomainName": + err = unpopulate(val, "FullyQualifiedDomainName", &s.FullyQualifiedDomainName) + delete(rawMsg, key) + case "infrastructureEncryption": + err = unpopulate(val, "InfrastructureEncryption", &s.InfrastructureEncryption) + delete(rawMsg, key) + case "masterServerId": + err = unpopulate(val, "MasterServerID", &s.MasterServerID) + delete(rawMsg, key) + case "minimalTlsVersion": + err = unpopulate(val, "MinimalTLSVersion", &s.MinimalTLSVersion) + delete(rawMsg, key) + case "privateEndpointConnections": + err = unpopulate(val, "PrivateEndpointConnections", &s.PrivateEndpointConnections) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &s.PublicNetworkAccess) + delete(rawMsg, key) + case "replicaCapacity": + err = unpopulate(val, "ReplicaCapacity", &s.ReplicaCapacity) + delete(rawMsg, key) + case "replicationRole": + err = unpopulate(val, "ReplicationRole", &s.ReplicationRole) + delete(rawMsg, key) + case "sslEnforcement": + err = unpopulate(val, "SSLEnforcement", &s.SSLEnforcement) + delete(rawMsg, key) + case "storageProfile": + err = unpopulate(val, "StorageProfile", &s.StorageProfile) + delete(rawMsg, key) + case "userVisibleState": + err = unpopulate(val, "UserVisibleState", &s.UserVisibleState) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &s.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerPropertiesForCreate. +func (s ServerPropertiesForCreate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["createMode"] = s.CreateMode + populate(objectMap, "infrastructureEncryption", s.InfrastructureEncryption) + populate(objectMap, "minimalTlsVersion", s.MinimalTLSVersion) + populate(objectMap, "publicNetworkAccess", s.PublicNetworkAccess) + populate(objectMap, "sslEnforcement", s.SSLEnforcement) + populate(objectMap, "storageProfile", s.StorageProfile) + populate(objectMap, "version", s.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerPropertiesForCreate. +func (s *ServerPropertiesForCreate) 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 "createMode": + err = unpopulate(val, "CreateMode", &s.CreateMode) + delete(rawMsg, key) + case "infrastructureEncryption": + err = unpopulate(val, "InfrastructureEncryption", &s.InfrastructureEncryption) + delete(rawMsg, key) + case "minimalTlsVersion": + err = unpopulate(val, "MinimalTLSVersion", &s.MinimalTLSVersion) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &s.PublicNetworkAccess) + delete(rawMsg, key) + case "sslEnforcement": + err = unpopulate(val, "SSLEnforcement", &s.SSLEnforcement) + delete(rawMsg, key) + case "storageProfile": + err = unpopulate(val, "StorageProfile", &s.StorageProfile) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &s.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerPropertiesForDefaultCreate. +func (s ServerPropertiesForDefaultCreate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "administratorLogin", s.AdministratorLogin) + populate(objectMap, "administratorLoginPassword", s.AdministratorLoginPassword) + objectMap["createMode"] = CreateModeDefault + populate(objectMap, "infrastructureEncryption", s.InfrastructureEncryption) + populate(objectMap, "minimalTlsVersion", s.MinimalTLSVersion) + populate(objectMap, "publicNetworkAccess", s.PublicNetworkAccess) + populate(objectMap, "sslEnforcement", s.SSLEnforcement) + populate(objectMap, "storageProfile", s.StorageProfile) + populate(objectMap, "version", s.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerPropertiesForDefaultCreate. +func (s *ServerPropertiesForDefaultCreate) 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 "administratorLogin": + err = unpopulate(val, "AdministratorLogin", &s.AdministratorLogin) + delete(rawMsg, key) + case "administratorLoginPassword": + err = unpopulate(val, "AdministratorLoginPassword", &s.AdministratorLoginPassword) + delete(rawMsg, key) + case "createMode": + err = unpopulate(val, "CreateMode", &s.CreateMode) + delete(rawMsg, key) + case "infrastructureEncryption": + err = unpopulate(val, "InfrastructureEncryption", &s.InfrastructureEncryption) + delete(rawMsg, key) + case "minimalTlsVersion": + err = unpopulate(val, "MinimalTLSVersion", &s.MinimalTLSVersion) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &s.PublicNetworkAccess) + delete(rawMsg, key) + case "sslEnforcement": + err = unpopulate(val, "SSLEnforcement", &s.SSLEnforcement) + delete(rawMsg, key) + case "storageProfile": + err = unpopulate(val, "StorageProfile", &s.StorageProfile) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &s.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerPropertiesForGeoRestore. +func (s ServerPropertiesForGeoRestore) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["createMode"] = CreateModeGeoRestore + populate(objectMap, "infrastructureEncryption", s.InfrastructureEncryption) + populate(objectMap, "minimalTlsVersion", s.MinimalTLSVersion) + populate(objectMap, "publicNetworkAccess", s.PublicNetworkAccess) + populate(objectMap, "sslEnforcement", s.SSLEnforcement) + populate(objectMap, "sourceServerId", s.SourceServerID) + populate(objectMap, "storageProfile", s.StorageProfile) + populate(objectMap, "version", s.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerPropertiesForGeoRestore. +func (s *ServerPropertiesForGeoRestore) 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 "createMode": + err = unpopulate(val, "CreateMode", &s.CreateMode) + delete(rawMsg, key) + case "infrastructureEncryption": + err = unpopulate(val, "InfrastructureEncryption", &s.InfrastructureEncryption) + delete(rawMsg, key) + case "minimalTlsVersion": + err = unpopulate(val, "MinimalTLSVersion", &s.MinimalTLSVersion) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &s.PublicNetworkAccess) + delete(rawMsg, key) + case "sslEnforcement": + err = unpopulate(val, "SSLEnforcement", &s.SSLEnforcement) + delete(rawMsg, key) + case "sourceServerId": + err = unpopulate(val, "SourceServerID", &s.SourceServerID) + delete(rawMsg, key) + case "storageProfile": + err = unpopulate(val, "StorageProfile", &s.StorageProfile) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &s.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerPropertiesForReplica. +func (s ServerPropertiesForReplica) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["createMode"] = CreateModeReplica + populate(objectMap, "infrastructureEncryption", s.InfrastructureEncryption) + populate(objectMap, "minimalTlsVersion", s.MinimalTLSVersion) + populate(objectMap, "publicNetworkAccess", s.PublicNetworkAccess) + populate(objectMap, "sslEnforcement", s.SSLEnforcement) + populate(objectMap, "sourceServerId", s.SourceServerID) + populate(objectMap, "storageProfile", s.StorageProfile) + populate(objectMap, "version", s.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerPropertiesForReplica. +func (s *ServerPropertiesForReplica) 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 "createMode": + err = unpopulate(val, "CreateMode", &s.CreateMode) + delete(rawMsg, key) + case "infrastructureEncryption": + err = unpopulate(val, "InfrastructureEncryption", &s.InfrastructureEncryption) + delete(rawMsg, key) + case "minimalTlsVersion": + err = unpopulate(val, "MinimalTLSVersion", &s.MinimalTLSVersion) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &s.PublicNetworkAccess) + delete(rawMsg, key) + case "sslEnforcement": + err = unpopulate(val, "SSLEnforcement", &s.SSLEnforcement) + delete(rawMsg, key) + case "sourceServerId": + err = unpopulate(val, "SourceServerID", &s.SourceServerID) + delete(rawMsg, key) + case "storageProfile": + err = unpopulate(val, "StorageProfile", &s.StorageProfile) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &s.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerPropertiesForRestore. +func (s ServerPropertiesForRestore) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["createMode"] = CreateModePointInTimeRestore + populate(objectMap, "infrastructureEncryption", s.InfrastructureEncryption) + populate(objectMap, "minimalTlsVersion", s.MinimalTLSVersion) + populate(objectMap, "publicNetworkAccess", s.PublicNetworkAccess) + populateTimeRFC3339(objectMap, "restorePointInTime", s.RestorePointInTime) + populate(objectMap, "sslEnforcement", s.SSLEnforcement) + populate(objectMap, "sourceServerId", s.SourceServerID) + populate(objectMap, "storageProfile", s.StorageProfile) + populate(objectMap, "version", s.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerPropertiesForRestore. +func (s *ServerPropertiesForRestore) 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 "createMode": + err = unpopulate(val, "CreateMode", &s.CreateMode) + delete(rawMsg, key) + case "infrastructureEncryption": + err = unpopulate(val, "InfrastructureEncryption", &s.InfrastructureEncryption) + delete(rawMsg, key) + case "minimalTlsVersion": + err = unpopulate(val, "MinimalTLSVersion", &s.MinimalTLSVersion) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &s.PublicNetworkAccess) + delete(rawMsg, key) + case "restorePointInTime": + err = unpopulateTimeRFC3339(val, "RestorePointInTime", &s.RestorePointInTime) + delete(rawMsg, key) + case "sslEnforcement": + err = unpopulate(val, "SSLEnforcement", &s.SSLEnforcement) + delete(rawMsg, key) + case "sourceServerId": + err = unpopulate(val, "SourceServerID", &s.SourceServerID) + delete(rawMsg, key) + case "storageProfile": + err = unpopulate(val, "StorageProfile", &s.StorageProfile) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &s.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerSecurityAlertPolicy. +func (s ServerSecurityAlertPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerSecurityAlertPolicy. +func (s *ServerSecurityAlertPolicy) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerSecurityAlertPolicyListResult. +func (s ServerSecurityAlertPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerSecurityAlertPolicyListResult. +func (s *ServerSecurityAlertPolicyListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerUpdateParameters. +func (s ServerUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerUpdateParameters. +func (s *ServerUpdateParameters) 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 "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + 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 ServerUpdateParametersProperties. +func (s ServerUpdateParametersProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "administratorLoginPassword", s.AdministratorLoginPassword) + populate(objectMap, "minimalTlsVersion", s.MinimalTLSVersion) + populate(objectMap, "publicNetworkAccess", s.PublicNetworkAccess) + populate(objectMap, "replicationRole", s.ReplicationRole) + populate(objectMap, "sslEnforcement", s.SSLEnforcement) + populate(objectMap, "storageProfile", s.StorageProfile) + populate(objectMap, "version", s.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerUpdateParametersProperties. +func (s *ServerUpdateParametersProperties) 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 "administratorLoginPassword": + err = unpopulate(val, "AdministratorLoginPassword", &s.AdministratorLoginPassword) + delete(rawMsg, key) + case "minimalTlsVersion": + err = unpopulate(val, "MinimalTLSVersion", &s.MinimalTLSVersion) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &s.PublicNetworkAccess) + delete(rawMsg, key) + case "replicationRole": + err = unpopulate(val, "ReplicationRole", &s.ReplicationRole) + delete(rawMsg, key) + case "sslEnforcement": + err = unpopulate(val, "SSLEnforcement", &s.SSLEnforcement) + delete(rawMsg, key) + case "storageProfile": + err = unpopulate(val, "StorageProfile", &s.StorageProfile) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &s.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerUpgradeParameters. +func (s ServerUpgradeParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerUpgradeParameters. +func (s *ServerUpgradeParameters) 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 "properties": + err = unpopulate(val, "Properties", &s.Properties) + 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 ServerUpgradeParametersProperties. +func (s ServerUpgradeParametersProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "targetServerVersion", s.TargetServerVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerUpgradeParametersProperties. +func (s *ServerUpgradeParametersProperties) 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 "targetServerVersion": + err = unpopulate(val, "TargetServerVersion", &s.TargetServerVersion) + 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 StorageProfile. +func (s StorageProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backupRetentionDays", s.BackupRetentionDays) + populate(objectMap, "geoRedundantBackup", s.GeoRedundantBackup) + populate(objectMap, "storageAutogrow", s.StorageAutogrow) + populate(objectMap, "storageMB", s.StorageMB) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageProfile. +func (s *StorageProfile) 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 "backupRetentionDays": + err = unpopulate(val, "BackupRetentionDays", &s.BackupRetentionDays) + delete(rawMsg, key) + case "geoRedundantBackup": + err = unpopulate(val, "GeoRedundantBackup", &s.GeoRedundantBackup) + delete(rawMsg, key) + case "storageAutogrow": + err = unpopulate(val, "StorageAutogrow", &s.StorageAutogrow) + delete(rawMsg, key) + case "storageMB": + err = unpopulate(val, "StorageMB", &s.StorageMB) + 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 TagsObject. +func (t TagsObject) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagsObject. +func (t *TagsObject) 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 "tags": + err = unpopulate(val, "Tags", &t.Tags) + 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 TopQueryStatisticsInput. +func (t TopQueryStatisticsInput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", t.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TopQueryStatisticsInput. +func (t *TopQueryStatisticsInput) 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 "properties": + err = unpopulate(val, "Properties", &t.Properties) + 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 TopQueryStatisticsInputProperties. +func (t TopQueryStatisticsInputProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "aggregationFunction", t.AggregationFunction) + populate(objectMap, "aggregationWindow", t.AggregationWindow) + populate(objectMap, "numberOfTopQueries", t.NumberOfTopQueries) + populateTimeRFC3339(objectMap, "observationEndTime", t.ObservationEndTime) + populateTimeRFC3339(objectMap, "observationStartTime", t.ObservationStartTime) + populate(objectMap, "observedMetric", t.ObservedMetric) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TopQueryStatisticsInputProperties. +func (t *TopQueryStatisticsInputProperties) 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 "aggregationFunction": + err = unpopulate(val, "AggregationFunction", &t.AggregationFunction) + delete(rawMsg, key) + case "aggregationWindow": + err = unpopulate(val, "AggregationWindow", &t.AggregationWindow) + delete(rawMsg, key) + case "numberOfTopQueries": + err = unpopulate(val, "NumberOfTopQueries", &t.NumberOfTopQueries) + delete(rawMsg, key) + case "observationEndTime": + err = unpopulateTimeRFC3339(val, "ObservationEndTime", &t.ObservationEndTime) + delete(rawMsg, key) + case "observationStartTime": + err = unpopulateTimeRFC3339(val, "ObservationStartTime", &t.ObservationStartTime) + delete(rawMsg, key) + case "observedMetric": + err = unpopulate(val, "ObservedMetric", &t.ObservedMetric) + 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 TopQueryStatisticsResultList. +func (t TopQueryStatisticsResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TopQueryStatisticsResultList. +func (t *TopQueryStatisticsResultList) 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 "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + 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 TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. +func (t *TrackedResource) 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 "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, 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 VirtualNetworkRule. +func (v VirtualNetworkRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", v.ID) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworkRule. +func (v *VirtualNetworkRule) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &v.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + case "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 VirtualNetworkRuleListResult. +func (v VirtualNetworkRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworkRuleListResult. +func (v *VirtualNetworkRuleListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &v.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &v.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworkRuleProperties. +func (v VirtualNetworkRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ignoreMissingVnetServiceEndpoint", v.IgnoreMissingVnetServiceEndpoint) + populate(objectMap, "state", v.State) + populate(objectMap, "virtualNetworkSubnetId", v.VirtualNetworkSubnetID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworkRuleProperties. +func (v *VirtualNetworkRuleProperties) 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 "ignoreMissingVnetServiceEndpoint": + err = unpopulate(val, "IgnoreMissingVnetServiceEndpoint", &v.IgnoreMissingVnetServiceEndpoint) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &v.State) + delete(rawMsg, key) + case "virtualNetworkSubnetId": + err = unpopulate(val, "VirtualNetworkSubnetID", &v.VirtualNetworkSubnetID) + 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 WaitStatistic. +func (w WaitStatistic) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", w.ID) + populate(objectMap, "name", w.Name) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "type", w.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WaitStatistic. +func (w *WaitStatistic) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &w.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &w.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &w.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WaitStatisticProperties. +func (w WaitStatisticProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", w.Count) + populate(objectMap, "databaseName", w.DatabaseName) + populateTimeRFC3339(objectMap, "endTime", w.EndTime) + populate(objectMap, "eventName", w.EventName) + populate(objectMap, "eventTypeName", w.EventTypeName) + populate(objectMap, "queryId", w.QueryID) + populateTimeRFC3339(objectMap, "startTime", w.StartTime) + populate(objectMap, "totalTimeInMs", w.TotalTimeInMs) + populate(objectMap, "userId", w.UserID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WaitStatisticProperties. +func (w *WaitStatisticProperties) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "count": + err = unpopulate(val, "Count", &w.Count) + delete(rawMsg, key) + case "databaseName": + err = unpopulate(val, "DatabaseName", &w.DatabaseName) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &w.EndTime) + delete(rawMsg, key) + case "eventName": + err = unpopulate(val, "EventName", &w.EventName) + delete(rawMsg, key) + case "eventTypeName": + err = unpopulate(val, "EventTypeName", &w.EventTypeName) + delete(rawMsg, key) + case "queryId": + err = unpopulate(val, "QueryID", &w.QueryID) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &w.StartTime) + delete(rawMsg, key) + case "totalTimeInMs": + err = unpopulate(val, "TotalTimeInMs", &w.TotalTimeInMs) + delete(rawMsg, key) + case "userId": + err = unpopulate(val, "UserID", &w.UserID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WaitStatisticsInput. +func (w WaitStatisticsInput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", w.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WaitStatisticsInput. +func (w *WaitStatisticsInput) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &w.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WaitStatisticsInputProperties. +func (w WaitStatisticsInputProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "aggregationWindow", w.AggregationWindow) + populateTimeRFC3339(objectMap, "observationEndTime", w.ObservationEndTime) + populateTimeRFC3339(objectMap, "observationStartTime", w.ObservationStartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WaitStatisticsInputProperties. +func (w *WaitStatisticsInputProperties) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "aggregationWindow": + err = unpopulate(val, "AggregationWindow", &w.AggregationWindow) + delete(rawMsg, key) + case "observationEndTime": + err = unpopulateTimeRFC3339(val, "ObservationEndTime", &w.ObservationEndTime) + delete(rawMsg, key) + case "observationStartTime": + err = unpopulateTimeRFC3339(val, "ObservationStartTime", &w.ObservationStartTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WaitStatisticsResultList. +func (w WaitStatisticsResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WaitStatisticsResultList. +func (w *WaitStatisticsResultList) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &w.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &w.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_operations_client.go b/sdk/resourcemanager/mysql/armmysql/operations_client.go similarity index 76% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_operations_client.go rename to sdk/resourcemanager/mysql/armmysql/operations_client.go index f798e9835293..16ee8087e9b8 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_operations_client.go +++ b/sdk/resourcemanager/mysql/armmysql/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 armmysql @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,42 +21,34 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // List - Lists all of the available REST API operations. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. func (client *OperationsClient) List(ctx context.Context, options *OperationsClientListOptions) (OperationsClientListResponse, error) { req, err := client.listCreateRequest(ctx, options) if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -70,7 +61,7 @@ func (client *OperationsClient) List(ctx context.Context, options *OperationsCli // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.DBforMySQL/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/operations_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/operations_client_example_test.go new file mode 100644 index 000000000000..cbd230ce15dd --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/operations_client_example_test.go @@ -0,0 +1,245 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/OperationList.json +func ExampleOperationsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewOperationsClient().List(ctx, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.OperationListResult = armmysql.OperationListResult{ + // Value: []*armmysql.Operation{ + // { + // Name: to.Ptr("Microsoft.DBforMySQL/locations/performanceTiers/read"), + // Display: &armmysql.OperationDisplay{ + // Description: to.Ptr("Returns the list of Performance Tiers available."), + // Operation: to.Ptr("List Performance Tiers"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("Performance Tiers"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/servers/firewallRules/read"), + // Display: &armmysql.OperationDisplay{ + // Description: to.Ptr("Return the list of firewall rules for a server or gets the properties for the specified firewall rule."), + // Operation: to.Ptr("List/Get Firewall Rules"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("Firewall Rules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/servers/firewallRules/write"), + // Display: &armmysql.OperationDisplay{ + // Description: to.Ptr("Creates a firewall rule with the specified parameters or update an existing rule."), + // Operation: to.Ptr("Create/Update Firewall Rule"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("Firewall Rules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/servers/firewallRules/delete"), + // Display: &armmysql.OperationDisplay{ + // Description: to.Ptr("Deletes an existing firewall rule."), + // Operation: to.Ptr("Delete Firewall Rule"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("Firewall Rules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/servers/read"), + // Display: &armmysql.OperationDisplay{ + // Description: to.Ptr("Return the list of servers or gets the properties for the specified server."), + // Operation: to.Ptr("List/Get MySQL Servers"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("MySQL Server"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/servers/write"), + // Display: &armmysql.OperationDisplay{ + // Description: to.Ptr("Creates a server with the specified parameters or update the properties or tags for the specified server."), + // Operation: to.Ptr("Create/Update MySQL Server"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("MySQL Server"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/servers/delete"), + // Display: &armmysql.OperationDisplay{ + // Description: to.Ptr("Deletes an existing server."), + // Operation: to.Ptr("Delete MySQL Server"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("MySQL Server"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/performanceTiers/read"), + // Display: &armmysql.OperationDisplay{ + // Description: to.Ptr("Returns the list of Performance Tiers available."), + // Operation: to.Ptr("List Performance Tiers"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("Performance Tiers"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/servers/recoverableServers/read"), + // Display: &armmysql.OperationDisplay{ + // Description: to.Ptr("Return the recoverable MySQL Server info"), + // Operation: to.Ptr("Get Recoverable MySQL Server info"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("Recoverable MySQL Server"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/servers/providers/Microsoft.Insights/metricDefinitions/read"), + // Display: &armmysql.OperationDisplay{ + // Description: to.Ptr("Return types of metrics that are available for databases"), + // Operation: to.Ptr("Get database metric definitions"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("Database Metric Definition"), + // }, + // Properties: map[string]any{ + // "serviceSpecification": map[string]any{ + // "metricSpecifications":[]any{ + // map[string]any{ + // "name": "cpu_percent", + // "aggregationType": "Average", + // "displayDescription": "CPU percent", + // "displayName": "CPU percent", + // "fillGapWithZero": true, + // "unit": "Percent", + // }, + // map[string]any{ + // "name": "memory_percent", + // "aggregationType": "Average", + // "displayDescription": "Memory percent", + // "displayName": "Memory percent", + // "fillGapWithZero": true, + // "unit": "Percent", + // }, + // map[string]any{ + // "name": "io_consumption_percent", + // "aggregationType": "Average", + // "displayDescription": "IO percent", + // "displayName": "IO percent", + // "fillGapWithZero": true, + // "unit": "Percent", + // }, + // map[string]any{ + // "name": "storage_percent", + // "aggregationType": "Average", + // "displayDescription": "Storage percentage", + // "displayName": "Storage percentage", + // "unit": "Percent", + // }, + // map[string]any{ + // "name": "storage_used", + // "aggregationType": "Average", + // "displayDescription": "Storage used", + // "displayName": "Storage used", + // "unit": "Bytes", + // }, + // map[string]any{ + // "name": "storage_limit", + // "aggregationType": "Average", + // "displayDescription": "Storage limit", + // "displayName": "Storage limit", + // "unit": "Bytes", + // }, + // map[string]any{ + // "name": "serverlog_storage_percent", + // "aggregationType": "Average", + // "displayDescription": "Server Log storage percent", + // "displayName": "Server Log storage percent", + // "unit": "Percent", + // }, + // map[string]any{ + // "name": "serverlog_storage_usage", + // "aggregationType": "Average", + // "displayDescription": "Server Log storage used", + // "displayName": "Server Log storage used", + // "unit": "Bytes", + // }, + // map[string]any{ + // "name": "serverlog_storage_limit", + // "aggregationType": "Average", + // "displayDescription": "Server Log storage limit", + // "displayName": "Server Log storage limit", + // "unit": "Bytes", + // }, + // map[string]any{ + // "name": "active_connections", + // "aggregationType": "Average", + // "displayDescription": "Total active connections", + // "displayName": "Total active connections", + // "fillGapWithZero": true, + // "unit": "Count", + // }, + // map[string]any{ + // "name": "connections_failed", + // "aggregationType": "Average", + // "displayDescription": "Total failed connections", + // "displayName": "Total failed connections", + // "fillGapWithZero": true, + // "unit": "Count", + // }, + // map[string]any{ + // "name": "seconds_behind_master", + // "aggregationType": "Average", + // "displayDescription": "Replication lag in seconds", + // "displayName": "Replication lag in seconds", + // "fillGapWithZero": true, + // "unit": "Count", + // }, + // }, + // }, + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/servers/providers/Microsoft.Insights/diagnosticSettings/read"), + // Display: &armmysql.OperationDisplay{ + // Description: to.Ptr("Gets the disagnostic setting for the resource"), + // Operation: to.Ptr("Read diagnostic setting"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("Database Metric Definition"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/servers/providers/Microsoft.Insights/diagnosticSettings/write"), + // Display: &armmysql.OperationDisplay{ + // Description: to.Ptr("Creates or updates the diagnostic setting for the resource"), + // Operation: to.Ptr("Write diagnostic setting"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("Database Metric Definition"), + // }, + // }}, + // } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/mysql/armmysql/polymorphic_helpers.go similarity index 96% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_polymorphic_helpers.go rename to sdk/resourcemanager/mysql/armmysql/polymorphic_helpers.go index 69dfa36b72b4..cde1cc20efdf 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_polymorphic_helpers.go +++ b/sdk/resourcemanager/mysql/armmysql/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 armmysql @@ -14,7 +15,7 @@ func unmarshalServerPropertiesForCreateClassification(rawMsg json.RawMessage) (S if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_privateendpointconnections_client.go b/sdk/resourcemanager/mysql/armmysql/privateendpointconnections_client.go similarity index 85% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_privateendpointconnections_client.go rename to sdk/resourcemanager/mysql/armmysql/privateendpointconnections_client.go index 1a16b6e01b71..34bd491471f6 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_privateendpointconnections_client.go +++ b/sdk/resourcemanager/mysql/armmysql/privateendpointconnections_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,63 +24,56 @@ import ( // PrivateEndpointConnectionsClient contains the methods for the PrivateEndpointConnections group. // Don't use this type directly, use NewPrivateEndpointConnectionsClient() instead. type PrivateEndpointConnectionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PrivateEndpointConnectionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PrivateEndpointConnectionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Approve or reject a private endpoint connection with a given name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginCreateOrUpdate +// method. func (client *PrivateEndpointConnectionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection, options *PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[PrivateEndpointConnectionsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, serverName, privateEndpointConnectionName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[PrivateEndpointConnectionsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[PrivateEndpointConnectionsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Approve or reject a private endpoint connection with a given name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 func (client *PrivateEndpointConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection, options *PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serverName, privateEndpointConnectionName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -110,7 +102,7 @@ func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -123,32 +115,34 @@ func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx // BeginDelete - Deletes a private endpoint connection with a given name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - PrivateEndpointConnectionsClientBeginDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - PrivateEndpointConnectionsClientBeginDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginDelete +// method. func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*runtime.Poller[PrivateEndpointConnectionsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, privateEndpointConnectionName, options) if err != nil { return nil, err } - return runtime.NewPoller[PrivateEndpointConnectionsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[PrivateEndpointConnectionsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a private endpoint connection with a given name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, privateEndpointConnectionName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -177,7 +171,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -190,18 +184,19 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // Get - Gets a private endpoint connection. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// privateEndpointConnectionName - The name of the private endpoint connection. -// options - PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - privateEndpointConnectionName - The name of the private endpoint connection. +// - options - PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get +// method. func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (PrivateEndpointConnectionsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, privateEndpointConnectionName, options) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err } @@ -230,7 +225,7 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -251,12 +246,12 @@ func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Res } // NewListByServerPager - Gets all private endpoint connections on a server. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - PrivateEndpointConnectionsClientListByServerOptions contains the optional parameters for the PrivateEndpointConnectionsClient.ListByServer -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - PrivateEndpointConnectionsClientListByServerOptions contains the optional parameters for the PrivateEndpointConnectionsClient.NewListByServerPager +// method. func (client *PrivateEndpointConnectionsClient) NewListByServerPager(resourceGroupName string, serverName string, options *PrivateEndpointConnectionsClientListByServerOptions) *runtime.Pager[PrivateEndpointConnectionsClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[PrivateEndpointConnectionsClientListByServerResponse]{ More: func(page PrivateEndpointConnectionsClientListByServerResponse) bool { @@ -273,7 +268,7 @@ func (client *PrivateEndpointConnectionsClient) NewListByServerPager(resourceGro if err != nil { return PrivateEndpointConnectionsClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientListByServerResponse{}, err } @@ -300,7 +295,7 @@ func (client *PrivateEndpointConnectionsClient) listByServerCreateRequest(ctx co return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -322,33 +317,35 @@ func (client *PrivateEndpointConnectionsClient) listByServerHandleResponse(resp // BeginUpdateTags - Updates private endpoint connection with the specified tags. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// parameters - Parameters supplied to the Update private endpoint connection Tags operation. -// options - PrivateEndpointConnectionsClientBeginUpdateTagsOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginUpdateTags -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - parameters - Parameters supplied to the Update private endpoint connection Tags operation. +// - options - PrivateEndpointConnectionsClientBeginUpdateTagsOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginUpdateTags +// method. func (client *PrivateEndpointConnectionsClient) BeginUpdateTags(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, parameters TagsObject, options *PrivateEndpointConnectionsClientBeginUpdateTagsOptions) (*runtime.Poller[PrivateEndpointConnectionsClientUpdateTagsResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.updateTags(ctx, resourceGroupName, serverName, privateEndpointConnectionName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[PrivateEndpointConnectionsClientUpdateTagsResponse](resp, client.pl, nil) + return runtime.NewPoller[PrivateEndpointConnectionsClientUpdateTagsResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientUpdateTagsResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientUpdateTagsResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // UpdateTags - Updates private endpoint connection with the specified tags. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 func (client *PrivateEndpointConnectionsClient) updateTags(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, parameters TagsObject, options *PrivateEndpointConnectionsClientBeginUpdateTagsOptions) (*http.Response, error) { req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, serverName, privateEndpointConnectionName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -377,7 +374,7 @@ func (client *PrivateEndpointConnectionsClient) updateTagsCreateRequest(ctx cont return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/privateendpointconnections_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/privateendpointconnections_client_example_test.go new file mode 100644 index 000000000000..4284c6238efe --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/privateendpointconnections_client_example_test.go @@ -0,0 +1,228 @@ +//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 armmysql_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/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/PrivateEndpointConnectionGet.json +func ExamplePrivateEndpointConnectionsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPrivateEndpointConnectionsClient().Get(ctx, "Default", "test-svr", "private-endpoint-connection-name", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateEndpointConnection = armmysql.PrivateEndpointConnection{ + // Name: to.Ptr("private-endpoint-connection-name"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.DBforMySQL/servers/test-svr/privateEndpointConnections/private-endpoint-connection-name"), + // Properties: &armmysql.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmysql.PrivateEndpointProperty{ + // ID: to.Ptr("/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-Network/providers/Microsoft.Network/privateEndpoints/private-endpoint-name"), + // }, + // PrivateLinkServiceConnectionState: &armmysql.PrivateLinkServiceConnectionStateProperty{ + // Description: to.Ptr("Auto-approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr("Approved"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/PrivateEndpointConnectionUpdate.json +func ExamplePrivateEndpointConnectionsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPrivateEndpointConnectionsClient().BeginCreateOrUpdate(ctx, "Default", "test-svr", "private-endpoint-connection-name", armmysql.PrivateEndpointConnection{ + Properties: &armmysql.PrivateEndpointConnectionProperties{ + PrivateLinkServiceConnectionState: &armmysql.PrivateLinkServiceConnectionStateProperty{ + Description: to.Ptr("Approved by johndoe@contoso.com"), + Status: to.Ptr("Approved"), + }, + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateEndpointConnection = armmysql.PrivateEndpointConnection{ + // Name: to.Ptr("private-endpoint-connection-name"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.DBforMySQL/servers/test-svr/privateEndpointConnections/private-endpoint-connection-name"), + // Properties: &armmysql.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmysql.PrivateEndpointProperty{ + // ID: to.Ptr("/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-Network/providers/Microsoft.Network/privateEndpoints/private-endpoint-name"), + // }, + // PrivateLinkServiceConnectionState: &armmysql.PrivateLinkServiceConnectionStateProperty{ + // Description: to.Ptr("Approved by johndoe@contoso.com"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr("Approved"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/PrivateEndpointConnectionDelete.json +func ExamplePrivateEndpointConnectionsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPrivateEndpointConnectionsClient().BeginDelete(ctx, "Default", "test-svr", "private-endpoint-connection-name", 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/PrivateEndpointConnectionUpdateTags.json +func ExamplePrivateEndpointConnectionsClient_BeginUpdateTags() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPrivateEndpointConnectionsClient().BeginUpdateTags(ctx, "Default", "test-svr", "private-endpoint-connection-name", armmysql.TagsObject{ + Tags: map[string]*string{ + "key1": to.Ptr("val1"), + "key2": to.Ptr("val2"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateEndpointConnection = armmysql.PrivateEndpointConnection{ + // Name: to.Ptr("private-endpoint-connection-name"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.DBforMySQL/servers/test-svr/privateEndpointConnections/private-endpoint-connection-name"), + // Properties: &armmysql.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmysql.PrivateEndpointProperty{ + // ID: to.Ptr("/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-Network/providers/Microsoft.Network/privateEndpoints/private-endpoint-name"), + // }, + // PrivateLinkServiceConnectionState: &armmysql.PrivateLinkServiceConnectionStateProperty{ + // Description: to.Ptr("Approved by johndoe@contoso.com"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr("Approved"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/PrivateEndpointConnectionList.json +func ExamplePrivateEndpointConnectionsClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPrivateEndpointConnectionsClient().NewListByServerPager("Default", "test-svr", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PrivateEndpointConnectionListResult = armmysql.PrivateEndpointConnectionListResult{ + // Value: []*armmysql.PrivateEndpointConnection{ + // { + // Name: to.Ptr("private-endpoint-connection-name"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.DBforMySQL/servers/test-svr/privateEndpointConnections/private-endpoint-connection-name-2"), + // Properties: &armmysql.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmysql.PrivateEndpointProperty{ + // ID: to.Ptr("/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-Network/providers/Microsoft.Network/privateEndpoints/private-endpoint-name"), + // }, + // PrivateLinkServiceConnectionState: &armmysql.PrivateLinkServiceConnectionStateProperty{ + // Description: to.Ptr("Auto-approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr("Approved"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // }, + // { + // Name: to.Ptr("private-endpoint-connection-name-2"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.DBforMySQL/servers/test-svr/privateEndpointConnections/private-endpoint-connection-name-2"), + // Properties: &armmysql.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmysql.PrivateEndpointProperty{ + // ID: to.Ptr("/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-Network/providers/Microsoft.Network/privateEndpoints/private-endpoint-name-2"), + // }, + // PrivateLinkServiceConnectionState: &armmysql.PrivateLinkServiceConnectionStateProperty{ + // Description: to.Ptr("Auto-approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr("Approved"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_privatelinkresources_client.go b/sdk/resourcemanager/mysql/armmysql/privatelinkresources_client.go similarity index 82% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_privatelinkresources_client.go rename to sdk/resourcemanager/mysql/armmysql/privatelinkresources_client.go index 0ca7b219189a..fc837d0b6c25 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_privatelinkresources_client.go +++ b/sdk/resourcemanager/mysql/armmysql/privatelinkresources_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,49 +24,41 @@ import ( // PrivateLinkResourcesClient contains the methods for the PrivateLinkResources group. // Don't use this type directly, use NewPrivateLinkResourcesClient() instead. type PrivateLinkResourcesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkResourcesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PrivateLinkResourcesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PrivateLinkResourcesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets a private link resource for MySQL server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// groupName - The name of the private link resource. -// options - PrivateLinkResourcesClientGetOptions contains the optional parameters for the PrivateLinkResourcesClient.Get -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - groupName - The name of the private link resource. +// - options - PrivateLinkResourcesClientGetOptions contains the optional parameters for the PrivateLinkResourcesClient.Get +// method. func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, serverName string, groupName string, options *PrivateLinkResourcesClientGetOptions) (PrivateLinkResourcesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, groupName, options) if err != nil { return PrivateLinkResourcesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkResourcesClientGetResponse{}, err } @@ -96,7 +87,7 @@ func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -117,12 +108,12 @@ func (client *PrivateLinkResourcesClient) getHandleResponse(resp *http.Response) } // NewListByServerPager - Gets the private link resources for MySQL server. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - PrivateLinkResourcesClientListByServerOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByServer -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - PrivateLinkResourcesClientListByServerOptions contains the optional parameters for the PrivateLinkResourcesClient.NewListByServerPager +// method. func (client *PrivateLinkResourcesClient) NewListByServerPager(resourceGroupName string, serverName string, options *PrivateLinkResourcesClientListByServerOptions) *runtime.Pager[PrivateLinkResourcesClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[PrivateLinkResourcesClientListByServerResponse]{ More: func(page PrivateLinkResourcesClientListByServerResponse) bool { @@ -139,7 +130,7 @@ func (client *PrivateLinkResourcesClient) NewListByServerPager(resourceGroupName if err != nil { return PrivateLinkResourcesClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkResourcesClientListByServerResponse{}, err } @@ -166,7 +157,7 @@ func (client *PrivateLinkResourcesClient) listByServerCreateRequest(ctx context. return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/privatelinkresources_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/privatelinkresources_client_example_test.go new file mode 100644 index 000000000000..7a8467abe516 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/privatelinkresources_client_example_test.go @@ -0,0 +1,86 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/PrivateLinkResourcesList.json +func ExamplePrivateLinkResourcesClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPrivateLinkResourcesClient().NewListByServerPager("Default", "test-svr", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PrivateLinkResourceListResult = armmysql.PrivateLinkResourceListResult{ + // Value: []*armmysql.PrivateLinkResource{ + // { + // Name: to.Ptr("plr"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/privateLinkResources"), + // ID: to.Ptr("subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.DBforMySQL/servers/test-svr/privateLinkResources/plr"), + // Properties: &armmysql.PrivateLinkResourceProperties{ + // GroupID: to.Ptr("mysqlServer"), + // RequiredMembers: []*string{ + // to.Ptr("mysqlServer")}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/PrivateLinkResourcesGet.json +func ExamplePrivateLinkResourcesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPrivateLinkResourcesClient().Get(ctx, "Default", "test-svr", "plr", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateLinkResource = armmysql.PrivateLinkResource{ + // Name: to.Ptr("plr"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/privateLinkResources"), + // ID: to.Ptr("subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.DBforMySQL/servers/test-svr/privateLinkResources/plr"), + // Properties: &armmysql.PrivateLinkResourceProperties{ + // GroupID: to.Ptr("mysqlServer"), + // RequiredMembers: []*string{ + // to.Ptr("mysqlServer")}, + // }, + // } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_querytexts_client.go b/sdk/resourcemanager/mysql/armmysql/querytexts_client.go similarity index 81% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_querytexts_client.go rename to sdk/resourcemanager/mysql/armmysql/querytexts_client.go index cc6521e06238..0864037a91ef 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_querytexts_client.go +++ b/sdk/resourcemanager/mysql/armmysql/querytexts_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // QueryTextsClient contains the methods for the QueryTexts group. // Don't use this type directly, use NewQueryTextsClient() instead. type QueryTextsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewQueryTextsClient creates a new instance of QueryTextsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewQueryTextsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*QueryTextsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".QueryTextsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &QueryTextsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Retrieve the Query-Store query texts for the queryId. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// queryID - The Query-Store query identifier. -// options - QueryTextsClientGetOptions contains the optional parameters for the QueryTextsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - queryID - The Query-Store query identifier. +// - options - QueryTextsClientGetOptions contains the optional parameters for the QueryTextsClient.Get method. func (client *QueryTextsClient) Get(ctx context.Context, resourceGroupName string, serverName string, queryID string, options *QueryTextsClientGetOptions) (QueryTextsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, queryID, options) if err != nil { return QueryTextsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return QueryTextsClientGetResponse{}, err } @@ -95,7 +86,7 @@ func (client *QueryTextsClient) getCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter queryID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{queryId}", url.PathEscape(queryID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -116,12 +107,13 @@ func (client *QueryTextsClient) getHandleResponse(resp *http.Response) (QueryTex } // NewListByServerPager - Retrieve the Query-Store query texts for specified queryIds. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// queryIDs - The query identifiers -// options - QueryTextsClientListByServerOptions contains the optional parameters for the QueryTextsClient.ListByServer method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - queryIDs - The query identifiers +// - options - QueryTextsClientListByServerOptions contains the optional parameters for the QueryTextsClient.NewListByServerPager +// method. func (client *QueryTextsClient) NewListByServerPager(resourceGroupName string, serverName string, queryIDs []string, options *QueryTextsClientListByServerOptions) *runtime.Pager[QueryTextsClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[QueryTextsClientListByServerResponse]{ More: func(page QueryTextsClientListByServerResponse) bool { @@ -138,7 +130,7 @@ func (client *QueryTextsClient) NewListByServerPager(resourceGroupName string, s if err != nil { return QueryTextsClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return QueryTextsClientListByServerResponse{}, err } @@ -165,7 +157,7 @@ func (client *QueryTextsClient) listByServerCreateRequest(ctx context.Context, r return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/querytexts_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/querytexts_client_example_test.go new file mode 100644 index 000000000000..4a1e0529d307 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/querytexts_client_example_test.go @@ -0,0 +1,95 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/QueryTextsGet.json +func ExampleQueryTextsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewQueryTextsClient().Get(ctx, "testResourceGroupName", "testServerName", "1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.QueryText = armmysql.QueryText{ + // Name: to.Ptr("1"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/queryTexts"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.DBforMySQL/servers/testServerName/queryTexts/1"), + // Properties: &armmysql.QueryTextProperties{ + // QueryID: to.Ptr("1"), + // QueryText: to.Ptr("UPDATE `performance_schema`.`setup_instruments` SET `ENABLED` = ? , `TIMED` = ? WHERE NAME = ?"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/QueryTextsListByServer.json +func ExampleQueryTextsClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewQueryTextsClient().NewListByServerPager("testResourceGroupName", "testServerName", []string{ + "1", + "2"}, nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.QueryTextsResultList = armmysql.QueryTextsResultList{ + // Value: []*armmysql.QueryText{ + // { + // Name: to.Ptr("1"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/queryTexts"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.DBforMySQL/servers/testServerName/queryTexts/1"), + // Properties: &armmysql.QueryTextProperties{ + // QueryID: to.Ptr("1"), + // QueryText: to.Ptr("UPDATE `performance_schema`.`setup_instruments` SET `ENABLED` = ? , `TIMED` = ? WHERE NAME = ?"), + // }, + // }, + // { + // Name: to.Ptr("2"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/queryTexts"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.DBforMySQL/servers/testServerName/queryTexts/2"), + // Properties: &armmysql.QueryTextProperties{ + // QueryID: to.Ptr("2"), + // QueryText: to.Ptr("UPDATE `performance_schema`.`setup_instruments` SET `ENABLED` = ? , `TIMED` = ? WHERE NAME LIKE ?"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_recommendedactions_client.go b/sdk/resourcemanager/mysql/armmysql/recommendedactions_client.go similarity index 82% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_recommendedactions_client.go rename to sdk/resourcemanager/mysql/armmysql/recommendedactions_client.go index 592ed1062c46..30473fd5fa8e 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_recommendedactions_client.go +++ b/sdk/resourcemanager/mysql/armmysql/recommendedactions_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,49 +24,41 @@ import ( // RecommendedActionsClient contains the methods for the RecommendedActions group. // Don't use this type directly, use NewRecommendedActionsClient() instead. type RecommendedActionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewRecommendedActionsClient creates a new instance of RecommendedActionsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewRecommendedActionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RecommendedActionsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".RecommendedActionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &RecommendedActionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Retrieve recommended actions from the advisor. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// advisorName - The advisor name for recommendation action. -// recommendedActionName - The recommended action name. -// options - RecommendedActionsClientGetOptions contains the optional parameters for the RecommendedActionsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - advisorName - The advisor name for recommendation action. +// - recommendedActionName - The recommended action name. +// - options - RecommendedActionsClientGetOptions contains the optional parameters for the RecommendedActionsClient.Get method. func (client *RecommendedActionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, advisorName string, recommendedActionName string, options *RecommendedActionsClientGetOptions) (RecommendedActionsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, advisorName, recommendedActionName, options) if err != nil { return RecommendedActionsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RecommendedActionsClientGetResponse{}, err } @@ -100,7 +91,7 @@ func (client *RecommendedActionsClient) getCreateRequest(ctx context.Context, re return nil, errors.New("parameter recommendedActionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{recommendedActionName}", url.PathEscape(recommendedActionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -121,13 +112,13 @@ func (client *RecommendedActionsClient) getHandleResponse(resp *http.Response) ( } // NewListByServerPager - Retrieve recommended actions from the advisor. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// advisorName - The advisor name for recommendation action. -// options - RecommendedActionsClientListByServerOptions contains the optional parameters for the RecommendedActionsClient.ListByServer -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - advisorName - The advisor name for recommendation action. +// - options - RecommendedActionsClientListByServerOptions contains the optional parameters for the RecommendedActionsClient.NewListByServerPager +// method. func (client *RecommendedActionsClient) NewListByServerPager(resourceGroupName string, serverName string, advisorName string, options *RecommendedActionsClientListByServerOptions) *runtime.Pager[RecommendedActionsClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[RecommendedActionsClientListByServerResponse]{ More: func(page RecommendedActionsClientListByServerResponse) bool { @@ -144,7 +135,7 @@ func (client *RecommendedActionsClient) NewListByServerPager(resourceGroupName s if err != nil { return RecommendedActionsClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RecommendedActionsClientListByServerResponse{}, err } @@ -175,7 +166,7 @@ func (client *RecommendedActionsClient) listByServerCreateRequest(ctx context.Co return nil, errors.New("parameter advisorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{advisorName}", url.PathEscape(advisorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/recommendedactions_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/recommendedactions_client_example_test.go new file mode 100644 index 000000000000..84f646b7ab5a --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/recommendedactions_client_example_test.go @@ -0,0 +1,141 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/RecommendedActionsGet.json +func ExampleRecommendedActionsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecommendedActionsClient().Get(ctx, "testResourceGroupName", "testServerName", "Index", "Index-1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RecommendationAction = armmysql.RecommendationAction{ + // Name: to.Ptr("Index-1"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/advisors/recommendedActions"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.Sql/servers/testServerName/advisors/Index/recommendedActions/Index-1"), + // Properties: &armmysql.RecommendationActionProperties{ + // ActionID: to.Ptr[int32](1), + // AdvisorName: to.Ptr("Index"), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-01T23:43:24Z"); return t}()), + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-08T23:43:24Z"); return t}()), + // Reason: to.Ptr("Column `movies_genres`.`movie_id` appear in Join On clause(s)."), + // RecommendationType: to.Ptr("Add"), + // SessionID: to.Ptr("c63c2114-e2a4-4c7a-98c1-85577d1a5d50"), + // Details: map[string]*string{ + // "engine": to.Ptr("InnoDB"), + // "indexColumns": to.Ptr("`movies_genres`.`movie_id`"), + // "indexName": to.Ptr("idx_movie_id"), + // "indexType": to.Ptr("BTREE"), + // "parentTableName": to.Ptr("movies_genres"), + // "queryIds": to.Ptr("779"), + // "schemaName": to.Ptr("movies"), + // "script": to.Ptr("alter table `movies`.`movies_genres` add index `idx_movie_id` (`movie_id`)"), + // "tableName": to.Ptr("movies_genres"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/RecommendedActionsListByServer.json +func ExampleRecommendedActionsClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRecommendedActionsClient().NewListByServerPager("testResourceGroupName", "testServerName", "Index", &armmysql.RecommendedActionsClientListByServerOptions{SessionID: nil}) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RecommendationActionsResultList = armmysql.RecommendationActionsResultList{ + // Value: []*armmysql.RecommendationAction{ + // { + // Name: to.Ptr("Index-1"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/advisors/recommendedActions"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.Sql/servers/testServerName/advisors/Index/recommendedActions/Index-1"), + // Properties: &armmysql.RecommendationActionProperties{ + // ActionID: to.Ptr[int32](1), + // AdvisorName: to.Ptr("Index"), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-01T23:43:24Z"); return t}()), + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-08T23:43:24Z"); return t}()), + // Reason: to.Ptr("Column `movies_genres`.`movie_id` appear in Join On clause(s)."), + // RecommendationType: to.Ptr("Add"), + // SessionID: to.Ptr("c63c2114-e2a4-4c7a-98c1-85577d1a5d50"), + // Details: map[string]*string{ + // "engine": to.Ptr("InnoDB"), + // "indexColumns": to.Ptr("`movies_genres`.`movie_id`"), + // "indexName": to.Ptr("idx_movie_id"), + // "indexType": to.Ptr("BTREE"), + // "parentTableName": to.Ptr("movies_genres"), + // "queryIds": to.Ptr("779"), + // "schemaName": to.Ptr("movies"), + // "script": to.Ptr("alter table `movies`.`movies_genres` add index `idx_movie_id` (`movie_id`)"), + // "tableName": to.Ptr("movies_genres"), + // }, + // }, + // }, + // { + // Name: to.Ptr("Index-2"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/advisors/recommendedActions"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.Sql/servers/testServerName/advisors/Index/recommendedActions/Index-2"), + // Properties: &armmysql.RecommendationActionProperties{ + // ActionID: to.Ptr[int32](2), + // AdvisorName: to.Ptr("Index"), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-01T23:43:24Z"); return t}()), + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-08T23:43:24Z"); return t}()), + // Reason: to.Ptr("Column `movies_genres`.`genre` appear in Group By clause(s)."), + // RecommendationType: to.Ptr("Add"), + // SessionID: to.Ptr("c63c2114-e2a4-4c7a-98c1-85577d1a5d50"), + // Details: map[string]*string{ + // "engine": to.Ptr("InnoDB"), + // "indexColumns": to.Ptr("`movies_genres`.`genre`"), + // "indexName": to.Ptr("idx_genre"), + // "indexType": to.Ptr("BTREE"), + // "parentTableName": to.Ptr("movies_genres"), + // "queryIds": to.Ptr("779"), + // "schemaName": to.Ptr("movies"), + // "script": to.Ptr("alter table `movies`.`movies_genres` add index `idx_genre` (`genre`)"), + // "tableName": to.Ptr("movies_genres"), + // }, + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_recoverableservers_client.go b/sdk/resourcemanager/mysql/armmysql/recoverableservers_client.go similarity index 77% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_recoverableservers_client.go rename to sdk/resourcemanager/mysql/armmysql/recoverableservers_client.go index dc1c9c1c07ac..fcf69eab48d2 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_recoverableservers_client.go +++ b/sdk/resourcemanager/mysql/armmysql/recoverableservers_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,47 +24,39 @@ import ( // RecoverableServersClient contains the methods for the RecoverableServers group. // Don't use this type directly, use NewRecoverableServersClient() instead. type RecoverableServersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewRecoverableServersClient creates a new instance of RecoverableServersClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewRecoverableServersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RecoverableServersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".RecoverableServersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &RecoverableServersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets a recoverable MySQL Server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - RecoverableServersClientGetOptions contains the optional parameters for the RecoverableServersClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - RecoverableServersClientGetOptions contains the optional parameters for the RecoverableServersClient.Get method. func (client *RecoverableServersClient) Get(ctx context.Context, resourceGroupName string, serverName string, options *RecoverableServersClientGetOptions) (RecoverableServersClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return RecoverableServersClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RecoverableServersClientGetResponse{}, err } @@ -90,7 +81,7 @@ func (client *RecoverableServersClient) getCreateRequest(ctx context.Context, re return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/recoverableservers_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/recoverableservers_client_example_test.go new file mode 100644 index 000000000000..b0e80c8428ad --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/recoverableservers_client_example_test.go @@ -0,0 +1,51 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/RecoverableServersGet.json +func ExampleRecoverableServersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecoverableServersClient().Get(ctx, "testrg", "testsvc4", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RecoverableServerResource = armmysql.RecoverableServerResource{ + // Name: to.Ptr("recoverableServers"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/recoverableServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/testsvc4/recoverableServers"), + // Properties: &armmysql.RecoverableServerProperties{ + // Edition: to.Ptr("GeneralPurpose"), + // HardwareGeneration: to.Ptr("Gen5"), + // LastAvailableBackupDateTime: to.Ptr("2020-11-20T01:06:29.78Z"), + // ServiceLevelObjective: to.Ptr("GP_Gen5_2"), + // VCore: to.Ptr[int32](2), + // Version: to.Ptr("5.7"), + // }, + // } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_replicas_client.go b/sdk/resourcemanager/mysql/armmysql/replicas_client.go similarity index 77% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_replicas_client.go rename to sdk/resourcemanager/mysql/armmysql/replicas_client.go index e3cd81ea9fc3..9b39415f5279 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_replicas_client.go +++ b/sdk/resourcemanager/mysql/armmysql/replicas_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,41 +24,33 @@ import ( // ReplicasClient contains the methods for the Replicas group. // Don't use this type directly, use NewReplicasClient() instead. type ReplicasClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewReplicasClient creates a new instance of ReplicasClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewReplicasClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ReplicasClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ReplicasClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ReplicasClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListByServerPager - List all the replicas for a given server. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ReplicasClientListByServerOptions contains the optional parameters for the ReplicasClient.ListByServer method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ReplicasClientListByServerOptions contains the optional parameters for the ReplicasClient.NewListByServerPager +// method. func (client *ReplicasClient) NewListByServerPager(resourceGroupName string, serverName string, options *ReplicasClientListByServerOptions) *runtime.Pager[ReplicasClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[ReplicasClientListByServerResponse]{ More: func(page ReplicasClientListByServerResponse) bool { @@ -70,7 +61,7 @@ func (client *ReplicasClient) NewListByServerPager(resourceGroupName string, ser if err != nil { return ReplicasClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ReplicasClientListByServerResponse{}, err } @@ -97,7 +88,7 @@ func (client *ReplicasClient) listByServerCreateRequest(ctx context.Context, res return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/replicas_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/replicas_client_example_test.go new file mode 100644 index 000000000000..98dea15dafe4 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/replicas_client_example_test.go @@ -0,0 +1,139 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ReplicasListByServer.json +func ExampleReplicasClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewReplicasClient().NewListByServerPager("TestGroup", "testmaster", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ServerListResult = armmysql.ServerListResult{ + // Value: []*armmysql.Server{ + // { + // Name: to.Ptr("testserver"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testserver"), + // Location: to.Ptr("northeurope"), + // Tags: map[string]*string{ + // "elasticServer": to.Ptr("1"), + // }, + // Properties: &armmysql.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-11T23:56:54.3+00:00"); return t}()), + // FullyQualifiedDomainName: to.Ptr("testserver.mysql.database.azure.com"), + // MasterServerID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testmaster"), + // ReplicaCapacity: to.Ptr[int32](0), + // ReplicationRole: to.Ptr("Replica"), + // SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumEnabled), + // StorageProfile: &armmysql.StorageProfile{ + // BackupRetentionDays: to.Ptr[int32](35), + // GeoRedundantBackup: to.Ptr(armmysql.GeoRedundantBackupEnabled), + // StorageMB: to.Ptr[int32](256000), + // }, + // UserVisibleState: to.Ptr(armmysql.ServerStateReady), + // Version: to.Ptr(armmysql.ServerVersionFive6), + // }, + // SKU: &armmysql.SKU{ + // Name: to.Ptr("GP_Gen4_2"), + // Capacity: to.Ptr[int32](2), + // Family: to.Ptr("Gen4"), + // Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), + // }, + // }, + // { + // Name: to.Ptr("testserver1"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testserver1"), + // Location: to.Ptr("northeurope"), + // Tags: map[string]*string{ + // "elasticServer": to.Ptr("1"), + // }, + // Properties: &armmysql.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-11T23:56:54.3+00:00"); return t}()), + // FullyQualifiedDomainName: to.Ptr("testserver1.mysql.database.azure.com"), + // MasterServerID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testmaster"), + // ReplicaCapacity: to.Ptr[int32](0), + // ReplicationRole: to.Ptr("Replica"), + // SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumEnabled), + // StorageProfile: &armmysql.StorageProfile{ + // BackupRetentionDays: to.Ptr[int32](35), + // GeoRedundantBackup: to.Ptr(armmysql.GeoRedundantBackupEnabled), + // StorageMB: to.Ptr[int32](256000), + // }, + // UserVisibleState: to.Ptr(armmysql.ServerStateReady), + // Version: to.Ptr(armmysql.ServerVersionFive6), + // }, + // SKU: &armmysql.SKU{ + // Name: to.Ptr("GP_Gen4_2"), + // Capacity: to.Ptr[int32](2), + // Family: to.Ptr("Gen4"), + // Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), + // }, + // }, + // { + // Name: to.Ptr("testserver2"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testserver2"), + // Location: to.Ptr("northeurope"), + // Tags: map[string]*string{ + // "elasticServer": to.Ptr("1"), + // }, + // Properties: &armmysql.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-11T23:56:54.3+00:00"); return t}()), + // FullyQualifiedDomainName: to.Ptr("testserver2.mysql.database.azure.com"), + // MasterServerID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testmaster"), + // ReplicaCapacity: to.Ptr[int32](0), + // ReplicationRole: to.Ptr("Replica"), + // SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumEnabled), + // StorageProfile: &armmysql.StorageProfile{ + // BackupRetentionDays: to.Ptr[int32](35), + // GeoRedundantBackup: to.Ptr(armmysql.GeoRedundantBackupEnabled), + // StorageMB: to.Ptr[int32](256000), + // }, + // UserVisibleState: to.Ptr(armmysql.ServerStateReady), + // Version: to.Ptr(armmysql.ServerVersionFive6), + // }, + // SKU: &armmysql.SKU{ + // Name: to.Ptr("GP_Gen4_2"), + // Capacity: to.Ptr[int32](2), + // Family: to.Ptr("Gen4"), + // Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_response_types.go b/sdk/resourcemanager/mysql/armmysql/response_types.go similarity index 81% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_response_types.go rename to sdk/resourcemanager/mysql/armmysql/response_types.go index 5a56aeacd2d9..cdce43facd87 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_response_types.go +++ b/sdk/resourcemanager/mysql/armmysql/response_types.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armmysql @@ -13,7 +14,7 @@ type AdvisorsClientGetResponse struct { Advisor } -// AdvisorsClientListByServerResponse contains the response from method AdvisorsClient.ListByServer. +// AdvisorsClientListByServerResponse contains the response from method AdvisorsClient.NewListByServerPager. type AdvisorsClientListByServerResponse struct { AdvisorsResultList } @@ -23,7 +24,7 @@ type CheckNameAvailabilityClientExecuteResponse struct { NameAvailability } -// ConfigurationsClientCreateOrUpdateResponse contains the response from method ConfigurationsClient.CreateOrUpdate. +// ConfigurationsClientCreateOrUpdateResponse contains the response from method ConfigurationsClient.BeginCreateOrUpdate. type ConfigurationsClientCreateOrUpdateResponse struct { Configuration } @@ -33,17 +34,17 @@ type ConfigurationsClientGetResponse struct { Configuration } -// ConfigurationsClientListByServerResponse contains the response from method ConfigurationsClient.ListByServer. +// ConfigurationsClientListByServerResponse contains the response from method ConfigurationsClient.NewListByServerPager. type ConfigurationsClientListByServerResponse struct { ConfigurationListResult } -// DatabasesClientCreateOrUpdateResponse contains the response from method DatabasesClient.CreateOrUpdate. +// DatabasesClientCreateOrUpdateResponse contains the response from method DatabasesClient.BeginCreateOrUpdate. type DatabasesClientCreateOrUpdateResponse struct { Database } -// DatabasesClientDeleteResponse contains the response from method DatabasesClient.Delete. +// DatabasesClientDeleteResponse contains the response from method DatabasesClient.BeginDelete. type DatabasesClientDeleteResponse struct { // placeholder for future response values } @@ -53,17 +54,17 @@ type DatabasesClientGetResponse struct { Database } -// DatabasesClientListByServerResponse contains the response from method DatabasesClient.ListByServer. +// DatabasesClientListByServerResponse contains the response from method DatabasesClient.NewListByServerPager. type DatabasesClientListByServerResponse struct { DatabaseListResult } -// FirewallRulesClientCreateOrUpdateResponse contains the response from method FirewallRulesClient.CreateOrUpdate. +// FirewallRulesClientCreateOrUpdateResponse contains the response from method FirewallRulesClient.BeginCreateOrUpdate. type FirewallRulesClientCreateOrUpdateResponse struct { FirewallRule } -// FirewallRulesClientDeleteResponse contains the response from method FirewallRulesClient.Delete. +// FirewallRulesClientDeleteResponse contains the response from method FirewallRulesClient.BeginDelete. type FirewallRulesClientDeleteResponse struct { // placeholder for future response values } @@ -73,12 +74,12 @@ type FirewallRulesClientGetResponse struct { FirewallRule } -// FirewallRulesClientListByServerResponse contains the response from method FirewallRulesClient.ListByServer. +// FirewallRulesClientListByServerResponse contains the response from method FirewallRulesClient.NewListByServerPager. type FirewallRulesClientListByServerResponse struct { FirewallRuleListResult } -// LocationBasedPerformanceTierClientListResponse contains the response from method LocationBasedPerformanceTierClient.List. +// LocationBasedPerformanceTierClientListResponse contains the response from method LocationBasedPerformanceTierClient.NewListPager. type LocationBasedPerformanceTierClientListResponse struct { PerformanceTierListResult } @@ -88,17 +89,17 @@ type LocationBasedRecommendedActionSessionsOperationStatusClientGetResponse stru RecommendedActionSessionsOperationStatus } -// LocationBasedRecommendedActionSessionsResultClientListResponse contains the response from method LocationBasedRecommendedActionSessionsResultClient.List. +// LocationBasedRecommendedActionSessionsResultClientListResponse contains the response from method LocationBasedRecommendedActionSessionsResultClient.NewListPager. type LocationBasedRecommendedActionSessionsResultClientListResponse struct { RecommendationActionsResultList } -// LogFilesClientListByServerResponse contains the response from method LogFilesClient.ListByServer. +// LogFilesClientListByServerResponse contains the response from method LogFilesClient.NewListByServerPager. type LogFilesClientListByServerResponse struct { LogFileListResult } -// ManagementClientCreateRecommendedActionSessionResponse contains the response from method ManagementClient.CreateRecommendedActionSession. +// ManagementClientCreateRecommendedActionSessionResponse contains the response from method ManagementClient.BeginCreateRecommendedActionSession. type ManagementClientCreateRecommendedActionSessionResponse struct { // placeholder for future response values } @@ -113,12 +114,12 @@ type OperationsClientListResponse struct { OperationListResult } -// PrivateEndpointConnectionsClientCreateOrUpdateResponse contains the response from method PrivateEndpointConnectionsClient.CreateOrUpdate. +// PrivateEndpointConnectionsClientCreateOrUpdateResponse contains the response from method PrivateEndpointConnectionsClient.BeginCreateOrUpdate. type PrivateEndpointConnectionsClientCreateOrUpdateResponse struct { PrivateEndpointConnection } -// PrivateEndpointConnectionsClientDeleteResponse contains the response from method PrivateEndpointConnectionsClient.Delete. +// PrivateEndpointConnectionsClientDeleteResponse contains the response from method PrivateEndpointConnectionsClient.BeginDelete. type PrivateEndpointConnectionsClientDeleteResponse struct { // placeholder for future response values } @@ -128,12 +129,12 @@ type PrivateEndpointConnectionsClientGetResponse struct { PrivateEndpointConnection } -// PrivateEndpointConnectionsClientListByServerResponse contains the response from method PrivateEndpointConnectionsClient.ListByServer. +// PrivateEndpointConnectionsClientListByServerResponse contains the response from method PrivateEndpointConnectionsClient.NewListByServerPager. type PrivateEndpointConnectionsClientListByServerResponse struct { PrivateEndpointConnectionListResult } -// PrivateEndpointConnectionsClientUpdateTagsResponse contains the response from method PrivateEndpointConnectionsClient.UpdateTags. +// PrivateEndpointConnectionsClientUpdateTagsResponse contains the response from method PrivateEndpointConnectionsClient.BeginUpdateTags. type PrivateEndpointConnectionsClientUpdateTagsResponse struct { PrivateEndpointConnection } @@ -143,7 +144,7 @@ type PrivateLinkResourcesClientGetResponse struct { PrivateLinkResource } -// PrivateLinkResourcesClientListByServerResponse contains the response from method PrivateLinkResourcesClient.ListByServer. +// PrivateLinkResourcesClientListByServerResponse contains the response from method PrivateLinkResourcesClient.NewListByServerPager. type PrivateLinkResourcesClientListByServerResponse struct { PrivateLinkResourceListResult } @@ -153,7 +154,7 @@ type QueryTextsClientGetResponse struct { QueryText } -// QueryTextsClientListByServerResponse contains the response from method QueryTextsClient.ListByServer. +// QueryTextsClientListByServerResponse contains the response from method QueryTextsClient.NewListByServerPager. type QueryTextsClientListByServerResponse struct { QueryTextsResultList } @@ -163,7 +164,7 @@ type RecommendedActionsClientGetResponse struct { RecommendationAction } -// RecommendedActionsClientListByServerResponse contains the response from method RecommendedActionsClient.ListByServer. +// RecommendedActionsClientListByServerResponse contains the response from method RecommendedActionsClient.NewListByServerPager. type RecommendedActionsClientListByServerResponse struct { RecommendationActionsResultList } @@ -173,17 +174,17 @@ type RecoverableServersClientGetResponse struct { RecoverableServerResource } -// ReplicasClientListByServerResponse contains the response from method ReplicasClient.ListByServer. +// ReplicasClientListByServerResponse contains the response from method ReplicasClient.NewListByServerPager. type ReplicasClientListByServerResponse struct { ServerListResult } -// ServerAdministratorsClientCreateOrUpdateResponse contains the response from method ServerAdministratorsClient.CreateOrUpdate. +// ServerAdministratorsClientCreateOrUpdateResponse contains the response from method ServerAdministratorsClient.BeginCreateOrUpdate. type ServerAdministratorsClientCreateOrUpdateResponse struct { ServerAdministratorResource } -// ServerAdministratorsClientDeleteResponse contains the response from method ServerAdministratorsClient.Delete. +// ServerAdministratorsClientDeleteResponse contains the response from method ServerAdministratorsClient.BeginDelete. type ServerAdministratorsClientDeleteResponse struct { // placeholder for future response values } @@ -193,22 +194,22 @@ type ServerAdministratorsClientGetResponse struct { ServerAdministratorResource } -// ServerAdministratorsClientListResponse contains the response from method ServerAdministratorsClient.List. +// ServerAdministratorsClientListResponse contains the response from method ServerAdministratorsClient.NewListPager. type ServerAdministratorsClientListResponse struct { ServerAdministratorResourceListResult } -// ServerBasedPerformanceTierClientListResponse contains the response from method ServerBasedPerformanceTierClient.List. +// ServerBasedPerformanceTierClientListResponse contains the response from method ServerBasedPerformanceTierClient.NewListPager. type ServerBasedPerformanceTierClientListResponse struct { PerformanceTierListResult } -// ServerKeysClientCreateOrUpdateResponse contains the response from method ServerKeysClient.CreateOrUpdate. +// ServerKeysClientCreateOrUpdateResponse contains the response from method ServerKeysClient.BeginCreateOrUpdate. type ServerKeysClientCreateOrUpdateResponse struct { ServerKey } -// ServerKeysClientDeleteResponse contains the response from method ServerKeysClient.Delete. +// ServerKeysClientDeleteResponse contains the response from method ServerKeysClient.BeginDelete. type ServerKeysClientDeleteResponse struct { // placeholder for future response values } @@ -218,17 +219,17 @@ type ServerKeysClientGetResponse struct { ServerKey } -// ServerKeysClientListResponse contains the response from method ServerKeysClient.List. +// ServerKeysClientListResponse contains the response from method ServerKeysClient.NewListPager. type ServerKeysClientListResponse struct { ServerKeyListResult } -// ServerParametersClientListUpdateConfigurationsResponse contains the response from method ServerParametersClient.ListUpdateConfigurations. +// ServerParametersClientListUpdateConfigurationsResponse contains the response from method ServerParametersClient.BeginListUpdateConfigurations. type ServerParametersClientListUpdateConfigurationsResponse struct { ConfigurationListResult } -// ServerSecurityAlertPoliciesClientCreateOrUpdateResponse contains the response from method ServerSecurityAlertPoliciesClient.CreateOrUpdate. +// ServerSecurityAlertPoliciesClientCreateOrUpdateResponse contains the response from method ServerSecurityAlertPoliciesClient.BeginCreateOrUpdate. type ServerSecurityAlertPoliciesClientCreateOrUpdateResponse struct { ServerSecurityAlertPolicy } @@ -238,17 +239,17 @@ type ServerSecurityAlertPoliciesClientGetResponse struct { ServerSecurityAlertPolicy } -// ServerSecurityAlertPoliciesClientListByServerResponse contains the response from method ServerSecurityAlertPoliciesClient.ListByServer. +// ServerSecurityAlertPoliciesClientListByServerResponse contains the response from method ServerSecurityAlertPoliciesClient.NewListByServerPager. type ServerSecurityAlertPoliciesClientListByServerResponse struct { ServerSecurityAlertPolicyListResult } -// ServersClientCreateResponse contains the response from method ServersClient.Create. +// ServersClientCreateResponse contains the response from method ServersClient.BeginCreate. type ServersClientCreateResponse struct { Server } -// ServersClientDeleteResponse contains the response from method ServersClient.Delete. +// ServersClientDeleteResponse contains the response from method ServersClient.BeginDelete. type ServersClientDeleteResponse struct { // placeholder for future response values } @@ -258,37 +259,37 @@ type ServersClientGetResponse struct { Server } -// ServersClientListByResourceGroupResponse contains the response from method ServersClient.ListByResourceGroup. +// ServersClientListByResourceGroupResponse contains the response from method ServersClient.NewListByResourceGroupPager. type ServersClientListByResourceGroupResponse struct { ServerListResult } -// ServersClientListResponse contains the response from method ServersClient.List. +// ServersClientListResponse contains the response from method ServersClient.NewListPager. type ServersClientListResponse struct { ServerListResult } -// ServersClientRestartResponse contains the response from method ServersClient.Restart. +// ServersClientRestartResponse contains the response from method ServersClient.BeginRestart. type ServersClientRestartResponse struct { // placeholder for future response values } -// ServersClientStartResponse contains the response from method ServersClient.Start. +// ServersClientStartResponse contains the response from method ServersClient.BeginStart. type ServersClientStartResponse struct { // placeholder for future response values } -// ServersClientStopResponse contains the response from method ServersClient.Stop. +// ServersClientStopResponse contains the response from method ServersClient.BeginStop. type ServersClientStopResponse struct { // placeholder for future response values } -// ServersClientUpdateResponse contains the response from method ServersClient.Update. +// ServersClientUpdateResponse contains the response from method ServersClient.BeginUpdate. type ServersClientUpdateResponse struct { Server } -// ServersClientUpgradeResponse contains the response from method ServersClient.Upgrade. +// ServersClientUpgradeResponse contains the response from method ServersClient.BeginUpgrade. type ServersClientUpgradeResponse struct { // placeholder for future response values } @@ -298,17 +299,17 @@ type TopQueryStatisticsClientGetResponse struct { QueryStatistic } -// TopQueryStatisticsClientListByServerResponse contains the response from method TopQueryStatisticsClient.ListByServer. +// TopQueryStatisticsClientListByServerResponse contains the response from method TopQueryStatisticsClient.NewListByServerPager. type TopQueryStatisticsClientListByServerResponse struct { TopQueryStatisticsResultList } -// VirtualNetworkRulesClientCreateOrUpdateResponse contains the response from method VirtualNetworkRulesClient.CreateOrUpdate. +// VirtualNetworkRulesClientCreateOrUpdateResponse contains the response from method VirtualNetworkRulesClient.BeginCreateOrUpdate. type VirtualNetworkRulesClientCreateOrUpdateResponse struct { VirtualNetworkRule } -// VirtualNetworkRulesClientDeleteResponse contains the response from method VirtualNetworkRulesClient.Delete. +// VirtualNetworkRulesClientDeleteResponse contains the response from method VirtualNetworkRulesClient.BeginDelete. type VirtualNetworkRulesClientDeleteResponse struct { // placeholder for future response values } @@ -318,7 +319,7 @@ type VirtualNetworkRulesClientGetResponse struct { VirtualNetworkRule } -// VirtualNetworkRulesClientListByServerResponse contains the response from method VirtualNetworkRulesClient.ListByServer. +// VirtualNetworkRulesClientListByServerResponse contains the response from method VirtualNetworkRulesClient.NewListByServerPager. type VirtualNetworkRulesClientListByServerResponse struct { VirtualNetworkRuleListResult } @@ -328,7 +329,7 @@ type WaitStatisticsClientGetResponse struct { WaitStatistic } -// WaitStatisticsClientListByServerResponse contains the response from method WaitStatisticsClient.ListByServer. +// WaitStatisticsClientListByServerResponse contains the response from method WaitStatisticsClient.NewListByServerPager. type WaitStatisticsClientListByServerResponse struct { WaitStatisticsResultList } diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_serveradministrators_client.go b/sdk/resourcemanager/mysql/armmysql/serveradministrators_client.go similarity index 83% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_serveradministrators_client.go rename to sdk/resourcemanager/mysql/armmysql/serveradministrators_client.go index 664069cd9b94..38b26a77a7bb 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_serveradministrators_client.go +++ b/sdk/resourcemanager/mysql/armmysql/serveradministrators_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,31 +24,22 @@ import ( // ServerAdministratorsClient contains the methods for the ServerAdministrators group. // Don't use this type directly, use NewServerAdministratorsClient() instead. type ServerAdministratorsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServerAdministratorsClient creates a new instance of ServerAdministratorsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServerAdministratorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServerAdministratorsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ServerAdministratorsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServerAdministratorsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -57,34 +47,36 @@ func NewServerAdministratorsClient(subscriptionID string, credential azcore.Toke // BeginCreateOrUpdate - Creates or update active directory administrator on an existing server. The update action will overwrite // the existing administrator. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// properties - The required parameters for creating or updating an AAD server administrator. -// options - ServerAdministratorsClientBeginCreateOrUpdateOptions contains the optional parameters for the ServerAdministratorsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - properties - The required parameters for creating or updating an AAD server administrator. +// - options - ServerAdministratorsClientBeginCreateOrUpdateOptions contains the optional parameters for the ServerAdministratorsClient.BeginCreateOrUpdate +// method. func (client *ServerAdministratorsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, properties ServerAdministratorResource, options *ServerAdministratorsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ServerAdministratorsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, serverName, properties, options) if err != nil { return nil, err } - return runtime.NewPoller[ServerAdministratorsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[ServerAdministratorsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServerAdministratorsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServerAdministratorsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or update active directory administrator on an existing server. The update action will overwrite // the existing administrator. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 func (client *ServerAdministratorsClient) createOrUpdate(ctx context.Context, resourceGroupName string, serverName string, properties ServerAdministratorResource, options *ServerAdministratorsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serverName, properties, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -109,7 +101,7 @@ func (client *ServerAdministratorsClient) createOrUpdateCreateRequest(ctx contex return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -122,32 +114,34 @@ func (client *ServerAdministratorsClient) createOrUpdateCreateRequest(ctx contex // BeginDelete - Deletes server active directory administrator. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServerAdministratorsClientBeginDeleteOptions contains the optional parameters for the ServerAdministratorsClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServerAdministratorsClientBeginDeleteOptions contains the optional parameters for the ServerAdministratorsClient.BeginDelete +// method. func (client *ServerAdministratorsClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, options *ServerAdministratorsClientBeginDeleteOptions) (*runtime.Poller[ServerAdministratorsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - return runtime.NewPoller[ServerAdministratorsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[ServerAdministratorsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServerAdministratorsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServerAdministratorsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes server active directory administrator. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 func (client *ServerAdministratorsClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, options *ServerAdministratorsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -172,7 +166,7 @@ func (client *ServerAdministratorsClient) deleteCreateRequest(ctx context.Contex return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -185,17 +179,18 @@ func (client *ServerAdministratorsClient) deleteCreateRequest(ctx context.Contex // Get - Gets information about a AAD server administrator. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServerAdministratorsClientGetOptions contains the optional parameters for the ServerAdministratorsClient.Get -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServerAdministratorsClientGetOptions contains the optional parameters for the ServerAdministratorsClient.Get +// method. func (client *ServerAdministratorsClient) Get(ctx context.Context, resourceGroupName string, serverName string, options *ServerAdministratorsClientGetOptions) (ServerAdministratorsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return ServerAdministratorsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServerAdministratorsClientGetResponse{}, err } @@ -220,7 +215,7 @@ func (client *ServerAdministratorsClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -241,12 +236,12 @@ func (client *ServerAdministratorsClient) getHandleResponse(resp *http.Response) } // NewListPager - Returns a list of server Administrators. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServerAdministratorsClientListOptions contains the optional parameters for the ServerAdministratorsClient.List -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServerAdministratorsClientListOptions contains the optional parameters for the ServerAdministratorsClient.NewListPager +// method. func (client *ServerAdministratorsClient) NewListPager(resourceGroupName string, serverName string, options *ServerAdministratorsClientListOptions) *runtime.Pager[ServerAdministratorsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ServerAdministratorsClientListResponse]{ More: func(page ServerAdministratorsClientListResponse) bool { @@ -257,7 +252,7 @@ func (client *ServerAdministratorsClient) NewListPager(resourceGroupName string, if err != nil { return ServerAdministratorsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServerAdministratorsClientListResponse{}, err } @@ -284,7 +279,7 @@ func (client *ServerAdministratorsClient) listCreateRequest(ctx context.Context, return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/serveradministrators_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/serveradministrators_client_example_test.go new file mode 100644 index 000000000000..ae8ffaa4078c --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/serveradministrators_client_example_test.go @@ -0,0 +1,152 @@ +//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 armmysql_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/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerAdminGet.json +func ExampleServerAdministratorsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServerAdministratorsClient().Get(ctx, "testrg", "mysqltestsvc4", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ServerAdministratorResource = armmysql.ServerAdministratorResource{ + // Name: to.Ptr("activeDirectory"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/administrators"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc4/administrators/activeDirectory"), + // Properties: &armmysql.ServerAdministratorProperties{ + // AdministratorType: to.Ptr("ActiveDirectory"), + // Login: to.Ptr("bob@contoso.com"), + // Sid: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + // TenantID: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerAdminCreateUpdate.json +func ExampleServerAdministratorsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServerAdministratorsClient().BeginCreateOrUpdate(ctx, "testrg", "mysqltestsvc4", armmysql.ServerAdministratorResource{ + Properties: &armmysql.ServerAdministratorProperties{ + AdministratorType: to.Ptr("ActiveDirectory"), + Login: to.Ptr("bob@contoso.com"), + Sid: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + TenantID: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ServerAdministratorResource = armmysql.ServerAdministratorResource{ + // Name: to.Ptr("activeDirectory"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/administrators"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc4/administrators/activeDirectory"), + // Properties: &armmysql.ServerAdministratorProperties{ + // AdministratorType: to.Ptr("ActiveDirectory"), + // Login: to.Ptr("bob@contoso.com"), + // Sid: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + // TenantID: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerAdminDelete.json +func ExampleServerAdministratorsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServerAdministratorsClient().BeginDelete(ctx, "testrg", "mysqltestsvc4", 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerAdminList.json +func ExampleServerAdministratorsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServerAdministratorsClient().NewListPager("testrg", "mysqltestsvc4", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ServerAdministratorResourceListResult = armmysql.ServerAdministratorResourceListResult{ + // Value: []*armmysql.ServerAdministratorResource{ + // { + // Name: to.Ptr("ActiveDirectory"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/administrators"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc4/administrators/activeDirectory"), + // Properties: &armmysql.ServerAdministratorProperties{ + // AdministratorType: to.Ptr("ActiveDirectory"), + // Login: to.Ptr("bob@contoso.com"), + // Sid: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + // TenantID: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_serverbasedperformancetier_client.go b/sdk/resourcemanager/mysql/armmysql/serverbasedperformancetier_client.go similarity index 78% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_serverbasedperformancetier_client.go rename to sdk/resourcemanager/mysql/armmysql/serverbasedperformancetier_client.go index 3e551481593f..158898cf2998 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_serverbasedperformancetier_client.go +++ b/sdk/resourcemanager/mysql/armmysql/serverbasedperformancetier_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,42 +24,33 @@ import ( // ServerBasedPerformanceTierClient contains the methods for the ServerBasedPerformanceTier group. // Don't use this type directly, use NewServerBasedPerformanceTierClient() instead. type ServerBasedPerformanceTierClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServerBasedPerformanceTierClient creates a new instance of ServerBasedPerformanceTierClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServerBasedPerformanceTierClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServerBasedPerformanceTierClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ServerBasedPerformanceTierClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServerBasedPerformanceTierClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - List all the performance tiers for a MySQL server. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServerBasedPerformanceTierClientListOptions contains the optional parameters for the ServerBasedPerformanceTierClient.List -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServerBasedPerformanceTierClientListOptions contains the optional parameters for the ServerBasedPerformanceTierClient.NewListPager +// method. func (client *ServerBasedPerformanceTierClient) NewListPager(resourceGroupName string, serverName string, options *ServerBasedPerformanceTierClientListOptions) *runtime.Pager[ServerBasedPerformanceTierClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ServerBasedPerformanceTierClientListResponse]{ More: func(page ServerBasedPerformanceTierClientListResponse) bool { @@ -71,7 +61,7 @@ func (client *ServerBasedPerformanceTierClient) NewListPager(resourceGroupName s if err != nil { return ServerBasedPerformanceTierClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServerBasedPerformanceTierClientListResponse{}, err } @@ -98,7 +88,7 @@ func (client *ServerBasedPerformanceTierClient) listCreateRequest(ctx context.Co return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/serverbasedperformancetier_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/serverbasedperformancetier_client_example_test.go new file mode 100644 index 000000000000..55bcb2464559 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/serverbasedperformancetier_client_example_test.go @@ -0,0 +1,206 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/PerformanceTiersListByServer.json +func ExampleServerBasedPerformanceTierClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServerBasedPerformanceTierClient().NewListPager("testrg", "mysqltestsvc1", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PerformanceTierListResult = armmysql.PerformanceTierListResult{ + // Value: []*armmysql.PerformanceTierProperties{ + // { + // ID: to.Ptr("Basic"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxLargeStorageMB: to.Ptr[int32](0), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinLargeStorageMB: to.Ptr[int32](0), + // MinStorageMB: to.Ptr[int32](5120), + // ServiceLevelObjectives: []*armmysql.PerformanceTierServiceLevelObjectives{ + // { + // Edition: to.Ptr("Basic"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("B_Gen5_1"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](1048576), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](1), + // }, + // { + // Edition: to.Ptr("Basic"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("B_Gen5_2"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](1048576), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](2), + // }}, + // }, + // { + // ID: to.Ptr("GeneralPurpose"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxLargeStorageMB: to.Ptr[int32](16777216), + // MaxStorageMB: to.Ptr[int32](16777216), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinLargeStorageMB: to.Ptr[int32](0), + // MinStorageMB: to.Ptr[int32](5120), + // ServiceLevelObjectives: []*armmysql.PerformanceTierServiceLevelObjectives{ + // { + // Edition: to.Ptr("GeneralPurpose"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("GP_Gen5_2"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](2), + // }, + // { + // Edition: to.Ptr("GeneralPurpose"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("GP_Gen5_4"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](4), + // }, + // { + // Edition: to.Ptr("GeneralPurpose"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("GP_Gen5_8"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](8), + // }, + // { + // Edition: to.Ptr("GeneralPurpose"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("GP_Gen5_16"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](16), + // }, + // { + // Edition: to.Ptr("GeneralPurpose"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("GP_Gen5_32"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](32), + // }, + // { + // Edition: to.Ptr("GeneralPurpose"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("GP_Gen5_64"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](32), + // }}, + // }, + // { + // ID: to.Ptr("MemoryOptimized"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxLargeStorageMB: to.Ptr[int32](16777216), + // MaxStorageMB: to.Ptr[int32](16777216), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinLargeStorageMB: to.Ptr[int32](0), + // MinStorageMB: to.Ptr[int32](5120), + // ServiceLevelObjectives: []*armmysql.PerformanceTierServiceLevelObjectives{ + // { + // Edition: to.Ptr("MemoryOptimized"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("MO_Gen5_2"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](2), + // }, + // { + // Edition: to.Ptr("MemoryOptimized"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("MO_Gen5_4"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](4), + // }, + // { + // Edition: to.Ptr("MemoryOptimized"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("MO_Gen5_8"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](8), + // }, + // { + // Edition: to.Ptr("MemoryOptimized"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("MO_Gen5_16"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](16), + // }, + // { + // Edition: to.Ptr("MemoryOptimized"), + // HardwareGeneration: to.Ptr("Gen5"), + // ID: to.Ptr("MO_Gen5_32"), + // MaxBackupRetentionDays: to.Ptr[int32](35), + // MaxStorageMB: to.Ptr[int32](2097152), + // MinBackupRetentionDays: to.Ptr[int32](7), + // MinStorageMB: to.Ptr[int32](5120), + // VCore: to.Ptr[int32](32), + // }}, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_serverkeys_client.go b/sdk/resourcemanager/mysql/armmysql/serverkeys_client.go similarity index 83% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_serverkeys_client.go rename to sdk/resourcemanager/mysql/armmysql/serverkeys_client.go index 31d59178b4fa..e20a3eb9f434 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_serverkeys_client.go +++ b/sdk/resourcemanager/mysql/armmysql/serverkeys_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,65 +24,58 @@ import ( // ServerKeysClient contains the methods for the ServerKeys group. // Don't use this type directly, use NewServerKeysClient() instead. type ServerKeysClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServerKeysClient creates a new instance of ServerKeysClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServerKeysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServerKeysClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ServerKeysClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServerKeysClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a MySQL Server key. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// serverName - The name of the server. -// keyName - The name of the MySQL Server key to be operated on (updated or created). -// resourceGroupName - The name of the resource group. The name is case insensitive. -// parameters - The requested MySQL Server key resource state. -// options - ServerKeysClientBeginCreateOrUpdateOptions contains the optional parameters for the ServerKeysClient.BeginCreateOrUpdate -// method. +// - serverName - The name of the server. +// - keyName - The name of the MySQL Server key to be operated on (updated or created). +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - parameters - The requested MySQL Server key resource state. +// - options - ServerKeysClientBeginCreateOrUpdateOptions contains the optional parameters for the ServerKeysClient.BeginCreateOrUpdate +// method. func (client *ServerKeysClient) BeginCreateOrUpdate(ctx context.Context, serverName string, keyName string, resourceGroupName string, parameters ServerKey, options *ServerKeysClientBeginCreateOrUpdateOptions) (*runtime.Poller[ServerKeysClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, serverName, keyName, resourceGroupName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[ServerKeysClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[ServerKeysClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServerKeysClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServerKeysClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a MySQL Server key. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 func (client *ServerKeysClient) createOrUpdate(ctx context.Context, serverName string, keyName string, resourceGroupName string, parameters ServerKey, options *ServerKeysClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, serverName, keyName, resourceGroupName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -112,7 +104,7 @@ func (client *ServerKeysClient) createOrUpdateCreateRequest(ctx context.Context, return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -125,32 +117,34 @@ func (client *ServerKeysClient) createOrUpdateCreateRequest(ctx context.Context, // BeginDelete - Deletes the MySQL Server key with the given name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// serverName - The name of the server. -// keyName - The name of the MySQL Server key to be deleted. -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - ServerKeysClientBeginDeleteOptions contains the optional parameters for the ServerKeysClient.BeginDelete method. +// - serverName - The name of the server. +// - keyName - The name of the MySQL Server key to be deleted. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ServerKeysClientBeginDeleteOptions contains the optional parameters for the ServerKeysClient.BeginDelete method. func (client *ServerKeysClient) BeginDelete(ctx context.Context, serverName string, keyName string, resourceGroupName string, options *ServerKeysClientBeginDeleteOptions) (*runtime.Poller[ServerKeysClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, serverName, keyName, resourceGroupName, options) if err != nil { return nil, err } - return runtime.NewPoller[ServerKeysClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[ServerKeysClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServerKeysClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServerKeysClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the MySQL Server key with the given name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 func (client *ServerKeysClient) deleteOperation(ctx context.Context, serverName string, keyName string, resourceGroupName string, options *ServerKeysClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, serverName, keyName, resourceGroupName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -179,7 +173,7 @@ func (client *ServerKeysClient) deleteCreateRequest(ctx context.Context, serverN return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -192,17 +186,18 @@ func (client *ServerKeysClient) deleteCreateRequest(ctx context.Context, serverN // Get - Gets a MySQL Server key. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// keyName - The name of the MySQL Server key to be retrieved. -// options - ServerKeysClientGetOptions contains the optional parameters for the ServerKeysClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - keyName - The name of the MySQL Server key to be retrieved. +// - options - ServerKeysClientGetOptions contains the optional parameters for the ServerKeysClient.Get method. func (client *ServerKeysClient) Get(ctx context.Context, resourceGroupName string, serverName string, keyName string, options *ServerKeysClientGetOptions) (ServerKeysClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, keyName, options) if err != nil { return ServerKeysClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServerKeysClientGetResponse{}, err } @@ -231,7 +226,7 @@ func (client *ServerKeysClient) getCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -252,11 +247,11 @@ func (client *ServerKeysClient) getHandleResponse(resp *http.Response) (ServerKe } // NewListPager - Gets a list of Server keys. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServerKeysClientListOptions contains the optional parameters for the ServerKeysClient.List method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServerKeysClientListOptions contains the optional parameters for the ServerKeysClient.NewListPager method. func (client *ServerKeysClient) NewListPager(resourceGroupName string, serverName string, options *ServerKeysClientListOptions) *runtime.Pager[ServerKeysClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ServerKeysClientListResponse]{ More: func(page ServerKeysClientListResponse) bool { @@ -273,7 +268,7 @@ func (client *ServerKeysClient) NewListPager(resourceGroupName string, serverNam if err != nil { return ServerKeysClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServerKeysClientListResponse{}, err } @@ -300,7 +295,7 @@ func (client *ServerKeysClient) listCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/serverkeys_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/serverkeys_client_example_test.go new file mode 100644 index 000000000000..08bd1b9314a2 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/serverkeys_client_example_test.go @@ -0,0 +1,150 @@ +//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 armmysql_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/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2020-01-01/examples/ServerKeyList.json +func ExampleServerKeysClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServerKeysClient().NewListPager("testrg", "testserver", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ServerKeyListResult = armmysql.ServerKeyListResult{ + // Value: []*armmysql.ServerKey{ + // { + // Name: to.Ptr("someVault_someKey_01234567890123456789012345678901"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/keys"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/testserver/keys/someVault_someKey_01234567890123456789012345678901"), + // Kind: to.Ptr("azurekeyvault"), + // Properties: &armmysql.ServerKeyProperties{ + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00.0Z"); return t}()), + // ServerKeyType: to.Ptr(armmysql.ServerKeyTypeAzureKeyVault), + // URI: to.Ptr("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2020-01-01/examples/ServerKeyGet.json +func ExampleServerKeysClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServerKeysClient().Get(ctx, "testrg", "testserver", "someVault_someKey_01234567890123456789012345678901", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ServerKey = armmysql.ServerKey{ + // Name: to.Ptr("someVault_someKey_01234567890123456789012345678901"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/keys"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/testserver/keys/someVault_someKey_01234567890123456789012345678901"), + // Kind: to.Ptr("azurekeyvault"), + // Properties: &armmysql.ServerKeyProperties{ + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00.0Z"); return t}()), + // ServerKeyType: to.Ptr(armmysql.ServerKeyTypeAzureKeyVault), + // URI: to.Ptr("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2020-01-01/examples/ServerKeyCreateOrUpdate.json +func ExampleServerKeysClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServerKeysClient().BeginCreateOrUpdate(ctx, "testserver", "someVault_someKey_01234567890123456789012345678901", "testrg", armmysql.ServerKey{ + Properties: &armmysql.ServerKeyProperties{ + ServerKeyType: to.Ptr(armmysql.ServerKeyTypeAzureKeyVault), + URI: to.Ptr("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ServerKey = armmysql.ServerKey{ + // Name: to.Ptr("omeVault_someKey_01234567890123456789012345678901"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/keys"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/testserver/keys/someVault_someKey_01234567890123456789012345678901"), + // Kind: to.Ptr("azurekeyvault"), + // Properties: &armmysql.ServerKeyProperties{ + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-01T00:00:00.0Z"); return t}()), + // ServerKeyType: to.Ptr(armmysql.ServerKeyTypeAzureKeyVault), + // URI: to.Ptr("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2020-01-01/examples/ServerKeyDelete.json +func ExampleServerKeysClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServerKeysClient().BeginDelete(ctx, "testserver", "someVault_someKey_01234567890123456789012345678901", "testrg", 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) + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_serverparameters_client.go b/sdk/resourcemanager/mysql/armmysql/serverparameters_client.go similarity index 75% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_serverparameters_client.go rename to sdk/resourcemanager/mysql/armmysql/serverparameters_client.go index 625dd337655e..876c8966153b 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_serverparameters_client.go +++ b/sdk/resourcemanager/mysql/armmysql/serverparameters_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,66 +24,59 @@ import ( // ServerParametersClient contains the methods for the ServerParameters group. // Don't use this type directly, use NewServerParametersClient() instead. type ServerParametersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServerParametersClient creates a new instance of ServerParametersClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServerParametersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServerParametersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ServerParametersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServerParametersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginListUpdateConfigurations - Update a list of configurations in a given server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// value - The parameters for updating a list of server configuration. -// options - ServerParametersClientBeginListUpdateConfigurationsOptions contains the optional parameters for the ServerParametersClient.BeginListUpdateConfigurations -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - value - The parameters for updating a list of server configuration. +// - options - ServerParametersClientBeginListUpdateConfigurationsOptions contains the optional parameters for the ServerParametersClient.BeginListUpdateConfigurations +// method. func (client *ServerParametersClient) BeginListUpdateConfigurations(ctx context.Context, resourceGroupName string, serverName string, value ConfigurationListResult, options *ServerParametersClientBeginListUpdateConfigurationsOptions) (*runtime.Poller[ServerParametersClientListUpdateConfigurationsResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.listUpdateConfigurations(ctx, resourceGroupName, serverName, value, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ServerParametersClientListUpdateConfigurationsResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ServerParametersClientListUpdateConfigurationsResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[ServerParametersClientListUpdateConfigurationsResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServerParametersClientListUpdateConfigurationsResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // ListUpdateConfigurations - Update a list of configurations in a given server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 func (client *ServerParametersClient) listUpdateConfigurations(ctx context.Context, resourceGroupName string, serverName string, value ConfigurationListResult, options *ServerParametersClientBeginListUpdateConfigurationsOptions) (*http.Response, error) { req, err := client.listUpdateConfigurationsCreateRequest(ctx, resourceGroupName, serverName, value, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -109,7 +101,7 @@ func (client *ServerParametersClient) listUpdateConfigurationsCreateRequest(ctx return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/serverparameters_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/serverparameters_client_example_test.go new file mode 100644 index 000000000000..aab222538142 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/serverparameters_client_example_test.go @@ -0,0 +1,71 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ConfigurationsUpdateByServer.json +func ExampleServerParametersClient_BeginListUpdateConfigurations() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServerParametersClient().BeginListUpdateConfigurations(ctx, "testrg", "mysqltestsvc1", armmysql.ConfigurationListResult{}, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ConfigurationListResult = armmysql.ConfigurationListResult{ + // Value: []*armmysql.Configuration{ + // { + // Name: to.Ptr("event_scheduler"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/event_scheduler"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Indicates the status of the Event Scheduler."), + // AllowedValues: to.Ptr("ON,OFF,DISABLED"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("OFF"), + // }, + // }, + // { + // Name: to.Ptr("div_precision_increment"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1/configurations/div_precision_increment"), + // Properties: &armmysql.ConfigurationProperties{ + // Description: to.Ptr("Number of digits by which to increase the scale of the result of division operations."), + // AllowedValues: to.Ptr("0-30"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("4"), + // Source: to.Ptr("system-default"), + // Value: to.Ptr("4"), + // }, + // }}, + // } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_servers_client.go b/sdk/resourcemanager/mysql/armmysql/servers_client.go similarity index 85% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_servers_client.go rename to sdk/resourcemanager/mysql/armmysql/servers_client.go index c69f72ad5be6..b551304d0a9f 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_servers_client.go +++ b/sdk/resourcemanager/mysql/armmysql/servers_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,63 +24,56 @@ import ( // ServersClient contains the methods for the Servers group. // Don't use this type directly, use NewServersClient() instead. type ServersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServersClient creates a new instance of ServersClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ServersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Creates a new server or updates an existing server. The update action will overwrite the existing server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// parameters - The required parameters for creating or updating a server. -// options - ServersClientBeginCreateOptions contains the optional parameters for the ServersClient.BeginCreate method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - parameters - The required parameters for creating or updating a server. +// - options - ServersClientBeginCreateOptions contains the optional parameters for the ServersClient.BeginCreate method. func (client *ServersClient) BeginCreate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForCreate, options *ServersClientBeginCreateOptions) (*runtime.Poller[ServersClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[ServersClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[ServersClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServersClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Creates a new server or updates an existing server. The update action will overwrite the existing server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 func (client *ServersClient) create(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForCreate, options *ServersClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -106,7 +98,7 @@ func (client *ServersClient) createCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -119,31 +111,33 @@ func (client *ServersClient) createCreateRequest(ctx context.Context, resourceGr // BeginDelete - Deletes a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServersClientBeginDeleteOptions contains the optional parameters for the ServersClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServersClientBeginDeleteOptions contains the optional parameters for the ServersClient.BeginDelete method. func (client *ServersClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginDeleteOptions) (*runtime.Poller[ServersClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - return runtime.NewPoller[ServersClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[ServersClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServersClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 func (client *ServersClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -168,7 +162,7 @@ func (client *ServersClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -181,16 +175,17 @@ func (client *ServersClient) deleteCreateRequest(ctx context.Context, resourceGr // Get - Gets information about a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServersClientGetOptions contains the optional parameters for the ServersClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServersClientGetOptions contains the optional parameters for the ServersClient.Get method. func (client *ServersClient) Get(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientGetOptions) (ServersClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return ServersClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientGetResponse{}, err } @@ -215,7 +210,7 @@ func (client *ServersClient) getCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -236,9 +231,9 @@ func (client *ServersClient) getHandleResponse(resp *http.Response) (ServersClie } // NewListPager - List all the servers in a given subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// options - ServersClientListOptions contains the optional parameters for the ServersClient.List method. +// - options - ServersClientListOptions contains the optional parameters for the ServersClient.NewListPager method. func (client *ServersClient) NewListPager(options *ServersClientListOptions) *runtime.Pager[ServersClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ServersClientListResponse]{ More: func(page ServersClientListResponse) bool { @@ -249,7 +244,7 @@ func (client *ServersClient) NewListPager(options *ServersClientListOptions) *ru if err != nil { return ServersClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientListResponse{}, err } @@ -268,7 +263,7 @@ func (client *ServersClient) listCreateRequest(ctx context.Context, options *Ser return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -289,11 +284,11 @@ func (client *ServersClient) listHandleResponse(resp *http.Response) (ServersCli } // NewListByResourceGroupPager - List all the servers in a given resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.NewListByResourceGroupPager +// method. func (client *ServersClient) NewListByResourceGroupPager(resourceGroupName string, options *ServersClientListByResourceGroupOptions) *runtime.Pager[ServersClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[ServersClientListByResourceGroupResponse]{ More: func(page ServersClientListByResourceGroupResponse) bool { @@ -304,7 +299,7 @@ func (client *ServersClient) NewListByResourceGroupPager(resourceGroupName strin if err != nil { return ServersClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientListByResourceGroupResponse{}, err } @@ -327,7 +322,7 @@ func (client *ServersClient) listByResourceGroupCreateRequest(ctx context.Contex return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -349,31 +344,33 @@ func (client *ServersClient) listByResourceGroupHandleResponse(resp *http.Respon // BeginRestart - Restarts a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServersClientBeginRestartOptions contains the optional parameters for the ServersClient.BeginRestart method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServersClientBeginRestartOptions contains the optional parameters for the ServersClient.BeginRestart method. func (client *ServersClient) BeginRestart(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginRestartOptions) (*runtime.Poller[ServersClientRestartResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.restart(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - return runtime.NewPoller[ServersClientRestartResponse](resp, client.pl, nil) + return runtime.NewPoller[ServersClientRestartResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServersClientRestartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientRestartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Restart - Restarts a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 func (client *ServersClient) restart(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginRestartOptions) (*http.Response, error) { req, err := client.restartCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -398,7 +395,7 @@ func (client *ServersClient) restartCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -411,31 +408,33 @@ func (client *ServersClient) restartCreateRequest(ctx context.Context, resourceG // BeginStart - Starts a stopped server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServersClientBeginStartOptions contains the optional parameters for the ServersClient.BeginStart method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServersClientBeginStartOptions contains the optional parameters for the ServersClient.BeginStart method. func (client *ServersClient) BeginStart(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginStartOptions) (*runtime.Poller[ServersClientStartResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.start(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - return runtime.NewPoller[ServersClientStartResponse](resp, client.pl, nil) + return runtime.NewPoller[ServersClientStartResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServersClientStartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Start - Starts a stopped server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 func (client *ServersClient) start(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginStartOptions) (*http.Response, error) { req, err := client.startCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -460,7 +459,7 @@ func (client *ServersClient) startCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -473,31 +472,33 @@ func (client *ServersClient) startCreateRequest(ctx context.Context, resourceGro // BeginStop - Stops a running server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServersClientBeginStopOptions contains the optional parameters for the ServersClient.BeginStop method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServersClientBeginStopOptions contains the optional parameters for the ServersClient.BeginStop method. func (client *ServersClient) BeginStop(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginStopOptions) (*runtime.Poller[ServersClientStopResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.stop(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - return runtime.NewPoller[ServersClientStopResponse](resp, client.pl, nil) + return runtime.NewPoller[ServersClientStopResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServersClientStopResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Stop - Stops a running server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 func (client *ServersClient) stop(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginStopOptions) (*http.Response, error) { req, err := client.stopCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -522,7 +523,7 @@ func (client *ServersClient) stopCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -536,33 +537,35 @@ func (client *ServersClient) stopCreateRequest(ctx context.Context, resourceGrou // BeginUpdate - Updates an existing server. The request body can contain one to many of the properties present in the normal // server definition. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// parameters - The required parameters for updating a server. -// options - ServersClientBeginUpdateOptions contains the optional parameters for the ServersClient.BeginUpdate method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - parameters - The required parameters for updating a server. +// - options - ServersClientBeginUpdateOptions contains the optional parameters for the ServersClient.BeginUpdate method. func (client *ServersClient) BeginUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerUpdateParameters, options *ServersClientBeginUpdateOptions) (*runtime.Poller[ServersClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[ServersClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[ServersClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServersClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates an existing server. The request body can contain one to many of the properties present in the normal server // definition. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 func (client *ServersClient) update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerUpdateParameters, options *ServersClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -587,7 +590,7 @@ func (client *ServersClient) updateCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -600,32 +603,34 @@ func (client *ServersClient) updateCreateRequest(ctx context.Context, resourceGr // BeginUpgrade - Upgrade server version. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// parameters - The required parameters for updating a server. -// options - ServersClientBeginUpgradeOptions contains the optional parameters for the ServersClient.BeginUpgrade method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - parameters - The required parameters for updating a server. +// - options - ServersClientBeginUpgradeOptions contains the optional parameters for the ServersClient.BeginUpgrade method. func (client *ServersClient) BeginUpgrade(ctx context.Context, resourceGroupName string, serverName string, parameters ServerUpgradeParameters, options *ServersClientBeginUpgradeOptions) (*runtime.Poller[ServersClientUpgradeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.upgrade(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[ServersClientUpgradeResponse](resp, client.pl, nil) + return runtime.NewPoller[ServersClientUpgradeResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServersClientUpgradeResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientUpgradeResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Upgrade - Upgrade server version. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 func (client *ServersClient) upgrade(ctx context.Context, resourceGroupName string, serverName string, parameters ServerUpgradeParameters, options *ServersClientBeginUpgradeOptions) (*http.Response, error) { req, err := client.upgradeCreateRequest(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -650,7 +655,7 @@ func (client *ServersClient) upgradeCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/servers_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/servers_client_example_test.go new file mode 100644 index 000000000000..9dd68af9b8a6 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/servers_client_example_test.go @@ -0,0 +1,759 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "time" + + "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/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerCreatePointInTimeRestore.json +func ExampleServersClient_BeginCreate_createADatabaseAsAPointInTimeRestore() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginCreate(ctx, "TargetResourceGroup", "targetserver", armmysql.ServerForCreate{ + Location: to.Ptr("brazilsouth"), + Properties: &armmysql.ServerPropertiesForRestore{ + CreateMode: to.Ptr(armmysql.CreateModePointInTimeRestore), + RestorePointInTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-12-14T00:00:37.467Z"); return t }()), + SourceServerID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/servers/sourceserver"), + }, + SKU: &armmysql.SKU{ + Name: to.Ptr("GP_Gen5_2"), + Capacity: to.Ptr[int32](2), + Family: to.Ptr("Gen5"), + Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), + }, + Tags: map[string]*string{ + "ElasticServer": to.Ptr("1"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Server = armmysql.Server{ + // Name: to.Ptr("targetserver"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/targetserver"), + // Location: to.Ptr("brazilsouth"), + // Tags: map[string]*string{ + // "elasticServer": to.Ptr("1"), + // }, + // Properties: &armmysql.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-14T18:02:41.577+00:00"); return t}()), + // FullyQualifiedDomainName: to.Ptr("targetserver.mysql.database.azure.com"), + // SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumEnabled), + // StorageProfile: &armmysql.StorageProfile{ + // BackupRetentionDays: to.Ptr[int32](7), + // GeoRedundantBackup: to.Ptr(armmysql.GeoRedundantBackupEnabled), + // StorageMB: to.Ptr[int32](128000), + // }, + // UserVisibleState: to.Ptr(armmysql.ServerStateReady), + // Version: to.Ptr(armmysql.ServerVersionFive7), + // }, + // SKU: &armmysql.SKU{ + // Name: to.Ptr("GP_Gen5_2"), + // Capacity: to.Ptr[int32](2), + // Family: to.Ptr("Gen5"), + // Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerCreate.json +func ExampleServersClient_BeginCreate_createANewServer() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginCreate(ctx, "testrg", "mysqltestsvc4", armmysql.ServerForCreate{ + Location: to.Ptr("westus"), + Properties: &armmysql.ServerPropertiesForDefaultCreate{ + CreateMode: to.Ptr(armmysql.CreateModeDefault), + SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumEnabled), + StorageProfile: &armmysql.StorageProfile{ + BackupRetentionDays: to.Ptr[int32](7), + GeoRedundantBackup: to.Ptr(armmysql.GeoRedundantBackupEnabled), + StorageMB: to.Ptr[int32](128000), + }, + AdministratorLogin: to.Ptr("cloudsa"), + AdministratorLoginPassword: to.Ptr(""), + }, + SKU: &armmysql.SKU{ + Name: to.Ptr("GP_Gen5_2"), + Capacity: to.Ptr[int32](2), + Family: to.Ptr("Gen5"), + Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), + }, + Tags: map[string]*string{ + "ElasticServer": to.Ptr("1"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Server = armmysql.Server{ + // Name: to.Ptr("mysqltestsvc4"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc4"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "elasticServer": to.Ptr("1"), + // }, + // Properties: &armmysql.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-14T18:02:41.577+00:00"); return t}()), + // FullyQualifiedDomainName: to.Ptr("mysqltestsvc4.mysql.database.azure.com"), + // SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumEnabled), + // StorageProfile: &armmysql.StorageProfile{ + // BackupRetentionDays: to.Ptr[int32](7), + // GeoRedundantBackup: to.Ptr(armmysql.GeoRedundantBackupEnabled), + // StorageMB: to.Ptr[int32](128000), + // }, + // UserVisibleState: to.Ptr(armmysql.ServerStateReady), + // Version: to.Ptr(armmysql.ServerVersionFive7), + // }, + // SKU: &armmysql.SKU{ + // Name: to.Ptr("GP_Gen5_2"), + // Capacity: to.Ptr[int32](2), + // Family: to.Ptr("Gen5"), + // Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerCreateReplicaMode.json +func ExampleServersClient_BeginCreate_createAReplicaServer() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginCreate(ctx, "TargetResourceGroup", "targetserver", armmysql.ServerForCreate{ + Location: to.Ptr("westus"), + Properties: &armmysql.ServerPropertiesForReplica{ + CreateMode: to.Ptr(armmysql.CreateModeReplica), + SourceServerID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/MasterResourceGroup/providers/Microsoft.DBforMySQL/servers/masterserver"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Server = armmysql.Server{ + // Name: to.Ptr("targetserver"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TargetResourceGroup/providers/Microsoft.DBforMySQL/servers/targetserver"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "ElasticServer": to.Ptr("1"), + // }, + // Properties: &armmysql.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-14T18:02:41.577+00:00"); return t}()), + // FullyQualifiedDomainName: to.Ptr("targetserver.mysql.database.azure.com"), + // MasterServerID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/MasterResourceGroup/providers/Microsoft.DBforMySQL/servers/masterserver"), + // ReplicaCapacity: to.Ptr[int32](0), + // ReplicationRole: to.Ptr("Replica"), + // SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumEnabled), + // StorageProfile: &armmysql.StorageProfile{ + // BackupRetentionDays: to.Ptr[int32](14), + // GeoRedundantBackup: to.Ptr(armmysql.GeoRedundantBackupEnabled), + // StorageMB: to.Ptr[int32](128000), + // }, + // UserVisibleState: to.Ptr(armmysql.ServerStateReady), + // Version: to.Ptr(armmysql.ServerVersionFive7), + // }, + // SKU: &armmysql.SKU{ + // Name: to.Ptr("GP_Gen5_2"), + // Capacity: to.Ptr[int32](2), + // Family: to.Ptr("Gen5"), + // Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerCreateGeoRestoreMode.json +func ExampleServersClient_BeginCreate_createAServerAsAGeoRestore() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginCreate(ctx, "TargetResourceGroup", "targetserver", armmysql.ServerForCreate{ + Location: to.Ptr("westus"), + Properties: &armmysql.ServerPropertiesForGeoRestore{ + CreateMode: to.Ptr(armmysql.CreateModeGeoRestore), + SourceServerID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/servers/sourceserver"), + }, + SKU: &armmysql.SKU{ + Name: to.Ptr("GP_Gen5_2"), + Capacity: to.Ptr[int32](2), + Family: to.Ptr("Gen5"), + Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), + }, + Tags: map[string]*string{ + "ElasticServer": to.Ptr("1"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Server = armmysql.Server{ + // Name: to.Ptr("targetserver"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/targetserver"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "elasticServer": to.Ptr("1"), + // }, + // Properties: &armmysql.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-14T18:02:41.577+00:00"); return t}()), + // FullyQualifiedDomainName: to.Ptr("targetserver.mysql.database.azure.com"), + // SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumEnabled), + // StorageProfile: &armmysql.StorageProfile{ + // BackupRetentionDays: to.Ptr[int32](14), + // GeoRedundantBackup: to.Ptr(armmysql.GeoRedundantBackupEnabled), + // StorageMB: to.Ptr[int32](128000), + // }, + // UserVisibleState: to.Ptr(armmysql.ServerStateReady), + // Version: to.Ptr(armmysql.ServerVersionFive7), + // }, + // SKU: &armmysql.SKU{ + // Name: to.Ptr("GP_Gen5_2"), + // Capacity: to.Ptr[int32](2), + // Family: to.Ptr("Gen5"), + // Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerUpdate.json +func ExampleServersClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginUpdate(ctx, "testrg", "mysqltestsvc4", armmysql.ServerUpdateParameters{ + Properties: &armmysql.ServerUpdateParametersProperties{ + AdministratorLoginPassword: to.Ptr(""), + SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumDisabled), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Server = armmysql.Server{ + // Name: to.Ptr("mysqltestsvc4"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc4"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "ElasticServer": to.Ptr("1"), + // }, + // Properties: &armmysql.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-14T18:02:41.577+00:00"); return t}()), + // FullyQualifiedDomainName: to.Ptr("mysqltestsvc4.mysql.database.azure.com"), + // SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumDisabled), + // StorageProfile: &armmysql.StorageProfile{ + // BackupRetentionDays: to.Ptr[int32](7), + // GeoRedundantBackup: to.Ptr(armmysql.GeoRedundantBackupEnabled), + // StorageMB: to.Ptr[int32](128000), + // }, + // UserVisibleState: to.Ptr(armmysql.ServerStateReady), + // Version: to.Ptr(armmysql.ServerVersionFive7), + // }, + // SKU: &armmysql.SKU{ + // Name: to.Ptr("GP_Gen4_2"), + // Capacity: to.Ptr[int32](2), + // Family: to.Ptr("Gen4"), + // Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerDelete.json +func ExampleServersClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginDelete(ctx, "TestGroup", "testserver", 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerGet.json +func ExampleServersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServersClient().Get(ctx, "testrg", "mysqltestsvc4", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Server = armmysql.Server{ + // Name: to.Ptr("mysqltestsvc4"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc4"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "ElasticServer": to.Ptr("1"), + // }, + // Properties: &armmysql.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-14T18:02:41.577+00:00"); return t}()), + // FullyQualifiedDomainName: to.Ptr("mysqltestsvc4.mysql.database.azure.com"), + // MasterServerID: to.Ptr(""), + // PrivateEndpointConnections: []*armmysql.ServerPrivateEndpointConnection{ + // { + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc4/privateEndpointConnections/private-endpoint-name-00000000-1111-2222-3333-444444444444"), + // Properties: &armmysql.ServerPrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmysql.PrivateEndpointProperty{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/Default-Network/providers/Microsoft.Network/privateEndpoints/private-endpoint-name"), + // }, + // PrivateLinkServiceConnectionState: &armmysql.ServerPrivateLinkServiceConnectionStateProperty{ + // Description: to.Ptr("Auto-approved"), + // ActionsRequired: to.Ptr(armmysql.PrivateLinkServiceConnectionStateActionsRequireNone), + // Status: to.Ptr(armmysql.PrivateLinkServiceConnectionStateStatusApproved), + // }, + // ProvisioningState: to.Ptr(armmysql.PrivateEndpointProvisioningState("Succeeded")), + // }, + // }}, + // PublicNetworkAccess: to.Ptr(armmysql.PublicNetworkAccessEnumEnabled), + // ReplicaCapacity: to.Ptr[int32](5), + // ReplicationRole: to.Ptr("None"), + // SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumEnabled), + // StorageProfile: &armmysql.StorageProfile{ + // BackupRetentionDays: to.Ptr[int32](7), + // GeoRedundantBackup: to.Ptr(armmysql.GeoRedundantBackupEnabled), + // StorageMB: to.Ptr[int32](128000), + // }, + // UserVisibleState: to.Ptr(armmysql.ServerStateReady), + // Version: to.Ptr(armmysql.ServerVersionFive7), + // }, + // SKU: &armmysql.SKU{ + // Name: to.Ptr("GP_Gen4_2"), + // Capacity: to.Ptr[int32](2), + // Family: to.Ptr("Gen4"), + // Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerListByResourceGroup.json +func ExampleServersClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServersClient().NewListByResourceGroupPager("testrg", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ServerListResult = armmysql.ServerListResult{ + // Value: []*armmysql.Server{ + // { + // Name: to.Ptr("mysqltestsvc1"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1"), + // Location: to.Ptr("westus"), + // Properties: &armmysql.ServerProperties{ + // AdministratorLogin: to.Ptr("testuser"), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-07T18:17:35.729321+00:00"); return t}()), + // FullyQualifiedDomainName: to.Ptr("mysqltestsvc1.mysql.database.azure.com"), + // PrivateEndpointConnections: []*armmysql.ServerPrivateEndpointConnection{ + // }, + // PublicNetworkAccess: to.Ptr(armmysql.PublicNetworkAccessEnumEnabled), + // SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumEnabled), + // StorageProfile: &armmysql.StorageProfile{ + // BackupRetentionDays: to.Ptr[int32](7), + // GeoRedundantBackup: to.Ptr(armmysql.GeoRedundantBackupDisabled), + // StorageMB: to.Ptr[int32](5120), + // }, + // UserVisibleState: to.Ptr(armmysql.ServerStateReady), + // Version: to.Ptr(armmysql.ServerVersionFive7), + // }, + // SKU: &armmysql.SKU{ + // Name: to.Ptr("B_Gen4_1"), + // Capacity: to.Ptr[int32](1), + // Family: to.Ptr("Gen4"), + // Tier: to.Ptr(armmysql.SKUTierBasic), + // }, + // }, + // { + // Name: to.Ptr("mysqltstsvc2"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltstsvc2"), + // Location: to.Ptr("westus"), + // Properties: &armmysql.ServerProperties{ + // AdministratorLogin: to.Ptr("testuser"), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-07T18:17:35.729321+00:00"); return t}()), + // FullyQualifiedDomainName: to.Ptr("mysqltstsvc2.mysql.database.azure.com"), + // PrivateEndpointConnections: []*armmysql.ServerPrivateEndpointConnection{ + // { + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltstsvc2/privateEndpointConnections/private-endpoint-name-00000000-1111-2222-3333-444444444444"), + // Properties: &armmysql.ServerPrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmysql.PrivateEndpointProperty{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/Default-Network/providers/Microsoft.Network/privateEndpoints/private-endpoint-name"), + // }, + // PrivateLinkServiceConnectionState: &armmysql.ServerPrivateLinkServiceConnectionStateProperty{ + // Description: to.Ptr("Auto-approved"), + // ActionsRequired: to.Ptr(armmysql.PrivateLinkServiceConnectionStateActionsRequireNone), + // Status: to.Ptr(armmysql.PrivateLinkServiceConnectionStateStatusApproved), + // }, + // ProvisioningState: to.Ptr(armmysql.PrivateEndpointProvisioningState("Succeeded")), + // }, + // }}, + // PublicNetworkAccess: to.Ptr(armmysql.PublicNetworkAccessEnumEnabled), + // SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumEnabled), + // StorageProfile: &armmysql.StorageProfile{ + // BackupRetentionDays: to.Ptr[int32](7), + // GeoRedundantBackup: to.Ptr(armmysql.GeoRedundantBackupDisabled), + // StorageMB: to.Ptr[int32](5120), + // }, + // UserVisibleState: to.Ptr(armmysql.ServerStateReady), + // Version: to.Ptr(armmysql.ServerVersionFive7), + // }, + // SKU: &armmysql.SKU{ + // Name: to.Ptr("GP_Gen4_2"), + // Capacity: to.Ptr[int32](2), + // Family: to.Ptr("Gen4"), + // Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerList.json +func ExampleServersClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServersClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ServerListResult = armmysql.ServerListResult{ + // Value: []*armmysql.Server{ + // { + // Name: to.Ptr("mysqltestsvc1"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc1"), + // Location: to.Ptr("westus"), + // Properties: &armmysql.ServerProperties{ + // AdministratorLogin: to.Ptr("testuser"), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-28T23:56:02.627+00:00"); return t}()), + // FullyQualifiedDomainName: to.Ptr("mysqltestsvc1.mysql.database.azure.com"), + // PrivateEndpointConnections: []*armmysql.ServerPrivateEndpointConnection{ + // }, + // PublicNetworkAccess: to.Ptr(armmysql.PublicNetworkAccessEnumEnabled), + // SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumEnabled), + // StorageProfile: &armmysql.StorageProfile{ + // BackupRetentionDays: to.Ptr[int32](7), + // GeoRedundantBackup: to.Ptr(armmysql.GeoRedundantBackupDisabled), + // StorageMB: to.Ptr[int32](5120), + // }, + // UserVisibleState: to.Ptr(armmysql.ServerStateReady), + // Version: to.Ptr(armmysql.ServerVersionFive7), + // }, + // SKU: &armmysql.SKU{ + // Name: to.Ptr("B_Gen4_2"), + // Capacity: to.Ptr[int32](2), + // Family: to.Ptr("Gen4"), + // Tier: to.Ptr(armmysql.SKUTierBasic), + // }, + // }, + // { + // Name: to.Ptr("mysqltstsvc2"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltstsvc2"), + // Location: to.Ptr("westus"), + // Properties: &armmysql.ServerProperties{ + // AdministratorLogin: to.Ptr("testuser"), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-28T23:56:54.3+00:00"); return t}()), + // FullyQualifiedDomainName: to.Ptr("mysqltstsvc2.mysql.database.azure.com"), + // PrivateEndpointConnections: []*armmysql.ServerPrivateEndpointConnection{ + // { + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltstsvc2/privateEndpointConnections/private-endpoint-name-00000000-1111-2222-3333-444444444444"), + // Properties: &armmysql.ServerPrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmysql.PrivateEndpointProperty{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/Default-Network/providers/Microsoft.Network/privateEndpoints/private-endpoint-name"), + // }, + // PrivateLinkServiceConnectionState: &armmysql.ServerPrivateLinkServiceConnectionStateProperty{ + // Description: to.Ptr("Auto-approved"), + // ActionsRequired: to.Ptr(armmysql.PrivateLinkServiceConnectionStateActionsRequireNone), + // Status: to.Ptr(armmysql.PrivateLinkServiceConnectionStateStatusApproved), + // }, + // ProvisioningState: to.Ptr(armmysql.PrivateEndpointProvisioningState("Succeeded")), + // }, + // }}, + // PublicNetworkAccess: to.Ptr(armmysql.PublicNetworkAccessEnumEnabled), + // SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumEnabled), + // StorageProfile: &armmysql.StorageProfile{ + // BackupRetentionDays: to.Ptr[int32](7), + // GeoRedundantBackup: to.Ptr(armmysql.GeoRedundantBackupDisabled), + // StorageMB: to.Ptr[int32](5120), + // }, + // UserVisibleState: to.Ptr(armmysql.ServerStateReady), + // Version: to.Ptr(armmysql.ServerVersionFive7), + // }, + // SKU: &armmysql.SKU{ + // Name: to.Ptr("GP_Gen4_2"), + // Capacity: to.Ptr[int32](2), + // Family: to.Ptr("Gen4"), + // Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), + // }, + // }, + // { + // Name: to.Ptr("mysqltestsvc3"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg1/providers/Microsoft.DBforMySQL/servers/mysqltestsvc3"), + // Location: to.Ptr("westus"), + // Properties: &armmysql.ServerProperties{ + // AdministratorLogin: to.Ptr("testuser"), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-28T23:59:44.847+00:00"); return t}()), + // FullyQualifiedDomainName: to.Ptr("mysqltestsvc3.mysql.database.azure.com"), + // PrivateEndpointConnections: []*armmysql.ServerPrivateEndpointConnection{ + // { + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/servers/mysqltestsvc3/privateEndpointConnections/private-endpoint-name-00000000-1111-2222-3333-444444444444"), + // Properties: &armmysql.ServerPrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmysql.PrivateEndpointProperty{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/Default-Network/providers/Microsoft.Network/privateEndpoints/private-endpoint-name"), + // }, + // PrivateLinkServiceConnectionState: &armmysql.ServerPrivateLinkServiceConnectionStateProperty{ + // Description: to.Ptr("Auto-approved"), + // ActionsRequired: to.Ptr(armmysql.PrivateLinkServiceConnectionStateActionsRequireNone), + // Status: to.Ptr(armmysql.PrivateLinkServiceConnectionStateStatusApproved), + // }, + // ProvisioningState: to.Ptr(armmysql.PrivateEndpointProvisioningState("Succeeded")), + // }, + // }}, + // PublicNetworkAccess: to.Ptr(armmysql.PublicNetworkAccessEnumEnabled), + // SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumEnabled), + // StorageProfile: &armmysql.StorageProfile{ + // BackupRetentionDays: to.Ptr[int32](35), + // GeoRedundantBackup: to.Ptr(armmysql.GeoRedundantBackupEnabled), + // StorageMB: to.Ptr[int32](102400), + // }, + // UserVisibleState: to.Ptr(armmysql.ServerStateReady), + // Version: to.Ptr(armmysql.ServerVersionFive7), + // }, + // SKU: &armmysql.SKU{ + // Name: to.Ptr("GP_Gen4_4"), + // Capacity: to.Ptr[int32](4), + // Family: to.Ptr("Gen4"), + // Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerRestart.json +func ExampleServersClient_BeginRestart() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginRestart(ctx, "TestGroup", "testserver", 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2020-01-01/examples/ServerStart.json +func ExampleServersClient_BeginStart() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginStart(ctx, "TestGroup", "testserver", 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2020-01-01/examples/ServerStop.json +func ExampleServersClient_BeginStop() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginStop(ctx, "TestGroup", "testserver", 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2020-01-01/examples/ServerUpgrade.json +func ExampleServersClient_BeginUpgrade() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginUpgrade(ctx, "TestGroup", "testserver", armmysql.ServerUpgradeParameters{ + Properties: &armmysql.ServerUpgradeParametersProperties{ + TargetServerVersion: to.Ptr("5.7"), + }, + }, 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) + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_serversecurityalertpolicies_client.go b/sdk/resourcemanager/mysql/armmysql/serversecurityalertpolicies_client.go similarity index 83% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_serversecurityalertpolicies_client.go rename to sdk/resourcemanager/mysql/armmysql/serversecurityalertpolicies_client.go index 57c23fc73293..9a821c79a467 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_serversecurityalertpolicies_client.go +++ b/sdk/resourcemanager/mysql/armmysql/serversecurityalertpolicies_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,65 +24,58 @@ import ( // ServerSecurityAlertPoliciesClient contains the methods for the ServerSecurityAlertPolicies group. // Don't use this type directly, use NewServerSecurityAlertPoliciesClient() instead. type ServerSecurityAlertPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServerSecurityAlertPoliciesClient creates a new instance of ServerSecurityAlertPoliciesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServerSecurityAlertPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServerSecurityAlertPoliciesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ServerSecurityAlertPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServerSecurityAlertPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a threat detection policy. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// securityAlertPolicyName - The name of the threat detection policy. -// parameters - The server security alert policy. -// options - ServerSecurityAlertPoliciesClientBeginCreateOrUpdateOptions contains the optional parameters for the ServerSecurityAlertPoliciesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - securityAlertPolicyName - The name of the threat detection policy. +// - parameters - The server security alert policy. +// - options - ServerSecurityAlertPoliciesClientBeginCreateOrUpdateOptions contains the optional parameters for the ServerSecurityAlertPoliciesClient.BeginCreateOrUpdate +// method. func (client *ServerSecurityAlertPoliciesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, securityAlertPolicyName SecurityAlertPolicyName, parameters ServerSecurityAlertPolicy, options *ServerSecurityAlertPoliciesClientBeginCreateOrUpdateOptions) (*runtime.Poller[ServerSecurityAlertPoliciesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, serverName, securityAlertPolicyName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[ServerSecurityAlertPoliciesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[ServerSecurityAlertPoliciesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServerSecurityAlertPoliciesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServerSecurityAlertPoliciesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a threat detection policy. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 func (client *ServerSecurityAlertPoliciesClient) createOrUpdate(ctx context.Context, resourceGroupName string, serverName string, securityAlertPolicyName SecurityAlertPolicyName, parameters ServerSecurityAlertPolicy, options *ServerSecurityAlertPoliciesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serverName, securityAlertPolicyName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -112,7 +104,7 @@ func (client *ServerSecurityAlertPoliciesClient) createOrUpdateCreateRequest(ctx return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -125,18 +117,19 @@ func (client *ServerSecurityAlertPoliciesClient) createOrUpdateCreateRequest(ctx // Get - Get a server's security alert policy. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// securityAlertPolicyName - The name of the security alert policy. -// options - ServerSecurityAlertPoliciesClientGetOptions contains the optional parameters for the ServerSecurityAlertPoliciesClient.Get -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - securityAlertPolicyName - The name of the security alert policy. +// - options - ServerSecurityAlertPoliciesClientGetOptions contains the optional parameters for the ServerSecurityAlertPoliciesClient.Get +// method. func (client *ServerSecurityAlertPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, securityAlertPolicyName SecurityAlertPolicyName, options *ServerSecurityAlertPoliciesClientGetOptions) (ServerSecurityAlertPoliciesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, securityAlertPolicyName, options) if err != nil { return ServerSecurityAlertPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServerSecurityAlertPoliciesClientGetResponse{}, err } @@ -165,7 +158,7 @@ func (client *ServerSecurityAlertPoliciesClient) getCreateRequest(ctx context.Co return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -186,12 +179,12 @@ func (client *ServerSecurityAlertPoliciesClient) getHandleResponse(resp *http.Re } // NewListByServerPager - Get the server's threat detection policies. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServerSecurityAlertPoliciesClientListByServerOptions contains the optional parameters for the ServerSecurityAlertPoliciesClient.ListByServer -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServerSecurityAlertPoliciesClientListByServerOptions contains the optional parameters for the ServerSecurityAlertPoliciesClient.NewListByServerPager +// method. func (client *ServerSecurityAlertPoliciesClient) NewListByServerPager(resourceGroupName string, serverName string, options *ServerSecurityAlertPoliciesClientListByServerOptions) *runtime.Pager[ServerSecurityAlertPoliciesClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[ServerSecurityAlertPoliciesClientListByServerResponse]{ More: func(page ServerSecurityAlertPoliciesClientListByServerResponse) bool { @@ -208,7 +201,7 @@ func (client *ServerSecurityAlertPoliciesClient) NewListByServerPager(resourceGr if err != nil { return ServerSecurityAlertPoliciesClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServerSecurityAlertPoliciesClientListByServerResponse{}, err } @@ -235,7 +228,7 @@ func (client *ServerSecurityAlertPoliciesClient) listByServerCreateRequest(ctx c return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/serversecurityalertpolicies_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/serversecurityalertpolicies_client_example_test.go new file mode 100644 index 000000000000..099dd353220c --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/serversecurityalertpolicies_client_example_test.go @@ -0,0 +1,194 @@ +//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 armmysql_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/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerSecurityAlertsGet.json +func ExampleServerSecurityAlertPoliciesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServerSecurityAlertPoliciesClient().Get(ctx, "securityalert-4799", "securityalert-6440", armmysql.SecurityAlertPolicyNameDefault, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ServerSecurityAlertPolicy = armmysql.ServerSecurityAlertPolicy{ + // Name: to.Ptr("Default"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/securityAlertPolicies"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/securityalert-4799/providers/Microsoft.DBforMySQL/servers/securityalert-6440/securityAlertPolicies/default"), + // Properties: &armmysql.SecurityAlertPolicyProperties{ + // DisabledAlerts: []*string{ + // to.Ptr("Access_Anomaly")}, + // EmailAccountAdmins: to.Ptr(true), + // EmailAddresses: []*string{ + // to.Ptr("test@microsoft.com;user@microsoft.com")}, + // RetentionDays: to.Ptr[int32](0), + // State: to.Ptr(armmysql.ServerSecurityAlertPolicyStateDisabled), + // StorageEndpoint: to.Ptr("https://mystorage.blob.core.windows.net"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerSecurityAlertsCreateMax.json +func ExampleServerSecurityAlertPoliciesClient_BeginCreateOrUpdate_updateAServersThreatDetectionPolicyWithAllParameters() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServerSecurityAlertPoliciesClient().BeginCreateOrUpdate(ctx, "securityalert-4799", "securityalert-6440", armmysql.SecurityAlertPolicyNameDefault, armmysql.ServerSecurityAlertPolicy{ + Properties: &armmysql.SecurityAlertPolicyProperties{ + DisabledAlerts: []*string{ + to.Ptr("Access_Anomaly"), + to.Ptr("Usage_Anomaly")}, + EmailAccountAdmins: to.Ptr(true), + EmailAddresses: []*string{ + to.Ptr("testSecurityAlert@microsoft.com")}, + RetentionDays: to.Ptr[int32](5), + State: to.Ptr(armmysql.ServerSecurityAlertPolicyStateEnabled), + StorageAccountAccessKey: to.Ptr("sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD=="), + StorageEndpoint: to.Ptr("https://mystorage.blob.core.windows.net"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ServerSecurityAlertPolicy = armmysql.ServerSecurityAlertPolicy{ + // Name: to.Ptr("Default"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/securityAlertPolicies"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/securityalert-4799/providers/Microsoft.DBforMySQL/servers/securityalert-6440/securityAlertPolicies/default"), + // Properties: &armmysql.SecurityAlertPolicyProperties{ + // DisabledAlerts: []*string{ + // to.Ptr("Access_Anomaly"), + // to.Ptr("Usage_Anomaly")}, + // EmailAccountAdmins: to.Ptr(true), + // EmailAddresses: []*string{ + // to.Ptr("testSecurityAlert@microsoft.com")}, + // RetentionDays: to.Ptr[int32](5), + // State: to.Ptr(armmysql.ServerSecurityAlertPolicyStateEnabled), + // StorageEndpoint: to.Ptr("https://mystorage.blob.core.windows.net"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerSecurityAlertsCreateMin.json +func ExampleServerSecurityAlertPoliciesClient_BeginCreateOrUpdate_updateAServersThreatDetectionPolicyWithMinimalParameters() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServerSecurityAlertPoliciesClient().BeginCreateOrUpdate(ctx, "securityalert-4799", "securityalert-6440", armmysql.SecurityAlertPolicyNameDefault, armmysql.ServerSecurityAlertPolicy{ + Properties: &armmysql.SecurityAlertPolicyProperties{ + EmailAccountAdmins: to.Ptr(true), + State: to.Ptr(armmysql.ServerSecurityAlertPolicyStateDisabled), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ServerSecurityAlertPolicy = armmysql.ServerSecurityAlertPolicy{ + // Name: to.Ptr("Default"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/securityAlertPolicies"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/securityalert-4799/providers/Microsoft.DBforMySQL/servers/securityalert-6440/securityAlertPolicies/default"), + // Properties: &armmysql.SecurityAlertPolicyProperties{ + // DisabledAlerts: []*string{ + // }, + // EmailAccountAdmins: to.Ptr(true), + // EmailAddresses: []*string{ + // }, + // RetentionDays: to.Ptr[int32](0), + // State: to.Ptr(armmysql.ServerSecurityAlertPolicyStateEnabled), + // StorageEndpoint: to.Ptr(""), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerSecurityAlertsListByServer.json +func ExampleServerSecurityAlertPoliciesClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServerSecurityAlertPoliciesClient().NewListByServerPager("securityalert-4799", "securityalert-6440", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ServerSecurityAlertPolicyListResult = armmysql.ServerSecurityAlertPolicyListResult{ + // Value: []*armmysql.ServerSecurityAlertPolicy{ + // { + // Name: to.Ptr("Default"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/securityAlertPolicies"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/securityalert-4799/providers/Microsoft.DBforMySQL/servers/securityalert-6440/securityAlertPolicies"), + // Properties: &armmysql.SecurityAlertPolicyProperties{ + // DisabledAlerts: []*string{ + // to.Ptr("Access_Anomaly")}, + // EmailAccountAdmins: to.Ptr(true), + // EmailAddresses: []*string{ + // to.Ptr("test@microsoft.com;user@microsoft.com")}, + // RetentionDays: to.Ptr[int32](0), + // State: to.Ptr(armmysql.ServerSecurityAlertPolicyStateDisabled), + // StorageEndpoint: to.Ptr("https://mystorage.blob.core.windows.net"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_time_rfc3339.go b/sdk/resourcemanager/mysql/armmysql/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/mysql/armmysql/time_rfc3339.go index 67c05423efa1..0d6635ee4703 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/mysql/armmysql/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 armmysql @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_topquerystatistics_client.go b/sdk/resourcemanager/mysql/armmysql/topquerystatistics_client.go similarity index 82% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_topquerystatistics_client.go rename to sdk/resourcemanager/mysql/armmysql/topquerystatistics_client.go index 40d71a5b5f58..31ee12404320 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_topquerystatistics_client.go +++ b/sdk/resourcemanager/mysql/armmysql/topquerystatistics_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // TopQueryStatisticsClient contains the methods for the TopQueryStatistics group. // Don't use this type directly, use NewTopQueryStatisticsClient() instead. type TopQueryStatisticsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTopQueryStatisticsClient creates a new instance of TopQueryStatisticsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewTopQueryStatisticsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TopQueryStatisticsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".TopQueryStatisticsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TopQueryStatisticsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Retrieve the query statistic for specified identifier. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// queryStatisticID - The Query Statistic identifier. -// options - TopQueryStatisticsClientGetOptions contains the optional parameters for the TopQueryStatisticsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - queryStatisticID - The Query Statistic identifier. +// - options - TopQueryStatisticsClientGetOptions contains the optional parameters for the TopQueryStatisticsClient.Get method. func (client *TopQueryStatisticsClient) Get(ctx context.Context, resourceGroupName string, serverName string, queryStatisticID string, options *TopQueryStatisticsClientGetOptions) (TopQueryStatisticsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, queryStatisticID, options) if err != nil { return TopQueryStatisticsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TopQueryStatisticsClientGetResponse{}, err } @@ -95,7 +86,7 @@ func (client *TopQueryStatisticsClient) getCreateRequest(ctx context.Context, re return nil, errors.New("parameter queryStatisticID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{queryStatisticId}", url.PathEscape(queryStatisticID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -116,13 +107,13 @@ func (client *TopQueryStatisticsClient) getHandleResponse(resp *http.Response) ( } // NewListByServerPager - Retrieve the Query-Store top queries for specified metric and aggregation. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// parameters - The required parameters for retrieving top query statistics. -// options - TopQueryStatisticsClientListByServerOptions contains the optional parameters for the TopQueryStatisticsClient.ListByServer -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - parameters - The required parameters for retrieving top query statistics. +// - options - TopQueryStatisticsClientListByServerOptions contains the optional parameters for the TopQueryStatisticsClient.NewListByServerPager +// method. func (client *TopQueryStatisticsClient) NewListByServerPager(resourceGroupName string, serverName string, parameters TopQueryStatisticsInput, options *TopQueryStatisticsClientListByServerOptions) *runtime.Pager[TopQueryStatisticsClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[TopQueryStatisticsClientListByServerResponse]{ More: func(page TopQueryStatisticsClientListByServerResponse) bool { @@ -139,7 +130,7 @@ func (client *TopQueryStatisticsClient) NewListByServerPager(resourceGroupName s if err != nil { return TopQueryStatisticsClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TopQueryStatisticsClientListByServerResponse{}, err } @@ -166,7 +157,7 @@ func (client *TopQueryStatisticsClient) listByServerCreateRequest(ctx context.Co return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/topquerystatistics_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/topquerystatistics_client_example_test.go new file mode 100644 index 000000000000..307f9cbd06c9 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/topquerystatistics_client_example_test.go @@ -0,0 +1,132 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "time" + + "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/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/TopQueryStatisticsGet.json +func ExampleTopQueryStatisticsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTopQueryStatisticsClient().Get(ctx, "testResourceGroupName", "testServerName", "66-636923268000000000-636923277000000000-avg-duration", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.QueryStatistic = armmysql.QueryStatistic{ + // Name: to.Ptr("66-636923268000000000-636923277000000000-avg-duration"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/queryStatistics"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.DBforMySQL/servers/testServerName/queryStatistic/66-636923268000000000-636923277000000000-avg-duration"), + // Properties: &armmysql.QueryStatisticProperties{ + // AggregationFunction: to.Ptr("avg"), + // DatabaseNames: []*string{ + // to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.DBforMySQL/servers/testServerName/databases/mysql")}, + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-01T17:15:00Z"); return t}()), + // MetricDisplayName: to.Ptr("Query duration"), + // MetricName: to.Ptr("duration"), + // MetricValue: to.Ptr[float64](123.301446136), + // MetricValueUnit: to.Ptr("milliseconds"), + // QueryExecutionCount: to.Ptr[int64](1), + // QueryID: to.Ptr("66"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-01T17:00:00Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/TopQueryStatisticsListByServer.json +func ExampleTopQueryStatisticsClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTopQueryStatisticsClient().NewListByServerPager("testResourceGroupName", "testServerName", armmysql.TopQueryStatisticsInput{ + Properties: &armmysql.TopQueryStatisticsInputProperties{ + AggregationFunction: to.Ptr("avg"), + AggregationWindow: to.Ptr("PT15M"), + NumberOfTopQueries: to.Ptr[int32](5), + ObservationEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-07T20:00:00.000Z"); return t }()), + ObservationStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-01T20:00:00.000Z"); return t }()), + ObservedMetric: to.Ptr("duration"), + }, + }, nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.TopQueryStatisticsResultList = armmysql.TopQueryStatisticsResultList{ + // Value: []*armmysql.QueryStatistic{ + // { + // Name: to.Ptr("66-636923268000000000-636923277000000000-avg-duration"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/queryStatistics"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.DBforMySQL/servers/testServerName/queryStatistic/66-636923268000000000-636923277000000000-avg-duration"), + // Properties: &armmysql.QueryStatisticProperties{ + // AggregationFunction: to.Ptr("avg"), + // DatabaseNames: []*string{ + // to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.DBforMySQL/servers/testServerName/databases/mysql")}, + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-01T17:15:00Z"); return t}()), + // MetricDisplayName: to.Ptr("Query duration"), + // MetricName: to.Ptr("duration"), + // MetricValue: to.Ptr[float64](123.301446136), + // MetricValueUnit: to.Ptr("milliseconds"), + // QueryExecutionCount: to.Ptr[int64](1), + // QueryID: to.Ptr("66"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-01T17:00:00Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("66-636924483000000000-636924492000000000-avg-duration"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/queryStatistics"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.DBforMySQL/servers/testServerName/queryStatistic/66-636924483000000000-636924492000000000-avg-duration"), + // Properties: &armmysql.QueryStatisticProperties{ + // AggregationFunction: to.Ptr("avg"), + // DatabaseNames: []*string{ + // to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.DBforMySQL/servers/testServerName/databases/mysql")}, + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-03T03:00:00Z"); return t}()), + // MetricDisplayName: to.Ptr("Query duration"), + // MetricName: to.Ptr("duration"), + // MetricValue: to.Ptr[float64](1712.301446136), + // MetricValueUnit: to.Ptr("milliseconds"), + // QueryExecutionCount: to.Ptr[int64](1), + // QueryID: to.Ptr("66"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-03T02:45:00Z"); return t}()), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_virtualnetworkrules_client.go b/sdk/resourcemanager/mysql/armmysql/virtualnetworkrules_client.go similarity index 83% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_virtualnetworkrules_client.go rename to sdk/resourcemanager/mysql/armmysql/virtualnetworkrules_client.go index 09d08b40d5a6..09dd1b26c68b 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_virtualnetworkrules_client.go +++ b/sdk/resourcemanager/mysql/armmysql/virtualnetworkrules_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,65 +24,58 @@ import ( // VirtualNetworkRulesClient contains the methods for the VirtualNetworkRules group. // Don't use this type directly, use NewVirtualNetworkRulesClient() instead. type VirtualNetworkRulesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVirtualNetworkRulesClient creates a new instance of VirtualNetworkRulesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewVirtualNetworkRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualNetworkRulesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".VirtualNetworkRulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VirtualNetworkRulesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates an existing virtual network rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// virtualNetworkRuleName - The name of the virtual network rule. -// parameters - The requested virtual Network Rule Resource state. -// options - VirtualNetworkRulesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualNetworkRulesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - virtualNetworkRuleName - The name of the virtual network rule. +// - parameters - The requested virtual Network Rule Resource state. +// - options - VirtualNetworkRulesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualNetworkRulesClient.BeginCreateOrUpdate +// method. func (client *VirtualNetworkRulesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string, parameters VirtualNetworkRule, options *VirtualNetworkRulesClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualNetworkRulesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, serverName, virtualNetworkRuleName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualNetworkRulesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualNetworkRulesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualNetworkRulesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualNetworkRulesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates an existing virtual network rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 func (client *VirtualNetworkRulesClient) createOrUpdate(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string, parameters VirtualNetworkRule, options *VirtualNetworkRulesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serverName, virtualNetworkRuleName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -112,7 +104,7 @@ func (client *VirtualNetworkRulesClient) createOrUpdateCreateRequest(ctx context return nil, errors.New("parameter virtualNetworkRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkRuleName}", url.PathEscape(virtualNetworkRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -125,33 +117,35 @@ func (client *VirtualNetworkRulesClient) createOrUpdateCreateRequest(ctx context // BeginDelete - Deletes the virtual network rule with the given name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// virtualNetworkRuleName - The name of the virtual network rule. -// options - VirtualNetworkRulesClientBeginDeleteOptions contains the optional parameters for the VirtualNetworkRulesClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - virtualNetworkRuleName - The name of the virtual network rule. +// - options - VirtualNetworkRulesClientBeginDeleteOptions contains the optional parameters for the VirtualNetworkRulesClient.BeginDelete +// method. func (client *VirtualNetworkRulesClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string, options *VirtualNetworkRulesClientBeginDeleteOptions) (*runtime.Poller[VirtualNetworkRulesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, virtualNetworkRuleName, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualNetworkRulesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualNetworkRulesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualNetworkRulesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualNetworkRulesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the virtual network rule with the given name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 func (client *VirtualNetworkRulesClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string, options *VirtualNetworkRulesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, virtualNetworkRuleName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -180,7 +174,7 @@ func (client *VirtualNetworkRulesClient) deleteCreateRequest(ctx context.Context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -192,17 +186,18 @@ func (client *VirtualNetworkRulesClient) deleteCreateRequest(ctx context.Context // Get - Gets a virtual network rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// virtualNetworkRuleName - The name of the virtual network rule. -// options - VirtualNetworkRulesClientGetOptions contains the optional parameters for the VirtualNetworkRulesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - virtualNetworkRuleName - The name of the virtual network rule. +// - options - VirtualNetworkRulesClientGetOptions contains the optional parameters for the VirtualNetworkRulesClient.Get method. func (client *VirtualNetworkRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string, options *VirtualNetworkRulesClientGetOptions) (VirtualNetworkRulesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, virtualNetworkRuleName, options) if err != nil { return VirtualNetworkRulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualNetworkRulesClientGetResponse{}, err } @@ -231,7 +226,7 @@ func (client *VirtualNetworkRulesClient) getCreateRequest(ctx context.Context, r return nil, errors.New("parameter virtualNetworkRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkRuleName}", url.PathEscape(virtualNetworkRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -252,12 +247,12 @@ func (client *VirtualNetworkRulesClient) getHandleResponse(resp *http.Response) } // NewListByServerPager - Gets a list of virtual network rules in a server. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - VirtualNetworkRulesClientListByServerOptions contains the optional parameters for the VirtualNetworkRulesClient.ListByServer -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - VirtualNetworkRulesClientListByServerOptions contains the optional parameters for the VirtualNetworkRulesClient.NewListByServerPager +// method. func (client *VirtualNetworkRulesClient) NewListByServerPager(resourceGroupName string, serverName string, options *VirtualNetworkRulesClientListByServerOptions) *runtime.Pager[VirtualNetworkRulesClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualNetworkRulesClientListByServerResponse]{ More: func(page VirtualNetworkRulesClientListByServerResponse) bool { @@ -274,7 +269,7 @@ func (client *VirtualNetworkRulesClient) NewListByServerPager(resourceGroupName if err != nil { return VirtualNetworkRulesClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualNetworkRulesClientListByServerResponse{}, err } @@ -301,7 +296,7 @@ func (client *VirtualNetworkRulesClient) listByServerCreateRequest(ctx context.C return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/virtualnetworkrules_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/virtualnetworkrules_client_example_test.go new file mode 100644 index 000000000000..7400195e62f7 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/virtualnetworkrules_client_example_test.go @@ -0,0 +1,156 @@ +//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 armmysql_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/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/VirtualNetworkRulesGet.json +func ExampleVirtualNetworkRulesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualNetworkRulesClient().Get(ctx, "TestGroup", "vnet-test-svr", "vnet-firewall-rule", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VirtualNetworkRule = armmysql.VirtualNetworkRule{ + // Name: to.Ptr("vnet-firewall-rule"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/virtualNetworkRules"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/vnet-test-svr/virtualNetworkRules/vnet-firewall-rule"), + // Properties: &armmysql.VirtualNetworkRuleProperties{ + // IgnoreMissingVnetServiceEndpoint: to.Ptr(false), + // State: to.Ptr(armmysql.VirtualNetworkRuleStateReady), + // VirtualNetworkSubnetID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/VirtualNetworkRulesCreateOrUpdate.json +func ExampleVirtualNetworkRulesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualNetworkRulesClient().BeginCreateOrUpdate(ctx, "TestGroup", "vnet-test-svr", "vnet-firewall-rule", armmysql.VirtualNetworkRule{ + Properties: &armmysql.VirtualNetworkRuleProperties{ + IgnoreMissingVnetServiceEndpoint: to.Ptr(false), + VirtualNetworkSubnetID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VirtualNetworkRule = armmysql.VirtualNetworkRule{ + // Name: to.Ptr("vnet-firewall-rule"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/virtualNetworkRules"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/vnet-test-svr/virtualNetworkRules/vnet-firewall-rule"), + // Properties: &armmysql.VirtualNetworkRuleProperties{ + // IgnoreMissingVnetServiceEndpoint: to.Ptr(false), + // VirtualNetworkSubnetID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/VirtualNetworkRulesDelete.json +func ExampleVirtualNetworkRulesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualNetworkRulesClient().BeginDelete(ctx, "TestGroup", "vnet-test-svr", "vnet-firewall-rule", 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/VirtualNetworkRulesList.json +func ExampleVirtualNetworkRulesClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewVirtualNetworkRulesClient().NewListByServerPager("TestGroup", "vnet-test-svr", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.VirtualNetworkRuleListResult = armmysql.VirtualNetworkRuleListResult{ + // Value: []*armmysql.VirtualNetworkRule{ + // { + // Name: to.Ptr("vnet-firewall-rule"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/virtualNetworkRules"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/vnet-test-svr/virtualNetworkRules/vnet-firewall-rule"), + // Properties: &armmysql.VirtualNetworkRuleProperties{ + // IgnoreMissingVnetServiceEndpoint: to.Ptr(false), + // State: to.Ptr(armmysql.VirtualNetworkRuleStateReady), + // VirtualNetworkSubnetID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), + // }, + // }, + // { + // Name: to.Ptr("vnet-firewall-rule"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/virtualNetworkRules"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/vnet-test-svr/virtualNetworkRules/vnet-firewall-rule"), + // Properties: &armmysql.VirtualNetworkRuleProperties{ + // IgnoreMissingVnetServiceEndpoint: to.Ptr(false), + // State: to.Ptr(armmysql.VirtualNetworkRuleStateReady), + // VirtualNetworkSubnetID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/zz_generated_waitstatistics_client.go b/sdk/resourcemanager/mysql/armmysql/waitstatistics_client.go similarity index 81% rename from sdk/resourcemanager/mysql/armmysql/zz_generated_waitstatistics_client.go rename to sdk/resourcemanager/mysql/armmysql/waitstatistics_client.go index d34d6bd96de1..3b3098a3b45c 100644 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_waitstatistics_client.go +++ b/sdk/resourcemanager/mysql/armmysql/waitstatistics_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 armmysql @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // WaitStatisticsClient contains the methods for the WaitStatistics group. // Don't use this type directly, use NewWaitStatisticsClient() instead. type WaitStatisticsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewWaitStatisticsClient creates a new instance of WaitStatisticsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewWaitStatisticsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WaitStatisticsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".WaitStatisticsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &WaitStatisticsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Retrieve wait statistics for specified identifier. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// waitStatisticsID - The Wait Statistic identifier. -// options - WaitStatisticsClientGetOptions contains the optional parameters for the WaitStatisticsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - waitStatisticsID - The Wait Statistic identifier. +// - options - WaitStatisticsClientGetOptions contains the optional parameters for the WaitStatisticsClient.Get method. func (client *WaitStatisticsClient) Get(ctx context.Context, resourceGroupName string, serverName string, waitStatisticsID string, options *WaitStatisticsClientGetOptions) (WaitStatisticsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, waitStatisticsID, options) if err != nil { return WaitStatisticsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WaitStatisticsClientGetResponse{}, err } @@ -95,7 +86,7 @@ func (client *WaitStatisticsClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter waitStatisticsID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{waitStatisticsId}", url.PathEscape(waitStatisticsID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -116,13 +107,13 @@ func (client *WaitStatisticsClient) getHandleResponse(resp *http.Response) (Wait } // NewListByServerPager - Retrieve wait statistics for specified aggregation window. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// parameters - The required parameters for retrieving wait statistics. -// options - WaitStatisticsClientListByServerOptions contains the optional parameters for the WaitStatisticsClient.ListByServer -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - parameters - The required parameters for retrieving wait statistics. +// - options - WaitStatisticsClientListByServerOptions contains the optional parameters for the WaitStatisticsClient.NewListByServerPager +// method. func (client *WaitStatisticsClient) NewListByServerPager(resourceGroupName string, serverName string, parameters WaitStatisticsInput, options *WaitStatisticsClientListByServerOptions) *runtime.Pager[WaitStatisticsClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[WaitStatisticsClientListByServerResponse]{ More: func(page WaitStatisticsClientListByServerResponse) bool { @@ -139,7 +130,7 @@ func (client *WaitStatisticsClient) NewListByServerPager(resourceGroupName strin if err != nil { return WaitStatisticsClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WaitStatisticsClientListByServerResponse{}, err } @@ -166,7 +157,7 @@ func (client *WaitStatisticsClient) listByServerCreateRequest(ctx context.Contex return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysql/waitstatistics_client_example_test.go b/sdk/resourcemanager/mysql/armmysql/waitstatistics_client_example_test.go new file mode 100644 index 000000000000..532219aa37c5 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysql/waitstatistics_client_example_test.go @@ -0,0 +1,123 @@ +//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 armmysql_test + +import ( + "context" + "log" + + "time" + + "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/mysql/armmysql" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/WaitStatisticsGet.json +func ExampleWaitStatisticsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWaitStatisticsClient().Get(ctx, "testResourceGroupName", "testServerName", "636927606000000000-636927615000000000-send-wait/io/socket/sql/client_connection-2--0", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.WaitStatistic = armmysql.WaitStatistic{ + // Name: to.Ptr("636927606000000000-636927615000000000-send-wait/io/socket/sql/client_connection-2--0"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/waitStatistics"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.DBforMySQL/servers/testServerName/waitStatistics/636927606000000000-636927615000000000-send-wait/io/socket/sql/client_connection-2--0"), + // Properties: &armmysql.WaitStatisticProperties{ + // Count: to.Ptr[int64](3), + // DatabaseName: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.DBforMySQL/servers/testServerName/databases/mysql"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-06T17:45:00Z"); return t}()), + // EventName: to.Ptr("wait/io/socket/sql/client_connection"), + // EventTypeName: to.Ptr("send"), + // QueryID: to.Ptr[int64](2), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-06T17:30:00Z"); return t}()), + // TotalTimeInMs: to.Ptr[float64](12.345), + // UserID: to.Ptr[int64](0), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/WaitStatisticsListByServer.json +func ExampleWaitStatisticsClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysql.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewWaitStatisticsClient().NewListByServerPager("testResourceGroupName", "testServerName", armmysql.WaitStatisticsInput{ + Properties: &armmysql.WaitStatisticsInputProperties{ + AggregationWindow: to.Ptr("PT15M"), + ObservationEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-07T20:00:00.000Z"); return t }()), + ObservationStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-01T20:00:00.000Z"); return t }()), + }, + }, nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.WaitStatisticsResultList = armmysql.WaitStatisticsResultList{ + // Value: []*armmysql.WaitStatistic{ + // { + // Name: to.Ptr("636927606000000000-636927615000000000-send-wait/io/socket/sql/client_connection-2--0"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/waitStatistics"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.DBforMySQL/servers/testServerName/waitStatistics/636927606000000000-636927615000000000-send-wait/io/socket/sql/client_connection-2--0"), + // Properties: &armmysql.WaitStatisticProperties{ + // Count: to.Ptr[int64](2), + // DatabaseName: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testResourceGroupName/providers/Microsoft.DBforMySQL/servers/testServerName/databases/mysql"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-06T17:45:00Z"); return t}()), + // EventName: to.Ptr("wait/io/socket/sql/client_connection"), + // EventTypeName: to.Ptr("send"), + // QueryID: to.Ptr[int64](2), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-06T17:30:00Z"); return t}()), + // TotalTimeInMs: to.Ptr[float64](12.345), + // UserID: to.Ptr[int64](0), + // }, + // }, + // { + // Name: to.Ptr("636927606000000000-636927615000000000-lock-wait/synch/mutex/mysys/THR_LOCK::mutex-2--0"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/waitStatistics"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/hyshim-test/providers/Microsoft.DBforMySQL/servers/hyshim-wait-stats-fix/waitStatistics/636927606000000000-636927615000000000-lock-wait/synch/mutex/mysys/THR_LOCK::mutex-2--0"), + // Properties: &armmysql.WaitStatisticProperties{ + // Count: to.Ptr[int64](4), + // DatabaseName: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/hyshim-test/providers/Microsoft.DBforMySQL/servers/hyshim-wait-stats-fix/databases/"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-06T17:45:00Z"); return t}()), + // EventName: to.Ptr("wait/synch/mutex/mysys/THR_LOCK::mutex"), + // EventTypeName: to.Ptr("lock"), + // QueryID: to.Ptr[int64](2), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-06T17:30:00Z"); return t}()), + // TotalTimeInMs: to.Ptr[float64](56.789), + // UserID: to.Ptr[int64](0), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_advisors_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_advisors_client_test.go deleted file mode 100644 index 2bb2d067f3b8..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_advisors_client_test.go +++ /dev/null @@ -1,66 +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 armmysql_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/AdvisorsGet.json -func ExampleAdvisorsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewAdvisorsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "testResourceGroupName", - "testServerName", - "Index", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/AdvisorsListByServer.json -func ExampleAdvisorsClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewAdvisorsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("testResourceGroupName", - "testServerName", - 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/mysql/armmysql/ze_generated_example_configurations_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_configurations_client_test.go deleted file mode 100644 index c0bba8cd9d35..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_configurations_client_test.go +++ /dev/null @@ -1,100 +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 armmysql_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/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ConfigurationCreateOrUpdate.json -func ExampleConfigurationsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewConfigurationsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "TestGroup", - "testserver", - "event_scheduler", - armmysql.Configuration{ - Properties: &armmysql.ConfigurationProperties{ - Source: to.Ptr("user-override"), - Value: to.Ptr("off"), - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ConfigurationGet.json -func ExampleConfigurationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewConfigurationsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "TestGroup", - "testserver", - "event_scheduler", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ConfigurationListByServer.json -func ExampleConfigurationsClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewConfigurationsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("testrg", - "mysqltestsvc1", - 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/mysql/armmysql/ze_generated_example_databases_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_databases_client_test.go deleted file mode 100644 index ce661cd1fd8d..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_databases_client_test.go +++ /dev/null @@ -1,125 +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 armmysql_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/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/DatabaseCreate.json -func ExampleDatabasesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewDatabasesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "TestGroup", - "testserver", - "db1", - armmysql.Database{ - Properties: &armmysql.DatabaseProperties{ - Charset: to.Ptr("utf8"), - Collation: to.Ptr("utf8_general_ci"), - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/DatabaseDelete.json -func ExampleDatabasesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewDatabasesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "TestGroup", - "testserver", - "db1", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/DatabaseGet.json -func ExampleDatabasesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewDatabasesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "TestGroup", - "testserver", - "db1", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/DatabaseListByServer.json -func ExampleDatabasesClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewDatabasesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("TestGroup", - "testserver", - 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/mysql/armmysql/ze_generated_example_firewallrules_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_firewallrules_client_test.go deleted file mode 100644 index da339fc8d3ed..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_firewallrules_client_test.go +++ /dev/null @@ -1,125 +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 armmysql_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/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/FirewallRuleCreate.json -func ExampleFirewallRulesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewFirewallRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "TestGroup", - "testserver", - "rule1", - armmysql.FirewallRule{ - Properties: &armmysql.FirewallRuleProperties{ - EndIPAddress: to.Ptr("255.255.255.255"), - StartIPAddress: to.Ptr("0.0.0.0"), - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/FirewallRuleDelete.json -func ExampleFirewallRulesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewFirewallRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "TestGroup", - "testserver", - "rule1", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/FirewallRuleGet.json -func ExampleFirewallRulesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewFirewallRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "TestGroup", - "testserver", - "rule1", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/FirewallRuleListByServer.json -func ExampleFirewallRulesClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewFirewallRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("TestGroup", - "testserver", - 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/mysql/armmysql/ze_generated_example_locationbasedperformancetier_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_locationbasedperformancetier_client_test.go deleted file mode 100644 index 4d413fb05650..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_locationbasedperformancetier_client_test.go +++ /dev/null @@ -1,42 +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 armmysql_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/PerformanceTiersListByLocation.json -func ExampleLocationBasedPerformanceTierClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewLocationBasedPerformanceTierClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("WestUS", - 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/mysql/armmysql/ze_generated_example_locationbasedrecommendedactionsessionsoperationstatus_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_locationbasedrecommendedactionsessionsoperationstatus_client_test.go deleted file mode 100644 index 465fbcf42d43..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_locationbasedrecommendedactionsessionsoperationstatus_client_test.go +++ /dev/null @@ -1,39 +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 armmysql_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/RecommendedActionSessionOperationStatus.json -func ExampleLocationBasedRecommendedActionSessionsOperationStatusClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewLocationBasedRecommendedActionSessionsOperationStatusClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "WestUS", - "aaaabbbb-cccc-dddd-0000-111122223333", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_locationbasedrecommendedactionsessionsresult_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_locationbasedrecommendedactionsessionsresult_client_test.go deleted file mode 100644 index 447d9f36cbeb..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_locationbasedrecommendedactionsessionsresult_client_test.go +++ /dev/null @@ -1,43 +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 armmysql_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/RecommendedActionSessionResult.json -func ExampleLocationBasedRecommendedActionSessionsResultClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewLocationBasedRecommendedActionSessionsResultClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("WestUS", - "aaaabbbb-cccc-dddd-0000-111122223333", - 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/mysql/armmysql/ze_generated_example_logfiles_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_logfiles_client_test.go deleted file mode 100644 index 7e9368f4c9cd..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_logfiles_client_test.go +++ /dev/null @@ -1,43 +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 armmysql_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/LogFileListByServer.json -func ExampleLogFilesClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewLogFilesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("TestGroup", - "testserver", - 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/mysql/armmysql/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_operations_client_test.go deleted file mode 100644 index 31f0e6147daa..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_operations_client_test.go +++ /dev/null @@ -1,37 +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 armmysql_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/OperationList.json -func ExampleOperationsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_privateendpointconnections_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_privateendpointconnections_client_test.go deleted file mode 100644 index 1adcb833d993..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_privateendpointconnections_client_test.go +++ /dev/null @@ -1,160 +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 armmysql_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/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/PrivateEndpointConnectionGet.json -func ExamplePrivateEndpointConnectionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewPrivateEndpointConnectionsClient("00000000-1111-2222-3333-444444444444", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "Default", - "test-svr", - "private-endpoint-connection-name", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/PrivateEndpointConnectionUpdate.json -func ExamplePrivateEndpointConnectionsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewPrivateEndpointConnectionsClient("00000000-1111-2222-3333-444444444444", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "Default", - "test-svr", - "private-endpoint-connection-name", - armmysql.PrivateEndpointConnection{ - Properties: &armmysql.PrivateEndpointConnectionProperties{ - PrivateLinkServiceConnectionState: &armmysql.PrivateLinkServiceConnectionStateProperty{ - Description: to.Ptr("Approved by johndoe@contoso.com"), - Status: to.Ptr("Approved"), - }, - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/PrivateEndpointConnectionDelete.json -func ExamplePrivateEndpointConnectionsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewPrivateEndpointConnectionsClient("00000000-1111-2222-3333-444444444444", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "Default", - "test-svr", - "private-endpoint-connection-name", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/PrivateEndpointConnectionUpdateTags.json -func ExamplePrivateEndpointConnectionsClient_BeginUpdateTags() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewPrivateEndpointConnectionsClient("00000000-1111-2222-3333-444444444444", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdateTags(ctx, - "Default", - "test-svr", - "private-endpoint-connection-name", - armmysql.TagsObject{ - Tags: map[string]*string{ - "key1": to.Ptr("val1"), - "key2": to.Ptr("val2"), - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/PrivateEndpointConnectionList.json -func ExamplePrivateEndpointConnectionsClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewPrivateEndpointConnectionsClient("00000000-1111-2222-3333-444444444444", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("Default", - "test-svr", - 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/mysql/armmysql/ze_generated_example_privatelinkresources_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_privatelinkresources_client_test.go deleted file mode 100644 index 22459200eed4..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_privatelinkresources_client_test.go +++ /dev/null @@ -1,66 +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 armmysql_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/PrivateLinkResourcesList.json -func ExamplePrivateLinkResourcesClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewPrivateLinkResourcesClient("00000000-1111-2222-3333-444444444444", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("Default", - "test-svr", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/PrivateLinkResourcesGet.json -func ExamplePrivateLinkResourcesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewPrivateLinkResourcesClient("00000000-1111-2222-3333-444444444444", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "Default", - "test-svr", - "plr", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_querytexts_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_querytexts_client_test.go deleted file mode 100644 index 42a63933e960..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_querytexts_client_test.go +++ /dev/null @@ -1,69 +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 armmysql_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/QueryTextsGet.json -func ExampleQueryTextsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewQueryTextsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "testResourceGroupName", - "testServerName", - "1", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/QueryTextsListByServer.json -func ExampleQueryTextsClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewQueryTextsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("testResourceGroupName", - "testServerName", - []string{ - "1", - "2"}, - 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/mysql/armmysql/ze_generated_example_recommendedactions_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_recommendedactions_client_test.go deleted file mode 100644 index 5a05730dd111..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_recommendedactions_client_test.go +++ /dev/null @@ -1,68 +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 armmysql_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/RecommendedActionsGet.json -func ExampleRecommendedActionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewRecommendedActionsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "testResourceGroupName", - "testServerName", - "Index", - "Index-1", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/RecommendedActionsListByServer.json -func ExampleRecommendedActionsClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewRecommendedActionsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("testResourceGroupName", - "testServerName", - "Index", - &armmysql.RecommendedActionsClientListByServerOptions{SessionID: 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/mysql/armmysql/ze_generated_example_recoverableservers_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_recoverableservers_client_test.go deleted file mode 100644 index fa20574fb9d6..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_recoverableservers_client_test.go +++ /dev/null @@ -1,39 +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 armmysql_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/RecoverableServersGet.json -func ExampleRecoverableServersClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewRecoverableServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "testrg", - "testsvc4", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_replicas_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_replicas_client_test.go deleted file mode 100644 index 1f5b9982e5e4..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_replicas_client_test.go +++ /dev/null @@ -1,43 +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 armmysql_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ReplicasListByServer.json -func ExampleReplicasClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewReplicasClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("TestGroup", - "testmaster", - 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/mysql/armmysql/ze_generated_example_serveradministrators_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_serveradministrators_client_test.go deleted file mode 100644 index e261f95eea68..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_serveradministrators_client_test.go +++ /dev/null @@ -1,124 +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 armmysql_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/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerAdminGet.json -func ExampleServerAdministratorsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServerAdministratorsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "testrg", - "mysqltestsvc4", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerAdminCreateUpdate.json -func ExampleServerAdministratorsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServerAdministratorsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "testrg", - "mysqltestsvc4", - armmysql.ServerAdministratorResource{ - Properties: &armmysql.ServerAdministratorProperties{ - AdministratorType: to.Ptr("ActiveDirectory"), - Login: to.Ptr("bob@contoso.com"), - Sid: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), - TenantID: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerAdminDelete.json -func ExampleServerAdministratorsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServerAdministratorsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "testrg", - "mysqltestsvc4", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerAdminList.json -func ExampleServerAdministratorsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServerAdministratorsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("testrg", - "mysqltestsvc4", - 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/mysql/armmysql/ze_generated_example_serverbasedperformancetier_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_serverbasedperformancetier_client_test.go deleted file mode 100644 index 668a085ca708..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_serverbasedperformancetier_client_test.go +++ /dev/null @@ -1,43 +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 armmysql_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/PerformanceTiersListByServer.json -func ExampleServerBasedPerformanceTierClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServerBasedPerformanceTierClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("testrg", - "mysqltestsvc1", - 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/mysql/armmysql/ze_generated_example_serverkeys_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_serverkeys_client_test.go deleted file mode 100644 index 79e258713aea..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_serverkeys_client_test.go +++ /dev/null @@ -1,125 +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 armmysql_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/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2020-01-01/examples/ServerKeyList.json -func ExampleServerKeysClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServerKeysClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("testrg", - "testserver", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2020-01-01/examples/ServerKeyGet.json -func ExampleServerKeysClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServerKeysClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "testrg", - "testserver", - "someVault_someKey_01234567890123456789012345678901", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2020-01-01/examples/ServerKeyCreateOrUpdate.json -func ExampleServerKeysClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServerKeysClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "testserver", - "someVault_someKey_01234567890123456789012345678901", - "testrg", - armmysql.ServerKey{ - Properties: &armmysql.ServerKeyProperties{ - ServerKeyType: to.Ptr(armmysql.ServerKeyTypeAzureKeyVault), - URI: to.Ptr("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2020-01-01/examples/ServerKeyDelete.json -func ExampleServerKeysClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServerKeysClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "testserver", - "someVault_someKey_01234567890123456789012345678901", - "testrg", - 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) - } -} diff --git a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_serverparameters_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_serverparameters_client_test.go deleted file mode 100644 index 518b09c978b7..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_serverparameters_client_test.go +++ /dev/null @@ -1,44 +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 armmysql_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ConfigurationsUpdateByServer.json -func ExampleServerParametersClient_BeginListUpdateConfigurations() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServerParametersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginListUpdateConfigurations(ctx, - "testrg", - "mysqltestsvc1", - armmysql.ConfigurationListResult{}, - 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 -} diff --git a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_servers_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_servers_client_test.go deleted file mode 100644 index c2a74a691f69..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_servers_client_test.go +++ /dev/null @@ -1,291 +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 armmysql_test - -import ( - "context" - "log" - - "time" - - "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/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerCreatePointInTimeRestore.json -func ExampleServersClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "TargetResourceGroup", - "targetserver", - armmysql.ServerForCreate{ - Location: to.Ptr("brazilsouth"), - Properties: &armmysql.ServerPropertiesForRestore{ - CreateMode: to.Ptr(armmysql.CreateModePointInTimeRestore), - RestorePointInTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-12-14T00:00:37.467Z"); return t }()), - SourceServerID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/servers/sourceserver"), - }, - SKU: &armmysql.SKU{ - Name: to.Ptr("GP_Gen5_2"), - Capacity: to.Ptr[int32](2), - Family: to.Ptr("Gen5"), - Tier: to.Ptr(armmysql.SKUTierGeneralPurpose), - }, - Tags: map[string]*string{ - "ElasticServer": to.Ptr("1"), - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerUpdate.json -func ExampleServersClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "testrg", - "mysqltestsvc4", - armmysql.ServerUpdateParameters{ - Properties: &armmysql.ServerUpdateParametersProperties{ - AdministratorLoginPassword: to.Ptr(""), - SSLEnforcement: to.Ptr(armmysql.SSLEnforcementEnumDisabled), - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerDelete.json -func ExampleServersClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "TestGroup", - "testserver", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerGet.json -func ExampleServersClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "testrg", - "mysqltestsvc4", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerListByResourceGroup.json -func ExampleServersClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("testrg", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerList.json -func ExampleServersClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", 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 - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerRestart.json -func ExampleServersClient_BeginRestart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginRestart(ctx, - "TestGroup", - "testserver", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2020-01-01/examples/ServerStart.json -func ExampleServersClient_BeginStart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStart(ctx, - "TestGroup", - "testserver", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2020-01-01/examples/ServerStop.json -func ExampleServersClient_BeginStop() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStop(ctx, - "TestGroup", - "testserver", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2020-01-01/examples/ServerUpgrade.json -func ExampleServersClient_BeginUpgrade() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpgrade(ctx, - "TestGroup", - "testserver", - armmysql.ServerUpgradeParameters{ - Properties: &armmysql.ServerUpgradeParametersProperties{ - TargetServerVersion: to.Ptr("5.7"), - }, - }, - 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) - } -} diff --git a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_serversecurityalertpolicies_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_serversecurityalertpolicies_client_test.go deleted file mode 100644 index 278a0be38e61..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_serversecurityalertpolicies_client_test.go +++ /dev/null @@ -1,108 +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 armmysql_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/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerSecurityAlertsGet.json -func ExampleServerSecurityAlertPoliciesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServerSecurityAlertPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "securityalert-4799", - "securityalert-6440", - armmysql.SecurityAlertPolicyNameDefault, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerSecurityAlertsCreateMax.json -func ExampleServerSecurityAlertPoliciesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServerSecurityAlertPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "securityalert-4799", - "securityalert-6440", - armmysql.SecurityAlertPolicyNameDefault, - armmysql.ServerSecurityAlertPolicy{ - Properties: &armmysql.SecurityAlertPolicyProperties{ - DisabledAlerts: []*string{ - to.Ptr("Access_Anomaly"), - to.Ptr("Usage_Anomaly")}, - EmailAccountAdmins: to.Ptr(true), - EmailAddresses: []*string{ - to.Ptr("testSecurityAlert@microsoft.com")}, - RetentionDays: to.Ptr[int32](5), - State: to.Ptr(armmysql.ServerSecurityAlertPolicyStateEnabled), - StorageAccountAccessKey: to.Ptr("sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD=="), - StorageEndpoint: to.Ptr("https://mystorage.blob.core.windows.net"), - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/ServerSecurityAlertsListByServer.json -func ExampleServerSecurityAlertPoliciesClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewServerSecurityAlertPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("securityalert-4799", - "securityalert-6440", - 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/mysql/armmysql/ze_generated_example_topquerystatistics_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_topquerystatistics_client_test.go deleted file mode 100644 index d3003a389ce8..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_topquerystatistics_client_test.go +++ /dev/null @@ -1,79 +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 armmysql_test - -import ( - "context" - "log" - - "time" - - "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/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/TopQueryStatisticsGet.json -func ExampleTopQueryStatisticsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewTopQueryStatisticsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "testResourceGroupName", - "testServerName", - "66-636923268000000000-636923277000000000-avg-duration", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/TopQueryStatisticsListByServer.json -func ExampleTopQueryStatisticsClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewTopQueryStatisticsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("testResourceGroupName", - "testServerName", - armmysql.TopQueryStatisticsInput{ - Properties: &armmysql.TopQueryStatisticsInputProperties{ - AggregationFunction: to.Ptr("avg"), - AggregationWindow: to.Ptr("PT15M"), - NumberOfTopQueries: to.Ptr[int32](5), - ObservationEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-07T20:00:00.000Z"); return t }()), - ObservationStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-01T20:00:00.000Z"); return t }()), - ObservedMetric: to.Ptr("duration"), - }, - }, - 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/mysql/armmysql/ze_generated_example_virtualnetworkrules_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_virtualnetworkrules_client_test.go deleted file mode 100644 index b9ce6472cb4d..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_virtualnetworkrules_client_test.go +++ /dev/null @@ -1,125 +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 armmysql_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/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/VirtualNetworkRulesGet.json -func ExampleVirtualNetworkRulesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewVirtualNetworkRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "TestGroup", - "vnet-test-svr", - "vnet-firewall-rule", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/VirtualNetworkRulesCreateOrUpdate.json -func ExampleVirtualNetworkRulesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewVirtualNetworkRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "TestGroup", - "vnet-test-svr", - "vnet-firewall-rule", - armmysql.VirtualNetworkRule{ - Properties: &armmysql.VirtualNetworkRuleProperties{ - IgnoreMissingVnetServiceEndpoint: to.Ptr(false), - VirtualNetworkSubnetID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/VirtualNetworkRulesDelete.json -func ExampleVirtualNetworkRulesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewVirtualNetworkRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "TestGroup", - "vnet-test-svr", - "vnet-firewall-rule", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/VirtualNetworkRulesList.json -func ExampleVirtualNetworkRulesClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewVirtualNetworkRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("TestGroup", - "vnet-test-svr", - 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/mysql/armmysql/ze_generated_example_waitstatistics_client_test.go b/sdk/resourcemanager/mysql/armmysql/ze_generated_example_waitstatistics_client_test.go deleted file mode 100644 index cef782d17b44..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/ze_generated_example_waitstatistics_client_test.go +++ /dev/null @@ -1,76 +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 armmysql_test - -import ( - "context" - "log" - - "time" - - "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/mysql/armmysql" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/WaitStatisticsGet.json -func ExampleWaitStatisticsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewWaitStatisticsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "testResourceGroupName", - "testServerName", - "636927606000000000-636927615000000000-send-wait/io/socket/sql/client_connection-2--0", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2018-06-01/examples/WaitStatisticsListByServer.json -func ExampleWaitStatisticsClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysql.NewWaitStatisticsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("testResourceGroupName", - "testServerName", - armmysql.WaitStatisticsInput{ - Properties: &armmysql.WaitStatisticsInputProperties{ - AggregationWindow: to.Ptr("PT15M"), - ObservationEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-07T20:00:00.000Z"); return t }()), - ObservationStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-01T20:00:00.000Z"); return t }()), - }, - }, - 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/mysql/armmysql/zz_generated_models_serde.go b/sdk/resourcemanager/mysql/armmysql/zz_generated_models_serde.go deleted file mode 100644 index 7f03b086bb1b..000000000000 --- a/sdk/resourcemanager/mysql/armmysql/zz_generated_models_serde.go +++ /dev/null @@ -1,823 +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 armmysql - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type ConfigurationListResult. -func (c ConfigurationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "value", c.Value) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type LogFileProperties. -func (l LogFileProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdTime", l.CreatedTime) - populateTimeRFC3339(objectMap, "lastModifiedTime", l.LastModifiedTime) - populate(objectMap, "sizeInKB", l.SizeInKB) - populate(objectMap, "type", l.Type) - populate(objectMap, "url", l.URL) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type LogFileProperties. -func (l *LogFileProperties) 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 "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &l.CreatedTime) - delete(rawMsg, key) - case "lastModifiedTime": - err = unpopulateTimeRFC3339(val, "LastModifiedTime", &l.LastModifiedTime) - delete(rawMsg, key) - case "sizeInKB": - err = unpopulate(val, "SizeInKB", &l.SizeInKB) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &l.Type) - delete(rawMsg, key) - case "url": - err = unpopulate(val, "URL", &l.URL) - 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 PrivateLinkResourceProperties. -func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "groupId", p.GroupID) - populate(objectMap, "requiredMembers", p.RequiredMembers) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type QueryStatisticProperties. -func (q QueryStatisticProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "aggregationFunction", q.AggregationFunction) - populate(objectMap, "databaseNames", q.DatabaseNames) - populateTimeRFC3339(objectMap, "endTime", q.EndTime) - populate(objectMap, "metricDisplayName", q.MetricDisplayName) - populate(objectMap, "metricName", q.MetricName) - populate(objectMap, "metricValue", q.MetricValue) - populate(objectMap, "metricValueUnit", q.MetricValueUnit) - populate(objectMap, "queryExecutionCount", q.QueryExecutionCount) - populate(objectMap, "queryId", q.QueryID) - populateTimeRFC3339(objectMap, "startTime", q.StartTime) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type QueryStatisticProperties. -func (q *QueryStatisticProperties) 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", q, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "aggregationFunction": - err = unpopulate(val, "AggregationFunction", &q.AggregationFunction) - delete(rawMsg, key) - case "databaseNames": - err = unpopulate(val, "DatabaseNames", &q.DatabaseNames) - delete(rawMsg, key) - case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &q.EndTime) - delete(rawMsg, key) - case "metricDisplayName": - err = unpopulate(val, "MetricDisplayName", &q.MetricDisplayName) - delete(rawMsg, key) - case "metricName": - err = unpopulate(val, "MetricName", &q.MetricName) - delete(rawMsg, key) - case "metricValue": - err = unpopulate(val, "MetricValue", &q.MetricValue) - delete(rawMsg, key) - case "metricValueUnit": - err = unpopulate(val, "MetricValueUnit", &q.MetricValueUnit) - delete(rawMsg, key) - case "queryExecutionCount": - err = unpopulate(val, "QueryExecutionCount", &q.QueryExecutionCount) - delete(rawMsg, key) - case "queryId": - err = unpopulate(val, "QueryID", &q.QueryID) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &q.StartTime) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", q, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type RecommendationActionProperties. -func (r RecommendationActionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "actionId", r.ActionID) - populate(objectMap, "advisorName", r.AdvisorName) - populateTimeRFC3339(objectMap, "createdTime", r.CreatedTime) - populate(objectMap, "details", r.Details) - populateTimeRFC3339(objectMap, "expirationTime", r.ExpirationTime) - populate(objectMap, "reason", r.Reason) - populate(objectMap, "recommendationType", r.RecommendationType) - populate(objectMap, "sessionId", r.SessionID) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RecommendationActionProperties. -func (r *RecommendationActionProperties) 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 "actionId": - err = unpopulate(val, "ActionID", &r.ActionID) - delete(rawMsg, key) - case "advisorName": - err = unpopulate(val, "AdvisorName", &r.AdvisorName) - delete(rawMsg, key) - case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &r.CreatedTime) - delete(rawMsg, key) - case "details": - err = unpopulate(val, "Details", &r.Details) - delete(rawMsg, key) - case "expirationTime": - err = unpopulateTimeRFC3339(val, "ExpirationTime", &r.ExpirationTime) - delete(rawMsg, key) - case "reason": - err = unpopulate(val, "Reason", &r.Reason) - delete(rawMsg, key) - case "recommendationType": - err = unpopulate(val, "RecommendationType", &r.RecommendationType) - delete(rawMsg, key) - case "sessionId": - err = unpopulate(val, "SessionID", &r.SessionID) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RecommendedActionSessionsOperationStatus. -func (r *RecommendedActionSessionsOperationStatus) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "name": - err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &r.StartTime) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &r.Status) - 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 SecurityAlertPolicyProperties. -func (s SecurityAlertPolicyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "disabledAlerts", s.DisabledAlerts) - populate(objectMap, "emailAccountAdmins", s.EmailAccountAdmins) - populate(objectMap, "emailAddresses", s.EmailAddresses) - populate(objectMap, "retentionDays", s.RetentionDays) - populate(objectMap, "state", s.State) - populate(objectMap, "storageAccountAccessKey", s.StorageAccountAccessKey) - populate(objectMap, "storageEndpoint", s.StorageEndpoint) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Server. -func (s Server) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", s.ID) - populate(objectMap, "identity", s.Identity) - populate(objectMap, "location", s.Location) - populate(objectMap, "name", s.Name) - populate(objectMap, "properties", s.Properties) - populate(objectMap, "sku", s.SKU) - populate(objectMap, "tags", s.Tags) - populate(objectMap, "type", s.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ServerForCreate. -func (s ServerForCreate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "identity", s.Identity) - populate(objectMap, "location", s.Location) - populate(objectMap, "properties", s.Properties) - populate(objectMap, "sku", s.SKU) - populate(objectMap, "tags", s.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ServerForCreate. -func (s *ServerForCreate) 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 "identity": - err = unpopulate(val, "Identity", &s.Identity) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &s.Location) - delete(rawMsg, key) - case "properties": - s.Properties, err = unmarshalServerPropertiesForCreateClassification(val) - delete(rawMsg, key) - case "sku": - err = unpopulate(val, "SKU", &s.SKU) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &s.Tags) - 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 ServerKeyProperties. -func (s ServerKeyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "creationDate", s.CreationDate) - populate(objectMap, "serverKeyType", s.ServerKeyType) - populate(objectMap, "uri", s.URI) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ServerKeyProperties. -func (s *ServerKeyProperties) 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 "creationDate": - err = unpopulateTimeRFC3339(val, "CreationDate", &s.CreationDate) - delete(rawMsg, key) - case "serverKeyType": - err = unpopulate(val, "ServerKeyType", &s.ServerKeyType) - delete(rawMsg, key) - case "uri": - err = unpopulate(val, "URI", &s.URI) - 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 ServerProperties. -func (s ServerProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "administratorLogin", s.AdministratorLogin) - populate(objectMap, "byokEnforcement", s.ByokEnforcement) - populateTimeRFC3339(objectMap, "earliestRestoreDate", s.EarliestRestoreDate) - populate(objectMap, "fullyQualifiedDomainName", s.FullyQualifiedDomainName) - populate(objectMap, "infrastructureEncryption", s.InfrastructureEncryption) - populate(objectMap, "masterServerId", s.MasterServerID) - populate(objectMap, "minimalTlsVersion", s.MinimalTLSVersion) - populate(objectMap, "privateEndpointConnections", s.PrivateEndpointConnections) - populate(objectMap, "publicNetworkAccess", s.PublicNetworkAccess) - populate(objectMap, "replicaCapacity", s.ReplicaCapacity) - populate(objectMap, "replicationRole", s.ReplicationRole) - populate(objectMap, "sslEnforcement", s.SSLEnforcement) - populate(objectMap, "storageProfile", s.StorageProfile) - populate(objectMap, "userVisibleState", s.UserVisibleState) - populate(objectMap, "version", s.Version) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ServerProperties. -func (s *ServerProperties) 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 "administratorLogin": - err = unpopulate(val, "AdministratorLogin", &s.AdministratorLogin) - delete(rawMsg, key) - case "byokEnforcement": - err = unpopulate(val, "ByokEnforcement", &s.ByokEnforcement) - delete(rawMsg, key) - case "earliestRestoreDate": - err = unpopulateTimeRFC3339(val, "EarliestRestoreDate", &s.EarliestRestoreDate) - delete(rawMsg, key) - case "fullyQualifiedDomainName": - err = unpopulate(val, "FullyQualifiedDomainName", &s.FullyQualifiedDomainName) - delete(rawMsg, key) - case "infrastructureEncryption": - err = unpopulate(val, "InfrastructureEncryption", &s.InfrastructureEncryption) - delete(rawMsg, key) - case "masterServerId": - err = unpopulate(val, "MasterServerID", &s.MasterServerID) - delete(rawMsg, key) - case "minimalTlsVersion": - err = unpopulate(val, "MinimalTLSVersion", &s.MinimalTLSVersion) - delete(rawMsg, key) - case "privateEndpointConnections": - err = unpopulate(val, "PrivateEndpointConnections", &s.PrivateEndpointConnections) - delete(rawMsg, key) - case "publicNetworkAccess": - err = unpopulate(val, "PublicNetworkAccess", &s.PublicNetworkAccess) - delete(rawMsg, key) - case "replicaCapacity": - err = unpopulate(val, "ReplicaCapacity", &s.ReplicaCapacity) - delete(rawMsg, key) - case "replicationRole": - err = unpopulate(val, "ReplicationRole", &s.ReplicationRole) - delete(rawMsg, key) - case "sslEnforcement": - err = unpopulate(val, "SSLEnforcement", &s.SSLEnforcement) - delete(rawMsg, key) - case "storageProfile": - err = unpopulate(val, "StorageProfile", &s.StorageProfile) - delete(rawMsg, key) - case "userVisibleState": - err = unpopulate(val, "UserVisibleState", &s.UserVisibleState) - delete(rawMsg, key) - case "version": - err = unpopulate(val, "Version", &s.Version) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ServerPropertiesForDefaultCreate. -func (s ServerPropertiesForDefaultCreate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "administratorLogin", s.AdministratorLogin) - populate(objectMap, "administratorLoginPassword", s.AdministratorLoginPassword) - objectMap["createMode"] = CreateModeDefault - populate(objectMap, "infrastructureEncryption", s.InfrastructureEncryption) - populate(objectMap, "minimalTlsVersion", s.MinimalTLSVersion) - populate(objectMap, "publicNetworkAccess", s.PublicNetworkAccess) - populate(objectMap, "sslEnforcement", s.SSLEnforcement) - populate(objectMap, "storageProfile", s.StorageProfile) - populate(objectMap, "version", s.Version) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ServerPropertiesForDefaultCreate. -func (s *ServerPropertiesForDefaultCreate) 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 "administratorLogin": - err = unpopulate(val, "AdministratorLogin", &s.AdministratorLogin) - delete(rawMsg, key) - case "administratorLoginPassword": - err = unpopulate(val, "AdministratorLoginPassword", &s.AdministratorLoginPassword) - delete(rawMsg, key) - case "createMode": - err = unpopulate(val, "CreateMode", &s.CreateMode) - delete(rawMsg, key) - case "infrastructureEncryption": - err = unpopulate(val, "InfrastructureEncryption", &s.InfrastructureEncryption) - delete(rawMsg, key) - case "minimalTlsVersion": - err = unpopulate(val, "MinimalTLSVersion", &s.MinimalTLSVersion) - delete(rawMsg, key) - case "publicNetworkAccess": - err = unpopulate(val, "PublicNetworkAccess", &s.PublicNetworkAccess) - delete(rawMsg, key) - case "sslEnforcement": - err = unpopulate(val, "SSLEnforcement", &s.SSLEnforcement) - delete(rawMsg, key) - case "storageProfile": - err = unpopulate(val, "StorageProfile", &s.StorageProfile) - delete(rawMsg, key) - case "version": - err = unpopulate(val, "Version", &s.Version) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ServerPropertiesForGeoRestore. -func (s ServerPropertiesForGeoRestore) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["createMode"] = CreateModeGeoRestore - populate(objectMap, "infrastructureEncryption", s.InfrastructureEncryption) - populate(objectMap, "minimalTlsVersion", s.MinimalTLSVersion) - populate(objectMap, "publicNetworkAccess", s.PublicNetworkAccess) - populate(objectMap, "sslEnforcement", s.SSLEnforcement) - populate(objectMap, "sourceServerId", s.SourceServerID) - populate(objectMap, "storageProfile", s.StorageProfile) - populate(objectMap, "version", s.Version) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ServerPropertiesForGeoRestore. -func (s *ServerPropertiesForGeoRestore) 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 "createMode": - err = unpopulate(val, "CreateMode", &s.CreateMode) - delete(rawMsg, key) - case "infrastructureEncryption": - err = unpopulate(val, "InfrastructureEncryption", &s.InfrastructureEncryption) - delete(rawMsg, key) - case "minimalTlsVersion": - err = unpopulate(val, "MinimalTLSVersion", &s.MinimalTLSVersion) - delete(rawMsg, key) - case "publicNetworkAccess": - err = unpopulate(val, "PublicNetworkAccess", &s.PublicNetworkAccess) - delete(rawMsg, key) - case "sslEnforcement": - err = unpopulate(val, "SSLEnforcement", &s.SSLEnforcement) - delete(rawMsg, key) - case "sourceServerId": - err = unpopulate(val, "SourceServerID", &s.SourceServerID) - delete(rawMsg, key) - case "storageProfile": - err = unpopulate(val, "StorageProfile", &s.StorageProfile) - delete(rawMsg, key) - case "version": - err = unpopulate(val, "Version", &s.Version) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ServerPropertiesForReplica. -func (s ServerPropertiesForReplica) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["createMode"] = CreateModeReplica - populate(objectMap, "infrastructureEncryption", s.InfrastructureEncryption) - populate(objectMap, "minimalTlsVersion", s.MinimalTLSVersion) - populate(objectMap, "publicNetworkAccess", s.PublicNetworkAccess) - populate(objectMap, "sslEnforcement", s.SSLEnforcement) - populate(objectMap, "sourceServerId", s.SourceServerID) - populate(objectMap, "storageProfile", s.StorageProfile) - populate(objectMap, "version", s.Version) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ServerPropertiesForReplica. -func (s *ServerPropertiesForReplica) 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 "createMode": - err = unpopulate(val, "CreateMode", &s.CreateMode) - delete(rawMsg, key) - case "infrastructureEncryption": - err = unpopulate(val, "InfrastructureEncryption", &s.InfrastructureEncryption) - delete(rawMsg, key) - case "minimalTlsVersion": - err = unpopulate(val, "MinimalTLSVersion", &s.MinimalTLSVersion) - delete(rawMsg, key) - case "publicNetworkAccess": - err = unpopulate(val, "PublicNetworkAccess", &s.PublicNetworkAccess) - delete(rawMsg, key) - case "sslEnforcement": - err = unpopulate(val, "SSLEnforcement", &s.SSLEnforcement) - delete(rawMsg, key) - case "sourceServerId": - err = unpopulate(val, "SourceServerID", &s.SourceServerID) - delete(rawMsg, key) - case "storageProfile": - err = unpopulate(val, "StorageProfile", &s.StorageProfile) - delete(rawMsg, key) - case "version": - err = unpopulate(val, "Version", &s.Version) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ServerPropertiesForRestore. -func (s ServerPropertiesForRestore) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["createMode"] = CreateModePointInTimeRestore - populate(objectMap, "infrastructureEncryption", s.InfrastructureEncryption) - populate(objectMap, "minimalTlsVersion", s.MinimalTLSVersion) - populate(objectMap, "publicNetworkAccess", s.PublicNetworkAccess) - populateTimeRFC3339(objectMap, "restorePointInTime", s.RestorePointInTime) - populate(objectMap, "sslEnforcement", s.SSLEnforcement) - populate(objectMap, "sourceServerId", s.SourceServerID) - populate(objectMap, "storageProfile", s.StorageProfile) - populate(objectMap, "version", s.Version) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ServerPropertiesForRestore. -func (s *ServerPropertiesForRestore) 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 "createMode": - err = unpopulate(val, "CreateMode", &s.CreateMode) - delete(rawMsg, key) - case "infrastructureEncryption": - err = unpopulate(val, "InfrastructureEncryption", &s.InfrastructureEncryption) - delete(rawMsg, key) - case "minimalTlsVersion": - err = unpopulate(val, "MinimalTLSVersion", &s.MinimalTLSVersion) - delete(rawMsg, key) - case "publicNetworkAccess": - err = unpopulate(val, "PublicNetworkAccess", &s.PublicNetworkAccess) - delete(rawMsg, key) - case "restorePointInTime": - err = unpopulateTimeRFC3339(val, "RestorePointInTime", &s.RestorePointInTime) - delete(rawMsg, key) - case "sslEnforcement": - err = unpopulate(val, "SSLEnforcement", &s.SSLEnforcement) - delete(rawMsg, key) - case "sourceServerId": - err = unpopulate(val, "SourceServerID", &s.SourceServerID) - delete(rawMsg, key) - case "storageProfile": - err = unpopulate(val, "StorageProfile", &s.StorageProfile) - delete(rawMsg, key) - case "version": - err = unpopulate(val, "Version", &s.Version) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ServerUpdateParameters. -func (s ServerUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "identity", s.Identity) - populate(objectMap, "properties", s.Properties) - populate(objectMap, "sku", s.SKU) - populate(objectMap, "tags", s.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TagsObject. -func (t TagsObject) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", t.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TopQueryStatisticsInputProperties. -func (t TopQueryStatisticsInputProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "aggregationFunction", t.AggregationFunction) - populate(objectMap, "aggregationWindow", t.AggregationWindow) - populate(objectMap, "numberOfTopQueries", t.NumberOfTopQueries) - populateTimeRFC3339(objectMap, "observationEndTime", t.ObservationEndTime) - populateTimeRFC3339(objectMap, "observationStartTime", t.ObservationStartTime) - populate(objectMap, "observedMetric", t.ObservedMetric) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type TopQueryStatisticsInputProperties. -func (t *TopQueryStatisticsInputProperties) 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 "aggregationFunction": - err = unpopulate(val, "AggregationFunction", &t.AggregationFunction) - delete(rawMsg, key) - case "aggregationWindow": - err = unpopulate(val, "AggregationWindow", &t.AggregationWindow) - delete(rawMsg, key) - case "numberOfTopQueries": - err = unpopulate(val, "NumberOfTopQueries", &t.NumberOfTopQueries) - delete(rawMsg, key) - case "observationEndTime": - err = unpopulateTimeRFC3339(val, "ObservationEndTime", &t.ObservationEndTime) - delete(rawMsg, key) - case "observationStartTime": - err = unpopulateTimeRFC3339(val, "ObservationStartTime", &t.ObservationStartTime) - delete(rawMsg, key) - case "observedMetric": - err = unpopulate(val, "ObservedMetric", &t.ObservedMetric) - 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 TrackedResource. -func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type WaitStatisticProperties. -func (w WaitStatisticProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "count", w.Count) - populate(objectMap, "databaseName", w.DatabaseName) - populateTimeRFC3339(objectMap, "endTime", w.EndTime) - populate(objectMap, "eventName", w.EventName) - populate(objectMap, "eventTypeName", w.EventTypeName) - populate(objectMap, "queryId", w.QueryID) - populateTimeRFC3339(objectMap, "startTime", w.StartTime) - populate(objectMap, "totalTimeInMs", w.TotalTimeInMs) - populate(objectMap, "userId", w.UserID) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WaitStatisticProperties. -func (w *WaitStatisticProperties) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "count": - err = unpopulate(val, "Count", &w.Count) - delete(rawMsg, key) - case "databaseName": - err = unpopulate(val, "DatabaseName", &w.DatabaseName) - delete(rawMsg, key) - case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &w.EndTime) - delete(rawMsg, key) - case "eventName": - err = unpopulate(val, "EventName", &w.EventName) - delete(rawMsg, key) - case "eventTypeName": - err = unpopulate(val, "EventTypeName", &w.EventTypeName) - delete(rawMsg, key) - case "queryId": - err = unpopulate(val, "QueryID", &w.QueryID) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &w.StartTime) - delete(rawMsg, key) - case "totalTimeInMs": - err = unpopulate(val, "TotalTimeInMs", &w.TotalTimeInMs) - delete(rawMsg, key) - case "userId": - err = unpopulate(val, "UserID", &w.UserID) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type WaitStatisticsInputProperties. -func (w WaitStatisticsInputProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "aggregationWindow", w.AggregationWindow) - populateTimeRFC3339(objectMap, "observationEndTime", w.ObservationEndTime) - populateTimeRFC3339(objectMap, "observationStartTime", w.ObservationStartTime) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WaitStatisticsInputProperties. -func (w *WaitStatisticsInputProperties) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "aggregationWindow": - err = unpopulate(val, "AggregationWindow", &w.AggregationWindow) - delete(rawMsg, key) - case "observationEndTime": - err = unpopulateTimeRFC3339(val, "ObservationEndTime", &w.ObservationEndTime) - delete(rawMsg, key) - case "observationStartTime": - err = unpopulateTimeRFC3339(val, "ObservationStartTime", &w.ObservationStartTime) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, 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/mysql/armmysqlflexibleservers/CHANGELOG.md b/sdk/resourcemanager/mysql/armmysqlflexibleservers/CHANGELOG.md index 4652e4355fd0..f2d19faa4345 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/CHANGELOG.md +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-05-17) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers` 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/mysql/armmysqlflexibleservers/README.md b/sdk/resourcemanager/mysql/armmysqlflexibleservers/README.md index fe9ce42cae8f..758e4f1d4e48 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/README.md +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Database for MySQL modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Database for MySQL module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armmysqlflexibleservers.NewDatabasesClient(, cred, nil) +clientFactory, err := armmysqlflexibleservers.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armmysqlflexibleservers.NewDatabasesClient(, cred, &options) +clientFactory, err := armmysqlflexibleservers.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewDatabasesClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/autorest.md b/sdk/resourcemanager/mysql/armmysqlflexibleservers/autorest.md index f75153a497f6..dd03feb806ba 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/autorest.md +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 package-flexibleservers: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_backups_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/backups_client.go similarity index 82% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_backups_client.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/backups_client.go index 73951610d647..5287b47d89c1 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_backups_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/backups_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 armmysqlflexibleservers @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // BackupsClient contains the methods for the Backups group. // Don't use this type directly, use NewBackupsClient() instead. type BackupsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewBackupsClient creates a new instance of BackupsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewBackupsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BackupsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".BackupsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &BackupsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - List all the backups for a given server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// backupName - The name of the backup. -// options - BackupsClientGetOptions contains the optional parameters for the BackupsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - backupName - The name of the backup. +// - options - BackupsClientGetOptions contains the optional parameters for the BackupsClient.Get method. func (client *BackupsClient) Get(ctx context.Context, resourceGroupName string, serverName string, backupName string, options *BackupsClientGetOptions) (BackupsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, backupName, options) if err != nil { return BackupsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BackupsClientGetResponse{}, err } @@ -95,7 +86,7 @@ func (client *BackupsClient) getCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter backupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{backupName}", url.PathEscape(backupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -116,11 +107,12 @@ func (client *BackupsClient) getHandleResponse(resp *http.Response) (BackupsClie } // NewListByServerPager - List all the backups for a given server. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - BackupsClientListByServerOptions contains the optional parameters for the BackupsClient.ListByServer method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - BackupsClientListByServerOptions contains the optional parameters for the BackupsClient.NewListByServerPager +// method. func (client *BackupsClient) NewListByServerPager(resourceGroupName string, serverName string, options *BackupsClientListByServerOptions) *runtime.Pager[BackupsClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[BackupsClientListByServerResponse]{ More: func(page BackupsClientListByServerResponse) bool { @@ -137,7 +129,7 @@ func (client *BackupsClient) NewListByServerPager(resourceGroupName string, serv if err != nil { return BackupsClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BackupsClientListByServerResponse{}, err } @@ -164,7 +156,7 @@ func (client *BackupsClient) listByServerCreateRequest(ctx context.Context, reso return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/backups_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/backups_client_example_test.go new file mode 100644 index 000000000000..862667091e36 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/backups_client_example_test.go @@ -0,0 +1,186 @@ +//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 armmysqlflexibleservers_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/BackupGet.json +func ExampleBackupsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBackupsClient().Get(ctx, "TestGroup", "mysqltestserver", "daily_20210615T160516", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ServerBackup = armmysqlflexibleservers.ServerBackup{ + // Name: to.Ptr("daily_20210615T160516"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/backups"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/backups/daily_20210615T160516"), + // Properties: &armmysqlflexibleservers.ServerBackupProperties{ + // BackupType: to.Ptr("FULL"), + // CompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T16:05:19.902522+00:00"); return t}()), + // Source: to.Ptr("Automatic"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/BackupsListByServer.json +func ExampleBackupsClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewBackupsClient().NewListByServerPager("TestGroup", "mysqltestserver", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ServerBackupListResult = armmysqlflexibleservers.ServerBackupListResult{ + // Value: []*armmysqlflexibleservers.ServerBackup{ + // { + // Name: to.Ptr("daily_20210615T160516"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/backups"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/backups/daily_20210615T160516"), + // Properties: &armmysqlflexibleservers.ServerBackupProperties{ + // BackupType: to.Ptr("FULL"), + // CompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T16:05:19.902522+00:00"); return t}()), + // Source: to.Ptr("Automatic"), + // }, + // }, + // { + // Name: to.Ptr("daily_20210616T160520"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/backups"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/backups/daily_20210616T160520"), + // Properties: &armmysqlflexibleservers.ServerBackupProperties{ + // BackupType: to.Ptr("FULL"), + // CompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-16T16:05:23.9243453+00:00"); return t}()), + // Source: to.Ptr("Automatic"), + // }, + // }, + // { + // Name: to.Ptr("daily_20210617T160525"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/backups"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/backups/daily_20210617T160525"), + // Properties: &armmysqlflexibleservers.ServerBackupProperties{ + // BackupType: to.Ptr("FULL"), + // CompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T16:05:28.1247488+00:00"); return t}()), + // Source: to.Ptr("Automatic"), + // }, + // }, + // { + // Name: to.Ptr("daily_20210618T160529"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/backups"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/backups/daily_20210618T160529"), + // Properties: &armmysqlflexibleservers.ServerBackupProperties{ + // BackupType: to.Ptr("FULL"), + // CompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-18T16:05:32.2736701+00:00"); return t}()), + // Source: to.Ptr("Automatic"), + // }, + // }, + // { + // Name: to.Ptr("daily_20210619T160533"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/backups"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/backups/daily_20210619T160533"), + // Properties: &armmysqlflexibleservers.ServerBackupProperties{ + // BackupType: to.Ptr("FULL"), + // CompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T16:05:36.8603354+00:00"); return t}()), + // Source: to.Ptr("Automatic"), + // }, + // }, + // { + // Name: to.Ptr("daily_20210620T160538"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/backups"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/backups/daily_20210620T160538"), + // Properties: &armmysqlflexibleservers.ServerBackupProperties{ + // BackupType: to.Ptr("FULL"), + // CompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-20T16:05:41.9200138+00:00"); return t}()), + // Source: to.Ptr("Automatic"), + // }, + // }, + // { + // Name: to.Ptr("daily_20210621T160543"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/backups"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/backups/daily_20210621T160543"), + // Properties: &armmysqlflexibleservers.ServerBackupProperties{ + // BackupType: to.Ptr("FULL"), + // CompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-21T16:05:48.8528447+00:00"); return t}()), + // Source: to.Ptr("Automatic"), + // }, + // }, + // { + // Name: to.Ptr("daily_20210622T160803"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/backups"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/backups/daily_20210622T160803"), + // Properties: &armmysqlflexibleservers.ServerBackupProperties{ + // BackupType: to.Ptr("FULL"), + // CompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-22T16:08:06.3121688+00:00"); return t}()), + // Source: to.Ptr("Automatic"), + // }, + // }, + // { + // Name: to.Ptr("daily_20210622T210807"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/backups"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/backups/daily_20210622T210807"), + // Properties: &armmysqlflexibleservers.ServerBackupProperties{ + // BackupType: to.Ptr("FULL"), + // CompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-22T21:08:10.5057354+00:00"); return t}()), + // Source: to.Ptr("Automatic"), + // }, + // }, + // { + // Name: to.Ptr("daily_20210623T212413"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/backups"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/backups/daily_20210623T212413"), + // Properties: &armmysqlflexibleservers.ServerBackupProperties{ + // BackupType: to.Ptr("FULL"), + // CompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-23T21:24:16.9401531+00:00"); return t}()), + // Source: to.Ptr("Automatic"), + // }, + // }, + // { + // Name: to.Ptr("daily_20210624T061328"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/backups"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/backups/daily_20210624T061328"), + // Properties: &armmysqlflexibleservers.ServerBackupProperties{ + // BackupType: to.Ptr("FULL"), + // CompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-24T06:13:31.4962137+00:00"); return t}()), + // Source: to.Ptr("Automatic"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_checknameavailability_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailability_client.go similarity index 77% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_checknameavailability_client.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailability_client.go index 6efd21f39f57..c32a3a9e1648 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_checknameavailability_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailability_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 armmysqlflexibleservers @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // CheckNameAvailabilityClient contains the methods for the CheckNameAvailability group. // Don't use this type directly, use NewCheckNameAvailabilityClient() instead. type CheckNameAvailabilityClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCheckNameAvailabilityClient creates a new instance of CheckNameAvailabilityClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCheckNameAvailabilityClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CheckNameAvailabilityClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CheckNameAvailabilityClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CheckNameAvailabilityClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Execute - Check the availability of name for server // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// locationName - The name of the location. -// nameAvailabilityRequest - The required parameters for checking if server name is available. -// options - CheckNameAvailabilityClientExecuteOptions contains the optional parameters for the CheckNameAvailabilityClient.Execute -// method. +// - locationName - The name of the location. +// - nameAvailabilityRequest - The required parameters for checking if server name is available. +// - options - CheckNameAvailabilityClientExecuteOptions contains the optional parameters for the CheckNameAvailabilityClient.Execute +// method. func (client *CheckNameAvailabilityClient) Execute(ctx context.Context, locationName string, nameAvailabilityRequest NameAvailabilityRequest, options *CheckNameAvailabilityClientExecuteOptions) (CheckNameAvailabilityClientExecuteResponse, error) { req, err := client.executeCreateRequest(ctx, locationName, nameAvailabilityRequest, options) if err != nil { return CheckNameAvailabilityClientExecuteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CheckNameAvailabilityClientExecuteResponse{}, err } @@ -87,7 +78,7 @@ func (client *CheckNameAvailabilityClient) executeCreateRequest(ctx context.Cont return nil, errors.New("parameter locationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_checknameavailability_client_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailability_client_example_test.go similarity index 51% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_checknameavailability_client_test.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailability_client_example_test.go index e4073bf36774..e6e26026ffa5 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_checknameavailability_client_test.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailability_client_example_test.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 armmysqlflexibleservers_test @@ -17,27 +18,30 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/CheckNameAvailability.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/CheckNameAvailability.json func ExampleCheckNameAvailabilityClient_Execute() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmysqlflexibleservers.NewCheckNameAvailabilityClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Execute(ctx, - "SouthEastAsia", - armmysqlflexibleservers.NameAvailabilityRequest{ - Name: to.Ptr("name1"), - Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), - }, - nil) + res, err := clientFactory.NewCheckNameAvailabilityClient().Execute(ctx, "SouthEastAsia", armmysqlflexibleservers.NameAvailabilityRequest{ + Name: to.Ptr("name1"), + Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.NameAvailability = armmysqlflexibleservers.NameAvailability{ + // Message: to.Ptr(""), + // NameAvailable: to.Ptr(true), + // Reason: to.Ptr(""), + // } } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_checkvirtualnetworksubnetusage_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checkvirtualnetworksubnetusage_client.go similarity index 78% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_checkvirtualnetworksubnetusage_client.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/checkvirtualnetworksubnetusage_client.go index b76adb5daee7..ed41d242f287 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_checkvirtualnetworksubnetusage_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checkvirtualnetworksubnetusage_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 armmysqlflexibleservers @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // CheckVirtualNetworkSubnetUsageClient contains the methods for the CheckVirtualNetworkSubnetUsage group. // Don't use this type directly, use NewCheckVirtualNetworkSubnetUsageClient() instead. type CheckVirtualNetworkSubnetUsageClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCheckVirtualNetworkSubnetUsageClient creates a new instance of CheckVirtualNetworkSubnetUsageClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCheckVirtualNetworkSubnetUsageClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CheckVirtualNetworkSubnetUsageClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CheckVirtualNetworkSubnetUsageClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CheckVirtualNetworkSubnetUsageClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Execute - Get virtual network subnet usage for a given vNet resource id. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// locationName - The name of the location. -// parameters - The required parameters for creating or updating a server. -// options - CheckVirtualNetworkSubnetUsageClientExecuteOptions contains the optional parameters for the CheckVirtualNetworkSubnetUsageClient.Execute -// method. +// - locationName - The name of the location. +// - parameters - The required parameters for creating or updating a server. +// - options - CheckVirtualNetworkSubnetUsageClientExecuteOptions contains the optional parameters for the CheckVirtualNetworkSubnetUsageClient.Execute +// method. func (client *CheckVirtualNetworkSubnetUsageClient) Execute(ctx context.Context, locationName string, parameters VirtualNetworkSubnetUsageParameter, options *CheckVirtualNetworkSubnetUsageClientExecuteOptions) (CheckVirtualNetworkSubnetUsageClientExecuteResponse, error) { req, err := client.executeCreateRequest(ctx, locationName, parameters, options) if err != nil { return CheckVirtualNetworkSubnetUsageClientExecuteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CheckVirtualNetworkSubnetUsageClientExecuteResponse{}, err } @@ -87,7 +78,7 @@ func (client *CheckVirtualNetworkSubnetUsageClient) executeCreateRequest(ctx con return nil, errors.New("parameter locationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/checkvirtualnetworksubnetusage_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checkvirtualnetworksubnetusage_client_example_test.go new file mode 100644 index 000000000000..8d800a4f3e85 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checkvirtualnetworksubnetusage_client_example_test.go @@ -0,0 +1,52 @@ +//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 armmysqlflexibleservers_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/mysql/armmysqlflexibleservers" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/CheckVirtualNetworkSubnetUsage.json +func ExampleCheckVirtualNetworkSubnetUsageClient_Execute() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCheckVirtualNetworkSubnetUsageClient().Execute(ctx, "WestUS", armmysqlflexibleservers.VirtualNetworkSubnetUsageParameter{ + VirtualNetworkResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/testvnet"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VirtualNetworkSubnetUsageResult = armmysqlflexibleservers.VirtualNetworkSubnetUsageResult{ + // DelegatedSubnetsUsage: []*armmysqlflexibleservers.DelegatedSubnetUsage{ + // { + // SubnetName: to.Ptr("test-subnet-1"), + // Usage: to.Ptr[int64](2), + // }, + // { + // SubnetName: to.Ptr("test-subnet-2"), + // Usage: to.Ptr[int64](3), + // }}, + // } +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/client_factory.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/client_factory.go new file mode 100644 index 000000000000..938882c6f81d --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/client_factory.go @@ -0,0 +1,94 @@ +//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 armmysqlflexibleservers + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewServersClient() *ServersClient { + subClient, _ := NewServersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewReplicasClient() *ReplicasClient { + subClient, _ := NewReplicasClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewBackupsClient() *BackupsClient { + subClient, _ := NewBackupsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewFirewallRulesClient() *FirewallRulesClient { + subClient, _ := NewFirewallRulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDatabasesClient() *DatabasesClient { + subClient, _ := NewDatabasesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewConfigurationsClient() *ConfigurationsClient { + subClient, _ := NewConfigurationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLocationBasedCapabilitiesClient() *LocationBasedCapabilitiesClient { + subClient, _ := NewLocationBasedCapabilitiesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCheckVirtualNetworkSubnetUsageClient() *CheckVirtualNetworkSubnetUsageClient { + subClient, _ := NewCheckVirtualNetworkSubnetUsageClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCheckNameAvailabilityClient() *CheckNameAvailabilityClient { + subClient, _ := NewCheckNameAvailabilityClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewGetPrivateDNSZoneSuffixClient() *GetPrivateDNSZoneSuffixClient { + subClient, _ := NewGetPrivateDNSZoneSuffixClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_configurations_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/configurations_client.go similarity index 83% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_configurations_client.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/configurations_client.go index e0a3bad6121e..ebfd334e1ed4 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_configurations_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/configurations_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 armmysqlflexibleservers @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,66 +24,59 @@ import ( // ConfigurationsClient contains the methods for the Configurations group. // Don't use this type directly, use NewConfigurationsClient() instead. type ConfigurationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewConfigurationsClient creates a new instance of ConfigurationsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ConfigurationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ConfigurationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ConfigurationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginBatchUpdate - Update a list of configurations in a given server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// parameters - The parameters for updating a list of server configuration. -// options - ConfigurationsClientBeginBatchUpdateOptions contains the optional parameters for the ConfigurationsClient.BeginBatchUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - parameters - The parameters for updating a list of server configuration. +// - options - ConfigurationsClientBeginBatchUpdateOptions contains the optional parameters for the ConfigurationsClient.BeginBatchUpdate +// method. func (client *ConfigurationsClient) BeginBatchUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ConfigurationListForBatchUpdate, options *ConfigurationsClientBeginBatchUpdateOptions) (*runtime.Poller[ConfigurationsClientBatchUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.batchUpdate(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ConfigurationsClientBatchUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConfigurationsClientBatchUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[ConfigurationsClientBatchUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ConfigurationsClientBatchUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // BatchUpdate - Update a list of configurations in a given server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *ConfigurationsClient) batchUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ConfigurationListForBatchUpdate, options *ConfigurationsClientBeginBatchUpdateOptions) (*http.Response, error) { req, err := client.batchUpdateCreateRequest(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -109,7 +101,7 @@ func (client *ConfigurationsClient) batchUpdateCreateRequest(ctx context.Context return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -122,17 +114,18 @@ func (client *ConfigurationsClient) batchUpdateCreateRequest(ctx context.Context // Get - Gets information about a configuration of server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// configurationName - The name of the server configuration. -// options - ConfigurationsClientGetOptions contains the optional parameters for the ConfigurationsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - configurationName - The name of the server configuration. +// - options - ConfigurationsClientGetOptions contains the optional parameters for the ConfigurationsClient.Get method. func (client *ConfigurationsClient) Get(ctx context.Context, resourceGroupName string, serverName string, configurationName string, options *ConfigurationsClientGetOptions) (ConfigurationsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, configurationName, options) if err != nil { return ConfigurationsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConfigurationsClientGetResponse{}, err } @@ -161,7 +154,7 @@ func (client *ConfigurationsClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter configurationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(configurationName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -182,12 +175,12 @@ func (client *ConfigurationsClient) getHandleResponse(resp *http.Response) (Conf } // NewListByServerPager - List all the configurations in a given server. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ConfigurationsClientListByServerOptions contains the optional parameters for the ConfigurationsClient.ListByServer -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ConfigurationsClientListByServerOptions contains the optional parameters for the ConfigurationsClient.NewListByServerPager +// method. func (client *ConfigurationsClient) NewListByServerPager(resourceGroupName string, serverName string, options *ConfigurationsClientListByServerOptions) *runtime.Pager[ConfigurationsClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[ConfigurationsClientListByServerResponse]{ More: func(page ConfigurationsClientListByServerResponse) bool { @@ -204,7 +197,7 @@ func (client *ConfigurationsClient) NewListByServerPager(resourceGroupName strin if err != nil { return ConfigurationsClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConfigurationsClientListByServerResponse{}, err } @@ -231,7 +224,7 @@ func (client *ConfigurationsClient) listByServerCreateRequest(ctx context.Contex return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -253,34 +246,36 @@ func (client *ConfigurationsClient) listByServerHandleResponse(resp *http.Respon // BeginUpdate - Updates a configuration of a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// configurationName - The name of the server configuration. -// parameters - The required parameters for updating a server configuration. -// options - ConfigurationsClientBeginUpdateOptions contains the optional parameters for the ConfigurationsClient.BeginUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - configurationName - The name of the server configuration. +// - parameters - The required parameters for updating a server configuration. +// - options - ConfigurationsClientBeginUpdateOptions contains the optional parameters for the ConfigurationsClient.BeginUpdate +// method. func (client *ConfigurationsClient) BeginUpdate(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsClientBeginUpdateOptions) (*runtime.Poller[ConfigurationsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, serverName, configurationName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[ConfigurationsClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[ConfigurationsClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ConfigurationsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ConfigurationsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates a configuration of a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *ConfigurationsClient) update(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, serverName, configurationName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -309,7 +304,7 @@ func (client *ConfigurationsClient) updateCreateRequest(ctx context.Context, res return nil, errors.New("parameter configurationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(configurationName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/configurations_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/configurations_client_example_test.go new file mode 100644 index 000000000000..f5470234e5bf --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/configurations_client_example_test.go @@ -0,0 +1,329 @@ +//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 armmysqlflexibleservers_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/mysql/armmysqlflexibleservers" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ConfigurationUpdate.json +func ExampleConfigurationsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewConfigurationsClient().BeginUpdate(ctx, "testrg", "testserver", "event_scheduler", armmysqlflexibleservers.Configuration{ + Properties: &armmysqlflexibleservers.ConfigurationProperties{ + Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceUserOverride), + Value: to.Ptr("on"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Configuration = armmysqlflexibleservers.Configuration{ + // Name: to.Ptr("event_scheduler"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/testserver/configurations/event_scheduler"), + // Properties: &armmysqlflexibleservers.ConfigurationProperties{ + // Description: to.Ptr("Indicates the status of the Event Scheduler. It is always OFF for a replica server to keep the replication consistency."), + // AllowedValues: to.Ptr("ON,OFF"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // IsConfigPendingRestart: to.Ptr(armmysqlflexibleservers.IsConfigPendingRestartFalse), + // IsDynamicConfig: to.Ptr(armmysqlflexibleservers.IsDynamicConfigTrue), + // IsReadOnly: to.Ptr(armmysqlflexibleservers.IsReadOnlyFalse), + // Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceUserOverride), + // Value: to.Ptr("ON"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ConfigurationGet.json +func ExampleConfigurationsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewConfigurationsClient().Get(ctx, "TestGroup", "testserver", "event_scheduler", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Configuration = armmysqlflexibleservers.Configuration{ + // Name: to.Ptr("event_scheduler"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/testserver/configurations/event_scheduler"), + // Properties: &armmysqlflexibleservers.ConfigurationProperties{ + // Description: to.Ptr("Indicates the status of the Event Scheduler. It is always OFF for a replica server to keep the replication consistency."), + // AllowedValues: to.Ptr("ON,OFF"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // IsConfigPendingRestart: to.Ptr(armmysqlflexibleservers.IsConfigPendingRestartFalse), + // IsDynamicConfig: to.Ptr(armmysqlflexibleservers.IsDynamicConfigTrue), + // IsReadOnly: to.Ptr(armmysqlflexibleservers.IsReadOnlyFalse), + // Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceSystemDefault), + // Value: to.Ptr("OFF"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ConfigurationsBatchUpdate.json +func ExampleConfigurationsClient_BeginBatchUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewConfigurationsClient().BeginBatchUpdate(ctx, "testrg", "mysqltestserver", armmysqlflexibleservers.ConfigurationListForBatchUpdate{ + Value: []*armmysqlflexibleservers.ConfigurationForBatchUpdate{ + { + Name: to.Ptr("event_scheduler"), + Properties: &armmysqlflexibleservers.ConfigurationForBatchUpdateProperties{ + Value: to.Ptr("OFF"), + }, + }, + { + Name: to.Ptr("div_precision_increment"), + Properties: &armmysqlflexibleservers.ConfigurationForBatchUpdateProperties{ + Value: to.Ptr("8"), + }, + }}, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ConfigurationListResult = armmysqlflexibleservers.ConfigurationListResult{ + // Value: []*armmysqlflexibleservers.Configuration{ + // { + // Name: to.Ptr("event_scheduler"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/configurations/event_scheduler"), + // Properties: &armmysqlflexibleservers.ConfigurationProperties{ + // Description: to.Ptr("Indicates the status of the Event Scheduler. It is always OFF for a replica server to keep the replication consistency."), + // AllowedValues: to.Ptr("ON,OFF"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // IsConfigPendingRestart: to.Ptr(armmysqlflexibleservers.IsConfigPendingRestartFalse), + // IsDynamicConfig: to.Ptr(armmysqlflexibleservers.IsDynamicConfigTrue), + // IsReadOnly: to.Ptr(armmysqlflexibleservers.IsReadOnlyFalse), + // Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceUserOverride), + // Value: to.Ptr("ON"), + // }, + // }, + // { + // Name: to.Ptr("div_precision_increment"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/configurations/div_precision_increment"), + // Properties: &armmysqlflexibleservers.ConfigurationProperties{ + // Description: to.Ptr("Number of digits by which to increase the scale of the result of division operations."), + // AllowedValues: to.Ptr("0-30"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("4"), + // IsConfigPendingRestart: to.Ptr(armmysqlflexibleservers.IsConfigPendingRestartFalse), + // IsDynamicConfig: to.Ptr(armmysqlflexibleservers.IsDynamicConfigTrue), + // IsReadOnly: to.Ptr(armmysqlflexibleservers.IsReadOnlyFalse), + // Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceUserOverride), + // Value: to.Ptr("8"), + // }, + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ConfigurationsListByServer.json +func ExampleConfigurationsClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewConfigurationsClient().NewListByServerPager("testrg", "mysqltestserver", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ConfigurationListResult = armmysqlflexibleservers.ConfigurationListResult{ + // Value: []*armmysqlflexibleservers.Configuration{ + // { + // Name: to.Ptr("archive"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/configurations/archive"), + // Properties: &armmysqlflexibleservers.ConfigurationProperties{ + // Description: to.Ptr("Tell the server to enable or disable archive engine."), + // AllowedValues: to.Ptr("ON,OFF"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // IsConfigPendingRestart: to.Ptr(armmysqlflexibleservers.IsConfigPendingRestartFalse), + // IsDynamicConfig: to.Ptr(armmysqlflexibleservers.IsDynamicConfigFalse), + // IsReadOnly: to.Ptr(armmysqlflexibleservers.IsReadOnlyTrue), + // Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceSystemDefault), + // Value: to.Ptr("OFF"), + // }, + // }, + // { + // Name: to.Ptr("audit_log_enabled"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/configurations/audit_log_enabled"), + // Properties: &armmysqlflexibleservers.ConfigurationProperties{ + // Description: to.Ptr("Allow to audit the log."), + // AllowedValues: to.Ptr("ON,OFF"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // IsConfigPendingRestart: to.Ptr(armmysqlflexibleservers.IsConfigPendingRestartFalse), + // IsDynamicConfig: to.Ptr(armmysqlflexibleservers.IsDynamicConfigTrue), + // IsReadOnly: to.Ptr(armmysqlflexibleservers.IsReadOnlyFalse), + // Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceSystemDefault), + // Value: to.Ptr("OFF"), + // }, + // }, + // { + // Name: to.Ptr("audit_log_events"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/configurations/audit_log_events"), + // Properties: &armmysqlflexibleservers.ConfigurationProperties{ + // Description: to.Ptr("Select the events to audit logs."), + // AllowedValues: to.Ptr("DDL,DML_SELECT,DML_NONSELECT,DCL,ADMIN,DML,GENERAL,CONNECTION,TABLE_ACCESS"), + // DataType: to.Ptr("Set"), + // DefaultValue: to.Ptr("CONNECTION"), + // IsConfigPendingRestart: to.Ptr(armmysqlflexibleservers.IsConfigPendingRestartFalse), + // IsDynamicConfig: to.Ptr(armmysqlflexibleservers.IsDynamicConfigTrue), + // IsReadOnly: to.Ptr(armmysqlflexibleservers.IsReadOnlyFalse), + // Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceSystemDefault), + // Value: to.Ptr("CONNECTION"), + // }, + // }, + // { + // Name: to.Ptr("audit_log_exclude_users"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/configurations/audit_log_exclude_users"), + // Properties: &armmysqlflexibleservers.ConfigurationProperties{ + // Description: to.Ptr("The comma-separated user list whose commands will not be in the audit logs."), + // AllowedValues: to.Ptr(""), + // DataType: to.Ptr("String"), + // DefaultValue: to.Ptr("azure_superuser"), + // IsConfigPendingRestart: to.Ptr(armmysqlflexibleservers.IsConfigPendingRestartFalse), + // IsDynamicConfig: to.Ptr(armmysqlflexibleservers.IsDynamicConfigTrue), + // IsReadOnly: to.Ptr(armmysqlflexibleservers.IsReadOnlyFalse), + // Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceSystemDefault), + // Value: to.Ptr("azure_superuser"), + // }, + // }, + // { + // Name: to.Ptr("audit_log_include_users"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/configurations/audit_log_include_users"), + // Properties: &armmysqlflexibleservers.ConfigurationProperties{ + // Description: to.Ptr("The comma-separated user list whose commands will be in the audit logs. It takes higher priority if the same user name is found in audit_log_exclude_users."), + // AllowedValues: to.Ptr(""), + // DataType: to.Ptr("String"), + // DefaultValue: to.Ptr(""), + // IsConfigPendingRestart: to.Ptr(armmysqlflexibleservers.IsConfigPendingRestartFalse), + // IsDynamicConfig: to.Ptr(armmysqlflexibleservers.IsDynamicConfigTrue), + // IsReadOnly: to.Ptr(armmysqlflexibleservers.IsReadOnlyFalse), + // Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceSystemDefault), + // Value: to.Ptr(""), + // }, + // }, + // { + // Name: to.Ptr("audit_slow_log_enabled"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/configurations/audit_slow_log_enabled"), + // Properties: &armmysqlflexibleservers.ConfigurationProperties{ + // Description: to.Ptr("Allow to audit the slow log."), + // AllowedValues: to.Ptr("ON,OFF"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("ON"), + // IsConfigPendingRestart: to.Ptr(armmysqlflexibleservers.IsConfigPendingRestartFalse), + // IsDynamicConfig: to.Ptr(armmysqlflexibleservers.IsDynamicConfigTrue), + // IsReadOnly: to.Ptr(armmysqlflexibleservers.IsReadOnlyTrue), + // Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceSystemDefault), + // Value: to.Ptr("ON"), + // }, + // }, + // { + // Name: to.Ptr("auto_generate_certs"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/configurations/auto_generate_certs"), + // Properties: &armmysqlflexibleservers.ConfigurationProperties{ + // Description: to.Ptr("Controls whether the server autogenerates SSL key and certificate files in the data directory, if they do not already exist."), + // AllowedValues: to.Ptr("ON,OFF"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // IsConfigPendingRestart: to.Ptr(armmysqlflexibleservers.IsConfigPendingRestartFalse), + // IsDynamicConfig: to.Ptr(armmysqlflexibleservers.IsDynamicConfigFalse), + // IsReadOnly: to.Ptr(armmysqlflexibleservers.IsReadOnlyTrue), + // Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceSystemDefault), + // Value: to.Ptr("OFF"), + // }, + // }, + // { + // Name: to.Ptr("auto_increment_increment"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/configurations/auto_increment_increment"), + // Properties: &armmysqlflexibleservers.ConfigurationProperties{ + // Description: to.Ptr("The auto_increment_increment is intended for use with source-to-source replication, and can be used to control the operation of AUTO_INCREMENT columns."), + // AllowedValues: to.Ptr("1-65535"), + // DataType: to.Ptr("Integer"), + // DefaultValue: to.Ptr("1"), + // IsConfigPendingRestart: to.Ptr(armmysqlflexibleservers.IsConfigPendingRestartFalse), + // IsDynamicConfig: to.Ptr(armmysqlflexibleservers.IsDynamicConfigTrue), + // IsReadOnly: to.Ptr(armmysqlflexibleservers.IsReadOnlyFalse), + // Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceSystemDefault), + // Value: to.Ptr("1"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_constants.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/constants.go similarity index 99% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_constants.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/constants.go index 8ab879661cfb..5978eaf86e31 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_constants.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/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 armmysqlflexibleservers const ( moduleName = "armmysqlflexibleservers" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // ConfigurationSource - Source of the configuration. diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_databases_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/databases_client.go similarity index 84% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_databases_client.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/databases_client.go index 6414e331c881..6c5c0ea45ce3 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_databases_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/databases_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 armmysqlflexibleservers @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,65 +24,58 @@ import ( // DatabasesClient contains the methods for the Databases group. // Don't use this type directly, use NewDatabasesClient() instead. type DatabasesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDatabasesClient creates a new instance of DatabasesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewDatabasesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DatabasesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".DatabasesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DatabasesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates a new database or updates an existing database. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// databaseName - The name of the database. -// parameters - The required parameters for creating or updating a database. -// options - DatabasesClientBeginCreateOrUpdateOptions contains the optional parameters for the DatabasesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - databaseName - The name of the database. +// - parameters - The required parameters for creating or updating a database. +// - options - DatabasesClientBeginCreateOrUpdateOptions contains the optional parameters for the DatabasesClient.BeginCreateOrUpdate +// method. func (client *DatabasesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database, options *DatabasesClientBeginCreateOrUpdateOptions) (*runtime.Poller[DatabasesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, serverName, databaseName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[DatabasesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[DatabasesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DatabasesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DatabasesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates a new database or updates an existing database. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *DatabasesClient) createOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database, options *DatabasesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serverName, databaseName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -112,7 +104,7 @@ func (client *DatabasesClient) createOrUpdateCreateRequest(ctx context.Context, return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -125,32 +117,34 @@ func (client *DatabasesClient) createOrUpdateCreateRequest(ctx context.Context, // BeginDelete - Deletes a database. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// databaseName - The name of the database. -// options - DatabasesClientBeginDeleteOptions contains the optional parameters for the DatabasesClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - databaseName - The name of the database. +// - options - DatabasesClientBeginDeleteOptions contains the optional parameters for the DatabasesClient.BeginDelete method. func (client *DatabasesClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, options *DatabasesClientBeginDeleteOptions) (*runtime.Poller[DatabasesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, databaseName, options) if err != nil { return nil, err } - return runtime.NewPoller[DatabasesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[DatabasesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DatabasesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DatabasesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a database. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *DatabasesClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, options *DatabasesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, databaseName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -179,7 +173,7 @@ func (client *DatabasesClient) deleteCreateRequest(ctx context.Context, resource return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -192,17 +186,18 @@ func (client *DatabasesClient) deleteCreateRequest(ctx context.Context, resource // Get - Gets information about a database. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// databaseName - The name of the database. -// options - DatabasesClientGetOptions contains the optional parameters for the DatabasesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - databaseName - The name of the database. +// - options - DatabasesClientGetOptions contains the optional parameters for the DatabasesClient.Get method. func (client *DatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, options *DatabasesClientGetOptions) (DatabasesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, databaseName, options) if err != nil { return DatabasesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DatabasesClientGetResponse{}, err } @@ -231,7 +226,7 @@ func (client *DatabasesClient) getCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -252,11 +247,12 @@ func (client *DatabasesClient) getHandleResponse(resp *http.Response) (Databases } // NewListByServerPager - List all the databases in a given server. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - DatabasesClientListByServerOptions contains the optional parameters for the DatabasesClient.ListByServer method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - DatabasesClientListByServerOptions contains the optional parameters for the DatabasesClient.NewListByServerPager +// method. func (client *DatabasesClient) NewListByServerPager(resourceGroupName string, serverName string, options *DatabasesClientListByServerOptions) *runtime.Pager[DatabasesClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[DatabasesClientListByServerResponse]{ More: func(page DatabasesClientListByServerResponse) bool { @@ -273,7 +269,7 @@ func (client *DatabasesClient) NewListByServerPager(resourceGroupName string, se if err != nil { return DatabasesClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DatabasesClientListByServerResponse{}, err } @@ -300,7 +296,7 @@ func (client *DatabasesClient) listByServerCreateRequest(ctx context.Context, re return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/databases_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/databases_client_example_test.go new file mode 100644 index 000000000000..2f67c5698430 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/databases_client_example_test.go @@ -0,0 +1,153 @@ +//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 armmysqlflexibleservers_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/mysql/armmysqlflexibleservers" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/DatabaseCreate.json +func ExampleDatabasesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDatabasesClient().BeginCreateOrUpdate(ctx, "TestGroup", "testserver", "db1", armmysqlflexibleservers.Database{ + Properties: &armmysqlflexibleservers.DatabaseProperties{ + Charset: to.Ptr("utf8"), + Collation: to.Ptr("utf8_general_ci"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Database = armmysqlflexibleservers.Database{ + // Name: to.Ptr("db1"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/databases"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/testserver/databases/db1"), + // Properties: &armmysqlflexibleservers.DatabaseProperties{ + // Charset: to.Ptr("utf8"), + // Collation: to.Ptr("utf8_general_ci"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/DatabaseDelete.json +func ExampleDatabasesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDatabasesClient().BeginDelete(ctx, "TestGroup", "testserver", "db1", 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/DatabaseGet.json +func ExampleDatabasesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDatabasesClient().Get(ctx, "TestGroup", "testserver", "db1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Database = armmysqlflexibleservers.Database{ + // Name: to.Ptr("db1"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/databases"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/testserver/databases/db1"), + // Properties: &armmysqlflexibleservers.DatabaseProperties{ + // Charset: to.Ptr("utf8"), + // Collation: to.Ptr("utf8_general_ci"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/DatabasesListByServer.json +func ExampleDatabasesClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDatabasesClient().NewListByServerPager("TestGroup", "testserver", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DatabaseListResult = armmysqlflexibleservers.DatabaseListResult{ + // Value: []*armmysqlflexibleservers.Database{ + // { + // Name: to.Ptr("db1"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/databases"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/testserver/databases/db1"), + // Properties: &armmysqlflexibleservers.DatabaseProperties{ + // Charset: to.Ptr("utf8"), + // Collation: to.Ptr("utf8_general_ci"), + // }, + // }, + // { + // Name: to.Ptr("db2"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/databases"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/testserver/databases/db2"), + // Properties: &armmysqlflexibleservers.DatabaseProperties{ + // Charset: to.Ptr("utf8"), + // Collation: to.Ptr("utf8_general_ci"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_firewallrules_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/firewallrules_client.go similarity index 83% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_firewallrules_client.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/firewallrules_client.go index 6ebd099ab45b..5bd4a644560e 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_firewallrules_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/firewallrules_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 armmysqlflexibleservers @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,65 +24,58 @@ import ( // FirewallRulesClient contains the methods for the FirewallRules group. // Don't use this type directly, use NewFirewallRulesClient() instead. type FirewallRulesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewFirewallRulesClient creates a new instance of FirewallRulesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewFirewallRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FirewallRulesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".FirewallRulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &FirewallRulesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates a new firewall rule or updates an existing firewall rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// firewallRuleName - The name of the server firewall rule. -// parameters - The required parameters for creating or updating a firewall rule. -// options - FirewallRulesClientBeginCreateOrUpdateOptions contains the optional parameters for the FirewallRulesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - firewallRuleName - The name of the server firewall rule. +// - parameters - The required parameters for creating or updating a firewall rule. +// - options - FirewallRulesClientBeginCreateOrUpdateOptions contains the optional parameters for the FirewallRulesClient.BeginCreateOrUpdate +// method. func (client *FirewallRulesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule, options *FirewallRulesClientBeginCreateOrUpdateOptions) (*runtime.Poller[FirewallRulesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, serverName, firewallRuleName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[FirewallRulesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[FirewallRulesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[FirewallRulesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[FirewallRulesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates a new firewall rule or updates an existing firewall rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *FirewallRulesClient) createOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule, options *FirewallRulesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serverName, firewallRuleName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -112,7 +104,7 @@ func (client *FirewallRulesClient) createOrUpdateCreateRequest(ctx context.Conte return nil, errors.New("parameter firewallRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{firewallRuleName}", url.PathEscape(firewallRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -125,33 +117,35 @@ func (client *FirewallRulesClient) createOrUpdateCreateRequest(ctx context.Conte // BeginDelete - Deletes a firewall rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// firewallRuleName - The name of the server firewall rule. -// options - FirewallRulesClientBeginDeleteOptions contains the optional parameters for the FirewallRulesClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - firewallRuleName - The name of the server firewall rule. +// - options - FirewallRulesClientBeginDeleteOptions contains the optional parameters for the FirewallRulesClient.BeginDelete +// method. func (client *FirewallRulesClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesClientBeginDeleteOptions) (*runtime.Poller[FirewallRulesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, firewallRuleName, options) if err != nil { return nil, err } - return runtime.NewPoller[FirewallRulesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[FirewallRulesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[FirewallRulesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[FirewallRulesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a firewall rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *FirewallRulesClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, firewallRuleName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -180,7 +174,7 @@ func (client *FirewallRulesClient) deleteCreateRequest(ctx context.Context, reso return nil, errors.New("parameter firewallRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{firewallRuleName}", url.PathEscape(firewallRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -193,17 +187,18 @@ func (client *FirewallRulesClient) deleteCreateRequest(ctx context.Context, reso // Get - Gets information about a server firewall rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// firewallRuleName - The name of the server firewall rule. -// options - FirewallRulesClientGetOptions contains the optional parameters for the FirewallRulesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - firewallRuleName - The name of the server firewall rule. +// - options - FirewallRulesClientGetOptions contains the optional parameters for the FirewallRulesClient.Get method. func (client *FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesClientGetOptions) (FirewallRulesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, firewallRuleName, options) if err != nil { return FirewallRulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FirewallRulesClientGetResponse{}, err } @@ -232,7 +227,7 @@ func (client *FirewallRulesClient) getCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter firewallRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{firewallRuleName}", url.PathEscape(firewallRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -253,12 +248,12 @@ func (client *FirewallRulesClient) getHandleResponse(resp *http.Response) (Firew } // NewListByServerPager - List all the firewall rules in a given server. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - FirewallRulesClientListByServerOptions contains the optional parameters for the FirewallRulesClient.ListByServer -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - FirewallRulesClientListByServerOptions contains the optional parameters for the FirewallRulesClient.NewListByServerPager +// method. func (client *FirewallRulesClient) NewListByServerPager(resourceGroupName string, serverName string, options *FirewallRulesClientListByServerOptions) *runtime.Pager[FirewallRulesClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[FirewallRulesClientListByServerResponse]{ More: func(page FirewallRulesClientListByServerResponse) bool { @@ -275,7 +270,7 @@ func (client *FirewallRulesClient) NewListByServerPager(resourceGroupName string if err != nil { return FirewallRulesClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FirewallRulesClientListByServerResponse{}, err } @@ -302,7 +297,7 @@ func (client *FirewallRulesClient) listByServerCreateRequest(ctx context.Context return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/firewallrules_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/firewallrules_client_example_test.go new file mode 100644 index 000000000000..b638b2098f41 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/firewallrules_client_example_test.go @@ -0,0 +1,153 @@ +//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 armmysqlflexibleservers_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/mysql/armmysqlflexibleservers" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/FirewallRuleCreate.json +func ExampleFirewallRulesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFirewallRulesClient().BeginCreateOrUpdate(ctx, "TestGroup", "testserver", "rule1", armmysqlflexibleservers.FirewallRule{ + Properties: &armmysqlflexibleservers.FirewallRuleProperties{ + EndIPAddress: to.Ptr("255.255.255.255"), + StartIPAddress: to.Ptr("0.0.0.0"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.FirewallRule = armmysqlflexibleservers.FirewallRule{ + // Name: to.Ptr("rule1"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/firewallRules"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/testserver/firewallRules/rule1"), + // Properties: &armmysqlflexibleservers.FirewallRuleProperties{ + // EndIPAddress: to.Ptr("255.255.255.255"), + // StartIPAddress: to.Ptr("0.0.0.0"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/FirewallRuleDelete.json +func ExampleFirewallRulesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFirewallRulesClient().BeginDelete(ctx, "TestGroup", "testserver", "rule1", 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/FirewallRuleGet.json +func ExampleFirewallRulesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirewallRulesClient().Get(ctx, "TestGroup", "testserver", "rule1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.FirewallRule = armmysqlflexibleservers.FirewallRule{ + // Name: to.Ptr("rule1"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/firewallRules"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/testserver/firewallRules/rule1"), + // Properties: &armmysqlflexibleservers.FirewallRuleProperties{ + // EndIPAddress: to.Ptr("255.255.255.255"), + // StartIPAddress: to.Ptr("0.0.0.0"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/FirewallRulesListByServer.json +func ExampleFirewallRulesClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirewallRulesClient().NewListByServerPager("TestGroup", "testserver", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.FirewallRuleListResult = armmysqlflexibleservers.FirewallRuleListResult{ + // Value: []*armmysqlflexibleservers.FirewallRule{ + // { + // Name: to.Ptr("rule1"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/firewallRules"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/testserver/firewallRules/rule1"), + // Properties: &armmysqlflexibleservers.FirewallRuleProperties{ + // EndIPAddress: to.Ptr("255.255.255.255"), + // StartIPAddress: to.Ptr("0.0.0.0"), + // }, + // }, + // { + // Name: to.Ptr("rule2"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/firewallRules"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/testserver/firewallRules/rule2"), + // Properties: &armmysqlflexibleservers.FirewallRuleProperties{ + // EndIPAddress: to.Ptr("255.0.0.0"), + // StartIPAddress: to.Ptr("1.0.0.0"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_getprivatednszonesuffix_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/getprivatednszonesuffix_client.go similarity index 77% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_getprivatednszonesuffix_client.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/getprivatednszonesuffix_client.go index a922aed1b674..71a3c30b592c 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_getprivatednszonesuffix_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/getprivatednszonesuffix_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 armmysqlflexibleservers @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,43 +21,35 @@ import ( // GetPrivateDNSZoneSuffixClient contains the methods for the GetPrivateDNSZoneSuffix group. // Don't use this type directly, use NewGetPrivateDNSZoneSuffixClient() instead. type GetPrivateDNSZoneSuffixClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewGetPrivateDNSZoneSuffixClient creates a new instance of GetPrivateDNSZoneSuffixClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewGetPrivateDNSZoneSuffixClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GetPrivateDNSZoneSuffixClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".GetPrivateDNSZoneSuffixClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &GetPrivateDNSZoneSuffixClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Execute - Get private DNS zone suffix in the cloud. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// options - GetPrivateDNSZoneSuffixClientExecuteOptions contains the optional parameters for the GetPrivateDNSZoneSuffixClient.Execute -// method. +// - options - GetPrivateDNSZoneSuffixClientExecuteOptions contains the optional parameters for the GetPrivateDNSZoneSuffixClient.Execute +// method. func (client *GetPrivateDNSZoneSuffixClient) Execute(ctx context.Context, options *GetPrivateDNSZoneSuffixClientExecuteOptions) (GetPrivateDNSZoneSuffixClientExecuteResponse, error) { req, err := client.executeCreateRequest(ctx, options) if err != nil { return GetPrivateDNSZoneSuffixClientExecuteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GetPrivateDNSZoneSuffixClientExecuteResponse{}, err } @@ -71,7 +62,7 @@ func (client *GetPrivateDNSZoneSuffixClient) Execute(ctx context.Context, option // executeCreateRequest creates the Execute request. func (client *GetPrivateDNSZoneSuffixClient) executeCreateRequest(ctx context.Context, options *GetPrivateDNSZoneSuffixClientExecuteOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.DBforMySQL/getPrivateDnsZoneSuffix" - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_getprivatednszonesuffix_client_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/getprivatednszonesuffix_client_example_test.go similarity index 54% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_getprivatednszonesuffix_client_test.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/getprivatednszonesuffix_client_example_test.go index fad85cc88a1a..07a0517be695 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_getprivatednszonesuffix_client_test.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/getprivatednszonesuffix_client_example_test.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 armmysqlflexibleservers_test @@ -16,22 +17,25 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/GetPrivateDnsZoneSuffix.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/GetPrivateDnsZoneSuffix.json func ExampleGetPrivateDNSZoneSuffixClient_Execute() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armmysqlflexibleservers.NewGetPrivateDNSZoneSuffixClient(cred, nil) + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Execute(ctx, - nil) + res, err := clientFactory.NewGetPrivateDNSZoneSuffixClient().Execute(ctx, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.GetPrivateDNSZoneSuffixResponse = armmysqlflexibleservers.GetPrivateDNSZoneSuffixResponse{ + // PrivateDNSZoneSuffix: to.Ptr("suffix-example"), + // } } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/go.mod b/sdk/resourcemanager/mysql/armmysqlflexibleservers/go.mod index 3c49474ed67f..f91b08d34d5e 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/go.mod +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexi go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) 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/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/go.sum b/sdk/resourcemanager/mysql/armmysqlflexibleservers/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/go.sum +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= 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/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_locationbasedcapabilities_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/locationbasedcapabilities_client.go similarity index 79% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_locationbasedcapabilities_client.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/locationbasedcapabilities_client.go index d1c8ca85d958..33c7c98e52cf 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_locationbasedcapabilities_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/locationbasedcapabilities_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 armmysqlflexibleservers @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,41 +24,32 @@ import ( // LocationBasedCapabilitiesClient contains the methods for the LocationBasedCapabilities group. // Don't use this type directly, use NewLocationBasedCapabilitiesClient() instead. type LocationBasedCapabilitiesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewLocationBasedCapabilitiesClient creates a new instance of LocationBasedCapabilitiesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewLocationBasedCapabilitiesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LocationBasedCapabilitiesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".LocationBasedCapabilitiesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LocationBasedCapabilitiesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Get capabilities at specified location in a given subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// locationName - The name of the location. -// options - LocationBasedCapabilitiesClientListOptions contains the optional parameters for the LocationBasedCapabilitiesClient.List -// method. +// - locationName - The name of the location. +// - options - LocationBasedCapabilitiesClientListOptions contains the optional parameters for the LocationBasedCapabilitiesClient.NewListPager +// method. func (client *LocationBasedCapabilitiesClient) NewListPager(locationName string, options *LocationBasedCapabilitiesClientListOptions) *runtime.Pager[LocationBasedCapabilitiesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[LocationBasedCapabilitiesClientListResponse]{ More: func(page LocationBasedCapabilitiesClientListResponse) bool { @@ -76,7 +66,7 @@ func (client *LocationBasedCapabilitiesClient) NewListPager(locationName string, if err != nil { return LocationBasedCapabilitiesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LocationBasedCapabilitiesClientListResponse{}, err } @@ -99,7 +89,7 @@ func (client *LocationBasedCapabilitiesClient) listCreateRequest(ctx context.Con return nil, errors.New("parameter locationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/locationbasedcapabilities_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/locationbasedcapabilities_client_example_test.go new file mode 100644 index 000000000000..0d3d408fe5f2 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/locationbasedcapabilities_client_example_test.go @@ -0,0 +1,1138 @@ +//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 armmysqlflexibleservers_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/CapabilitiesByLocationList.json +func ExampleLocationBasedCapabilitiesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLocationBasedCapabilitiesClient().NewListPager("WestUS", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.CapabilitiesListResult = armmysqlflexibleservers.CapabilitiesListResult{ + // Value: []*armmysqlflexibleservers.CapabilityProperties{ + // { + // SupportedFlexibleServerEditions: []*armmysqlflexibleservers.ServerEditionCapability{ + // { + // Name: to.Ptr("Burstable"), + // SupportedServerVersions: []*armmysqlflexibleservers.ServerVersionCapability{ + // { + // Name: to.Ptr("5.7"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_B1s"), + // SupportedIops: to.Ptr[int64](400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](1024), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B1ms"), + // SupportedIops: to.Ptr[int64](640), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B2s"), + // SupportedIops: to.Ptr[int64](1280), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](2), + // }}, + // }, + // { + // Name: to.Ptr("8.0.21"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_B1s"), + // SupportedIops: to.Ptr[int64](400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](1024), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B1ms"), + // SupportedIops: to.Ptr[int64](640), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B2s"), + // SupportedIops: to.Ptr[int64](1280), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](2), + // }}, + // }}, + // SupportedStorageEditions: []*armmysqlflexibleservers.StorageEditionCapability{ + // { + // Name: to.Ptr("Premium"), + // MaxBackupRetentionDays: to.Ptr[int64](35), + // MaxStorageSize: to.Ptr[int64](16777216), + // MinBackupRetentionDays: to.Ptr[int64](7), + // MinStorageSize: to.Ptr[int64](20480), + // }}, + // }, + // { + // Name: to.Ptr("GeneralPurpose"), + // SupportedServerVersions: []*armmysqlflexibleservers.ServerVersionCapability{ + // { + // Name: to.Ptr("5.7"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_D2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_D4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_D8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_D16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_D32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_D48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_D64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](64), + // }}, + // }, + // { + // Name: to.Ptr("8.0.21"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_D2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_D4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_D8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_D16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_D32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_D48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_D64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](64), + // }}, + // }}, + // SupportedStorageEditions: []*armmysqlflexibleservers.StorageEditionCapability{ + // { + // Name: to.Ptr("Premium"), + // MaxBackupRetentionDays: to.Ptr[int64](35), + // MaxStorageSize: to.Ptr[int64](16777216), + // MinBackupRetentionDays: to.Ptr[int64](7), + // MinStorageSize: to.Ptr[int64](20480), + // }}, + // }, + // { + // Name: to.Ptr("MemoryOptimized"), + // SupportedServerVersions: []*armmysqlflexibleservers.ServerVersionCapability{ + // { + // Name: to.Ptr("5.7"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_E2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_E4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_E8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_E16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_E32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_E48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_E64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](64), + // }}, + // }, + // { + // Name: to.Ptr("8.0.21"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_E2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_E4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_E8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_E16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_E32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_E48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_E64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](64), + // }}, + // }}, + // SupportedStorageEditions: []*armmysqlflexibleservers.StorageEditionCapability{ + // { + // Name: to.Ptr("Premium"), + // MaxBackupRetentionDays: to.Ptr[int64](35), + // MaxStorageSize: to.Ptr[int64](16777216), + // MinBackupRetentionDays: to.Ptr[int64](7), + // MinStorageSize: to.Ptr[int64](20480), + // }}, + // }}, + // SupportedGeoBackupRegions: []*string{ + // }, + // SupportedHAMode: []*string{ + // to.Ptr("SameZone"), + // to.Ptr("ZoneRedundant")}, + // Zone: to.Ptr("none"), + // }, + // { + // SupportedFlexibleServerEditions: []*armmysqlflexibleservers.ServerEditionCapability{ + // { + // Name: to.Ptr("Burstable"), + // SupportedServerVersions: []*armmysqlflexibleservers.ServerVersionCapability{ + // { + // Name: to.Ptr("5.7"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_B1s"), + // SupportedIops: to.Ptr[int64](400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](1024), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B1ms"), + // SupportedIops: to.Ptr[int64](640), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B2s"), + // SupportedIops: to.Ptr[int64](1280), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](2), + // }}, + // }, + // { + // Name: to.Ptr("8.0.21"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_B1s"), + // SupportedIops: to.Ptr[int64](400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](1024), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B1ms"), + // SupportedIops: to.Ptr[int64](640), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B2s"), + // SupportedIops: to.Ptr[int64](1280), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](2), + // }}, + // }}, + // SupportedStorageEditions: []*armmysqlflexibleservers.StorageEditionCapability{ + // { + // Name: to.Ptr("Premium"), + // MaxBackupRetentionDays: to.Ptr[int64](35), + // MaxStorageSize: to.Ptr[int64](16777216), + // MinBackupRetentionDays: to.Ptr[int64](7), + // MinStorageSize: to.Ptr[int64](20480), + // }}, + // }, + // { + // Name: to.Ptr("GeneralPurpose"), + // SupportedServerVersions: []*armmysqlflexibleservers.ServerVersionCapability{ + // { + // Name: to.Ptr("5.7"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_D2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_D4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_D8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_D16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_D32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_D48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_D64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](64), + // }}, + // }, + // { + // Name: to.Ptr("8.0.21"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_D2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_D4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_D8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_D16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_D32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_D48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_D64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](64), + // }}, + // }}, + // SupportedStorageEditions: []*armmysqlflexibleservers.StorageEditionCapability{ + // { + // Name: to.Ptr("Premium"), + // MaxBackupRetentionDays: to.Ptr[int64](35), + // MaxStorageSize: to.Ptr[int64](16777216), + // MinBackupRetentionDays: to.Ptr[int64](7), + // MinStorageSize: to.Ptr[int64](20480), + // }}, + // }, + // { + // Name: to.Ptr("MemoryOptimized"), + // SupportedServerVersions: []*armmysqlflexibleservers.ServerVersionCapability{ + // { + // Name: to.Ptr("5.7"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_E2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_E4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_E8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_E16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_E32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_E48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_E64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](64), + // }}, + // }, + // { + // Name: to.Ptr("8.0.21"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_E2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_E4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_E8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_E16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_E32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_E48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_E64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](64), + // }}, + // }}, + // SupportedStorageEditions: []*armmysqlflexibleservers.StorageEditionCapability{ + // { + // Name: to.Ptr("Premium"), + // MaxBackupRetentionDays: to.Ptr[int64](35), + // MaxStorageSize: to.Ptr[int64](16777216), + // MinBackupRetentionDays: to.Ptr[int64](7), + // MinStorageSize: to.Ptr[int64](20480), + // }}, + // }}, + // SupportedGeoBackupRegions: []*string{ + // }, + // SupportedHAMode: []*string{ + // to.Ptr("SameZone"), + // to.Ptr("ZoneRedundant")}, + // Zone: to.Ptr("1"), + // }, + // { + // SupportedFlexibleServerEditions: []*armmysqlflexibleservers.ServerEditionCapability{ + // { + // Name: to.Ptr("Burstable"), + // SupportedServerVersions: []*armmysqlflexibleservers.ServerVersionCapability{ + // { + // Name: to.Ptr("5.7"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_B1s"), + // SupportedIops: to.Ptr[int64](400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](1024), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B1ms"), + // SupportedIops: to.Ptr[int64](640), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B2s"), + // SupportedIops: to.Ptr[int64](1280), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](2), + // }}, + // }, + // { + // Name: to.Ptr("8.0.21"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_B1s"), + // SupportedIops: to.Ptr[int64](400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](1024), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B1ms"), + // SupportedIops: to.Ptr[int64](640), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B2s"), + // SupportedIops: to.Ptr[int64](1280), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](2), + // }}, + // }}, + // SupportedStorageEditions: []*armmysqlflexibleservers.StorageEditionCapability{ + // { + // Name: to.Ptr("Premium"), + // MaxBackupRetentionDays: to.Ptr[int64](35), + // MaxStorageSize: to.Ptr[int64](16777216), + // MinBackupRetentionDays: to.Ptr[int64](7), + // MinStorageSize: to.Ptr[int64](20480), + // }}, + // }, + // { + // Name: to.Ptr("GeneralPurpose"), + // SupportedServerVersions: []*armmysqlflexibleservers.ServerVersionCapability{ + // { + // Name: to.Ptr("5.7"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_D2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_D4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_D8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_D16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_D32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_D48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_D64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](64), + // }}, + // }, + // { + // Name: to.Ptr("8.0.21"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_D2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_D4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_D8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_D16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_D32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_D48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_D64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](64), + // }}, + // }}, + // SupportedStorageEditions: []*armmysqlflexibleservers.StorageEditionCapability{ + // { + // Name: to.Ptr("Premium"), + // MaxBackupRetentionDays: to.Ptr[int64](35), + // MaxStorageSize: to.Ptr[int64](16777216), + // MinBackupRetentionDays: to.Ptr[int64](7), + // MinStorageSize: to.Ptr[int64](20480), + // }}, + // }, + // { + // Name: to.Ptr("MemoryOptimized"), + // SupportedServerVersions: []*armmysqlflexibleservers.ServerVersionCapability{ + // { + // Name: to.Ptr("5.7"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_E2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_E4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_E8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_E16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_E32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_E48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_E64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](64), + // }}, + // }, + // { + // Name: to.Ptr("8.0.21"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_E2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_E4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_E8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_E16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_E32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_E48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_E64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](64), + // }}, + // }}, + // SupportedStorageEditions: []*armmysqlflexibleservers.StorageEditionCapability{ + // { + // Name: to.Ptr("Premium"), + // MaxBackupRetentionDays: to.Ptr[int64](35), + // MaxStorageSize: to.Ptr[int64](16777216), + // MinBackupRetentionDays: to.Ptr[int64](7), + // MinStorageSize: to.Ptr[int64](20480), + // }}, + // }}, + // SupportedGeoBackupRegions: []*string{ + // }, + // SupportedHAMode: []*string{ + // to.Ptr("SameZone"), + // to.Ptr("ZoneRedundant")}, + // Zone: to.Ptr("2"), + // }, + // { + // SupportedFlexibleServerEditions: []*armmysqlflexibleservers.ServerEditionCapability{ + // { + // Name: to.Ptr("Burstable"), + // SupportedServerVersions: []*armmysqlflexibleservers.ServerVersionCapability{ + // { + // Name: to.Ptr("5.7"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_B1s"), + // SupportedIops: to.Ptr[int64](400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](1024), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B1ms"), + // SupportedIops: to.Ptr[int64](640), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B2s"), + // SupportedIops: to.Ptr[int64](1280), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](2), + // }}, + // }, + // { + // Name: to.Ptr("8.0.21"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_B1s"), + // SupportedIops: to.Ptr[int64](400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](1024), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B1ms"), + // SupportedIops: to.Ptr[int64](640), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](1), + // }, + // { + // Name: to.Ptr("Standard_B2s"), + // SupportedIops: to.Ptr[int64](1280), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](2048), + // VCores: to.Ptr[int64](2), + // }}, + // }}, + // SupportedStorageEditions: []*armmysqlflexibleservers.StorageEditionCapability{ + // { + // Name: to.Ptr("Premium"), + // MaxBackupRetentionDays: to.Ptr[int64](35), + // MaxStorageSize: to.Ptr[int64](16777216), + // MinBackupRetentionDays: to.Ptr[int64](7), + // MinStorageSize: to.Ptr[int64](20480), + // }}, + // }, + // { + // Name: to.Ptr("GeneralPurpose"), + // SupportedServerVersions: []*armmysqlflexibleservers.ServerVersionCapability{ + // { + // Name: to.Ptr("5.7"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_D2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_D4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_D8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_D16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_D32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_D48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_D64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](64), + // }}, + // }, + // { + // Name: to.Ptr("8.0.21"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_D2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_D4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_D8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_D16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_D32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_D48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_D64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](4096), + // VCores: to.Ptr[int64](64), + // }}, + // }}, + // SupportedStorageEditions: []*armmysqlflexibleservers.StorageEditionCapability{ + // { + // Name: to.Ptr("Premium"), + // MaxBackupRetentionDays: to.Ptr[int64](35), + // MaxStorageSize: to.Ptr[int64](16777216), + // MinBackupRetentionDays: to.Ptr[int64](7), + // MinStorageSize: to.Ptr[int64](20480), + // }}, + // }, + // { + // Name: to.Ptr("MemoryOptimized"), + // SupportedServerVersions: []*armmysqlflexibleservers.ServerVersionCapability{ + // { + // Name: to.Ptr("5.7"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_E2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_E4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_E8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_E16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_E32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_E48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_E64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](64), + // }}, + // }, + // { + // Name: to.Ptr("8.0.21"), + // SupportedSKUs: []*armmysqlflexibleservers.SKUCapability{ + // { + // Name: to.Ptr("Standard_E2ds_v4"), + // SupportedIops: to.Ptr[int64](3200), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](2), + // }, + // { + // Name: to.Ptr("Standard_E4ds_v4"), + // SupportedIops: to.Ptr[int64](6400), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](4), + // }, + // { + // Name: to.Ptr("Standard_E8ds_v4"), + // SupportedIops: to.Ptr[int64](12800), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](8), + // }, + // { + // Name: to.Ptr("Standard_E16ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](16), + // }, + // { + // Name: to.Ptr("Standard_E32ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](32), + // }, + // { + // Name: to.Ptr("Standard_E48ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](48), + // }, + // { + // Name: to.Ptr("Standard_E64ds_v4"), + // SupportedIops: to.Ptr[int64](20000), + // SupportedMemoryPerVCoreMB: to.Ptr[int64](8192), + // VCores: to.Ptr[int64](64), + // }}, + // }}, + // SupportedStorageEditions: []*armmysqlflexibleservers.StorageEditionCapability{ + // { + // Name: to.Ptr("Premium"), + // MaxBackupRetentionDays: to.Ptr[int64](35), + // MaxStorageSize: to.Ptr[int64](16777216), + // MinBackupRetentionDays: to.Ptr[int64](7), + // MinStorageSize: to.Ptr[int64](20480), + // }}, + // }}, + // SupportedGeoBackupRegions: []*string{ + // }, + // SupportedHAMode: []*string{ + // to.Ptr("SameZone"), + // to.Ptr("ZoneRedundant")}, + // Zone: to.Ptr("3"), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_models.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/models.go similarity index 97% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_models.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/models.go index 0e1d2bbc0257..ee8b0ca17e9b 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_models.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/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 armmysqlflexibleservers @@ -27,7 +28,7 @@ type BackupsClientGetOptions struct { // placeholder for future optional parameters } -// BackupsClientListByServerOptions contains the optional parameters for the BackupsClient.ListByServer method. +// BackupsClientListByServerOptions contains the optional parameters for the BackupsClient.NewListByServerPager method. type BackupsClientListByServerOptions struct { // placeholder for future optional parameters } @@ -68,12 +69,6 @@ type CheckVirtualNetworkSubnetUsageClientExecuteOptions struct { // placeholder for future optional parameters } -// CloudError - An error response from the Batch service. -type CloudError struct { - // The resource management error response. - Error *ErrorResponse `json:"error,omitempty"` -} - // Configuration - Represents a Configuration. type Configuration struct { // The properties of a configuration. @@ -173,7 +168,8 @@ type ConfigurationsClientGetOptions struct { // placeholder for future optional parameters } -// ConfigurationsClientListByServerOptions contains the optional parameters for the ConfigurationsClient.ListByServer method. +// ConfigurationsClientListByServerOptions contains the optional parameters for the ConfigurationsClient.NewListByServerPager +// method. type ConfigurationsClientListByServerOptions struct { // placeholder for future optional parameters } @@ -250,7 +246,7 @@ type DatabasesClientGetOptions struct { // placeholder for future optional parameters } -// DatabasesClientListByServerOptions contains the optional parameters for the DatabasesClient.ListByServer method. +// DatabasesClientListByServerOptions contains the optional parameters for the DatabasesClient.NewListByServerPager method. type DatabasesClientListByServerOptions struct { // placeholder for future optional parameters } @@ -267,7 +263,7 @@ type DelegatedSubnetUsage struct { // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty" azure:"ro"` + Info any `json:"info,omitempty" azure:"ro"` // READ-ONLY; The additional info type. Type *string `json:"type,omitempty" azure:"ro"` @@ -346,7 +342,8 @@ type FirewallRulesClientGetOptions struct { // placeholder for future optional parameters } -// FirewallRulesClientListByServerOptions contains the optional parameters for the FirewallRulesClient.ListByServer method. +// FirewallRulesClientListByServerOptions contains the optional parameters for the FirewallRulesClient.NewListByServerPager +// method. type FirewallRulesClientListByServerOptions struct { // placeholder for future optional parameters } @@ -381,7 +378,7 @@ type Identity struct { Type *string `json:"type,omitempty"` // Metadata of user assigned identity. - UserAssignedIdentities map[string]interface{} `json:"userAssignedIdentities,omitempty"` + UserAssignedIdentities map[string]any `json:"userAssignedIdentities,omitempty"` // READ-ONLY; ObjectId from the KeyVault PrincipalID *string `json:"principalId,omitempty" azure:"ro"` @@ -390,7 +387,7 @@ type Identity struct { TenantID *string `json:"tenantId,omitempty" azure:"ro"` } -// LocationBasedCapabilitiesClientListOptions contains the optional parameters for the LocationBasedCapabilitiesClient.List +// LocationBasedCapabilitiesClientListOptions contains the optional parameters for the LocationBasedCapabilitiesClient.NewListPager // method. type LocationBasedCapabilitiesClientListOptions struct { // placeholder for future optional parameters @@ -456,7 +453,7 @@ type Operation struct { Origin *string `json:"origin,omitempty"` // Additional descriptions for the operation. - Properties map[string]interface{} `json:"properties,omitempty"` + Properties map[string]any `json:"properties,omitempty"` } // OperationDisplay - Display metadata associated with the operation. @@ -483,7 +480,7 @@ type OperationListResult struct { Value []*Operation `json:"value,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -501,7 +498,7 @@ type ProxyResource struct { Type *string `json:"type,omitempty" azure:"ro"` } -// ReplicasClientListByServerOptions contains the optional parameters for the ReplicasClient.ListByServer method. +// ReplicasClientListByServerOptions contains the optional parameters for the ReplicasClient.NewListByServerPager method. type ReplicasClientListByServerOptions struct { // placeholder for future optional parameters } @@ -791,12 +788,13 @@ type ServersClientGetOptions struct { // placeholder for future optional parameters } -// ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.ListByResourceGroup method. +// ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.NewListByResourceGroupPager +// method. type ServersClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// ServersClientListOptions contains the optional parameters for the ServersClient.List method. +// ServersClientListOptions contains the optional parameters for the ServersClient.NewListPager method. type ServersClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/models_serde.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/models_serde.go new file mode 100644 index 000000000000..acb3a2c085e2 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/models_serde.go @@ -0,0 +1,1946 @@ +//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 armmysqlflexibleservers + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Backup. +func (b Backup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backupRetentionDays", b.BackupRetentionDays) + populateTimeRFC3339(objectMap, "earliestRestoreDate", b.EarliestRestoreDate) + populate(objectMap, "geoRedundantBackup", b.GeoRedundantBackup) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Backup. +func (b *Backup) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "backupRetentionDays": + err = unpopulate(val, "BackupRetentionDays", &b.BackupRetentionDays) + delete(rawMsg, key) + case "earliestRestoreDate": + err = unpopulateTimeRFC3339(val, "EarliestRestoreDate", &b.EarliestRestoreDate) + delete(rawMsg, key) + case "geoRedundantBackup": + err = unpopulate(val, "GeoRedundantBackup", &b.GeoRedundantBackup) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CapabilitiesListResult. +func (c CapabilitiesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapabilitiesListResult. +func (c *CapabilitiesListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + 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 CapabilityProperties. +func (c CapabilityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "supportedFlexibleServerEditions", c.SupportedFlexibleServerEditions) + populate(objectMap, "supportedGeoBackupRegions", c.SupportedGeoBackupRegions) + populate(objectMap, "supportedHAMode", c.SupportedHAMode) + populate(objectMap, "zone", c.Zone) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapabilityProperties. +func (c *CapabilityProperties) 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 "supportedFlexibleServerEditions": + err = unpopulate(val, "SupportedFlexibleServerEditions", &c.SupportedFlexibleServerEditions) + delete(rawMsg, key) + case "supportedGeoBackupRegions": + err = unpopulate(val, "SupportedGeoBackupRegions", &c.SupportedGeoBackupRegions) + delete(rawMsg, key) + case "supportedHAMode": + err = unpopulate(val, "SupportedHAMode", &c.SupportedHAMode) + delete(rawMsg, key) + case "zone": + err = unpopulate(val, "Zone", &c.Zone) + 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 Configuration. +func (c Configuration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Configuration. +func (c *Configuration) 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 "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + 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 ConfigurationForBatchUpdate. +func (c ConfigurationForBatchUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationForBatchUpdate. +func (c *ConfigurationForBatchUpdate) 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 "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + 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 ConfigurationForBatchUpdateProperties. +func (c ConfigurationForBatchUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "source", c.Source) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationForBatchUpdateProperties. +func (c *ConfigurationForBatchUpdateProperties) 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 "source": + err = unpopulate(val, "Source", &c.Source) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + 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 ConfigurationListForBatchUpdate. +func (c ConfigurationListForBatchUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationListForBatchUpdate. +func (c *ConfigurationListForBatchUpdate) 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 "value": + err = unpopulate(val, "Value", &c.Value) + 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 ConfigurationListResult. +func (c ConfigurationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationListResult. +func (c *ConfigurationListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + 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 ConfigurationProperties. +func (c ConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allowedValues", c.AllowedValues) + populate(objectMap, "dataType", c.DataType) + populate(objectMap, "defaultValue", c.DefaultValue) + populate(objectMap, "description", c.Description) + populate(objectMap, "isConfigPendingRestart", c.IsConfigPendingRestart) + populate(objectMap, "isDynamicConfig", c.IsDynamicConfig) + populate(objectMap, "isReadOnly", c.IsReadOnly) + populate(objectMap, "source", c.Source) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationProperties. +func (c *ConfigurationProperties) 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 "allowedValues": + err = unpopulate(val, "AllowedValues", &c.AllowedValues) + delete(rawMsg, key) + case "dataType": + err = unpopulate(val, "DataType", &c.DataType) + delete(rawMsg, key) + case "defaultValue": + err = unpopulate(val, "DefaultValue", &c.DefaultValue) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &c.Description) + delete(rawMsg, key) + case "isConfigPendingRestart": + err = unpopulate(val, "IsConfigPendingRestart", &c.IsConfigPendingRestart) + delete(rawMsg, key) + case "isDynamicConfig": + err = unpopulate(val, "IsDynamicConfig", &c.IsDynamicConfig) + delete(rawMsg, key) + case "isReadOnly": + err = unpopulate(val, "IsReadOnly", &c.IsReadOnly) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &c.Source) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + 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 DataEncryption. +func (d DataEncryption) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "geoBackupKeyUri", d.GeoBackupKeyURI) + populate(objectMap, "geoBackupUserAssignedIdentityId", d.GeoBackupUserAssignedIdentityID) + populate(objectMap, "primaryKeyUri", d.PrimaryKeyURI) + populate(objectMap, "primaryUserAssignedIdentityId", d.PrimaryUserAssignedIdentityID) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataEncryption. +func (d *DataEncryption) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "geoBackupKeyUri": + err = unpopulate(val, "GeoBackupKeyURI", &d.GeoBackupKeyURI) + delete(rawMsg, key) + case "geoBackupUserAssignedIdentityId": + err = unpopulate(val, "GeoBackupUserAssignedIdentityID", &d.GeoBackupUserAssignedIdentityID) + delete(rawMsg, key) + case "primaryKeyUri": + err = unpopulate(val, "PrimaryKeyURI", &d.PrimaryKeyURI) + delete(rawMsg, key) + case "primaryUserAssignedIdentityId": + err = unpopulate(val, "PrimaryUserAssignedIdentityID", &d.PrimaryUserAssignedIdentityID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Database. +func (d Database) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Database. +func (d *Database) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DatabaseListResult. +func (d DatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DatabaseListResult. +func (d *DatabaseListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DatabaseProperties. +func (d DatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "charset", d.Charset) + populate(objectMap, "collation", d.Collation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DatabaseProperties. +func (d *DatabaseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "charset": + err = unpopulate(val, "Charset", &d.Charset) + delete(rawMsg, key) + case "collation": + err = unpopulate(val, "Collation", &d.Collation) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DelegatedSubnetUsage. +func (d DelegatedSubnetUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "subnetName", d.SubnetName) + populate(objectMap, "usage", d.Usage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DelegatedSubnetUsage. +func (d *DelegatedSubnetUsage) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "subnetName": + err = unpopulate(val, "SubnetName", &d.SubnetName) + delete(rawMsg, key) + case "usage": + err = unpopulate(val, "Usage", &d.Usage) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "info", &e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FirewallRule. +func (f FirewallRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + populate(objectMap, "name", f.Name) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "systemData", f.SystemData) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FirewallRule. +func (f *FirewallRule) 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", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &f.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FirewallRuleListResult. +func (f FirewallRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", f.NextLink) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FirewallRuleListResult. +func (f *FirewallRuleListResult) 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", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &f.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &f.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FirewallRuleProperties. +func (f FirewallRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "endIpAddress", f.EndIPAddress) + populate(objectMap, "startIpAddress", f.StartIPAddress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FirewallRuleProperties. +func (f *FirewallRuleProperties) 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", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endIpAddress": + err = unpopulate(val, "EndIPAddress", &f.EndIPAddress) + delete(rawMsg, key) + case "startIpAddress": + err = unpopulate(val, "StartIPAddress", &f.StartIPAddress) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GetPrivateDNSZoneSuffixResponse. +func (g GetPrivateDNSZoneSuffixResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "privateDnsZoneSuffix", g.PrivateDNSZoneSuffix) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GetPrivateDNSZoneSuffixResponse. +func (g *GetPrivateDNSZoneSuffixResponse) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "privateDnsZoneSuffix": + err = unpopulate(val, "PrivateDNSZoneSuffix", &g.PrivateDNSZoneSuffix) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HighAvailability. +func (h HighAvailability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "mode", h.Mode) + populate(objectMap, "standbyAvailabilityZone", h.StandbyAvailabilityZone) + populate(objectMap, "state", h.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HighAvailability. +func (h *HighAvailability) 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", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "mode": + err = unpopulate(val, "Mode", &h.Mode) + delete(rawMsg, key) + case "standbyAvailabilityZone": + err = unpopulate(val, "StandbyAvailabilityZone", &h.StandbyAvailabilityZone) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &h.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Identity. +func (i Identity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", i.PrincipalID) + populate(objectMap, "tenantId", i.TenantID) + objectMap["type"] = "UserAssigned" + populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Identity. +func (i *Identity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &i.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &i.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &i.UserAssignedIdentities) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MaintenanceWindow. +func (m MaintenanceWindow) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customWindow", m.CustomWindow) + populate(objectMap, "dayOfWeek", m.DayOfWeek) + populate(objectMap, "startHour", m.StartHour) + populate(objectMap, "startMinute", m.StartMinute) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MaintenanceWindow. +func (m *MaintenanceWindow) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "customWindow": + err = unpopulate(val, "CustomWindow", &m.CustomWindow) + delete(rawMsg, key) + case "dayOfWeek": + err = unpopulate(val, "DayOfWeek", &m.DayOfWeek) + delete(rawMsg, key) + case "startHour": + err = unpopulate(val, "StartHour", &m.StartHour) + delete(rawMsg, key) + case "startMinute": + err = unpopulate(val, "StartMinute", &m.StartMinute) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NameAvailability. +func (n NameAvailability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", n.Message) + populate(objectMap, "nameAvailable", n.NameAvailable) + populate(objectMap, "reason", n.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NameAvailability. +func (n *NameAvailability) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &n.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &n.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &n.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NameAvailabilityRequest. +func (n NameAvailabilityRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", n.Name) + populate(objectMap, "type", n.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NameAvailabilityRequest. +func (n *NameAvailabilityRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &n.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Network. +func (n Network) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "delegatedSubnetResourceId", n.DelegatedSubnetResourceID) + populate(objectMap, "privateDnsZoneResourceId", n.PrivateDNSZoneResourceID) + populate(objectMap, "publicNetworkAccess", n.PublicNetworkAccess) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Network. +func (n *Network) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "delegatedSubnetResourceId": + err = unpopulate(val, "DelegatedSubnetResourceID", &n.DelegatedSubnetResourceID) + delete(rawMsg, key) + case "privateDnsZoneResourceId": + err = unpopulate(val, "PrivateDNSZoneResourceID", &n.PrivateDNSZoneResourceID) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &n.PublicNetworkAccess) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + populate(objectMap, "properties", o.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "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]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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]any) + 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 SKU. +func (s SKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKU. +func (s *SKU) 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 "tier": + err = unpopulate(val, "Tier", &s.Tier) + 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 SKUCapability. +func (s SKUCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + populate(objectMap, "supportedIops", s.SupportedIops) + populate(objectMap, "supportedMemoryPerVCoreMB", s.SupportedMemoryPerVCoreMB) + populate(objectMap, "vCores", s.VCores) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKUCapability. +func (s *SKUCapability) 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 "supportedIops": + err = unpopulate(val, "SupportedIops", &s.SupportedIops) + delete(rawMsg, key) + case "supportedMemoryPerVCoreMB": + err = unpopulate(val, "SupportedMemoryPerVCoreMB", &s.SupportedMemoryPerVCoreMB) + delete(rawMsg, key) + case "vCores": + err = unpopulate(val, "VCores", &s.VCores) + 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 Server. +func (s Server) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "location", s.Location) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Server. +func (s *Server) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerBackup. +func (s ServerBackup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerBackup. +func (s *ServerBackup) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerBackupListResult. +func (s ServerBackupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerBackupListResult. +func (s *ServerBackupListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerBackupProperties. +func (s ServerBackupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backupType", s.BackupType) + populateTimeRFC3339(objectMap, "completedTime", s.CompletedTime) + populate(objectMap, "source", s.Source) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerBackupProperties. +func (s *ServerBackupProperties) 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 "backupType": + err = unpopulate(val, "BackupType", &s.BackupType) + delete(rawMsg, key) + case "completedTime": + err = unpopulateTimeRFC3339(val, "CompletedTime", &s.CompletedTime) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &s.Source) + 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 ServerEditionCapability. +func (s ServerEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + populate(objectMap, "supportedServerVersions", s.SupportedServerVersions) + populate(objectMap, "supportedStorageEditions", s.SupportedStorageEditions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerEditionCapability. +func (s *ServerEditionCapability) 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 "supportedServerVersions": + err = unpopulate(val, "SupportedServerVersions", &s.SupportedServerVersions) + delete(rawMsg, key) + case "supportedStorageEditions": + err = unpopulate(val, "SupportedStorageEditions", &s.SupportedStorageEditions) + 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 ServerForUpdate. +func (s ServerForUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerForUpdate. +func (s *ServerForUpdate) 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 "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + 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 ServerListResult. +func (s ServerListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerListResult. +func (s *ServerListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerProperties. +func (s ServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "administratorLogin", s.AdministratorLogin) + populate(objectMap, "administratorLoginPassword", s.AdministratorLoginPassword) + populate(objectMap, "availabilityZone", s.AvailabilityZone) + populate(objectMap, "backup", s.Backup) + populate(objectMap, "createMode", s.CreateMode) + populate(objectMap, "dataEncryption", s.DataEncryption) + populate(objectMap, "fullyQualifiedDomainName", s.FullyQualifiedDomainName) + populate(objectMap, "highAvailability", s.HighAvailability) + populate(objectMap, "maintenanceWindow", s.MaintenanceWindow) + populate(objectMap, "network", s.Network) + populate(objectMap, "replicaCapacity", s.ReplicaCapacity) + populate(objectMap, "replicationRole", s.ReplicationRole) + populateTimeRFC3339(objectMap, "restorePointInTime", s.RestorePointInTime) + populate(objectMap, "sourceServerResourceId", s.SourceServerResourceID) + populate(objectMap, "state", s.State) + populate(objectMap, "storage", s.Storage) + populate(objectMap, "version", s.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerProperties. +func (s *ServerProperties) 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 "administratorLogin": + err = unpopulate(val, "AdministratorLogin", &s.AdministratorLogin) + delete(rawMsg, key) + case "administratorLoginPassword": + err = unpopulate(val, "AdministratorLoginPassword", &s.AdministratorLoginPassword) + delete(rawMsg, key) + case "availabilityZone": + err = unpopulate(val, "AvailabilityZone", &s.AvailabilityZone) + delete(rawMsg, key) + case "backup": + err = unpopulate(val, "Backup", &s.Backup) + delete(rawMsg, key) + case "createMode": + err = unpopulate(val, "CreateMode", &s.CreateMode) + delete(rawMsg, key) + case "dataEncryption": + err = unpopulate(val, "DataEncryption", &s.DataEncryption) + delete(rawMsg, key) + case "fullyQualifiedDomainName": + err = unpopulate(val, "FullyQualifiedDomainName", &s.FullyQualifiedDomainName) + delete(rawMsg, key) + case "highAvailability": + err = unpopulate(val, "HighAvailability", &s.HighAvailability) + delete(rawMsg, key) + case "maintenanceWindow": + err = unpopulate(val, "MaintenanceWindow", &s.MaintenanceWindow) + delete(rawMsg, key) + case "network": + err = unpopulate(val, "Network", &s.Network) + delete(rawMsg, key) + case "replicaCapacity": + err = unpopulate(val, "ReplicaCapacity", &s.ReplicaCapacity) + delete(rawMsg, key) + case "replicationRole": + err = unpopulate(val, "ReplicationRole", &s.ReplicationRole) + delete(rawMsg, key) + case "restorePointInTime": + err = unpopulateTimeRFC3339(val, "RestorePointInTime", &s.RestorePointInTime) + delete(rawMsg, key) + case "sourceServerResourceId": + err = unpopulate(val, "SourceServerResourceID", &s.SourceServerResourceID) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &s.State) + delete(rawMsg, key) + case "storage": + err = unpopulate(val, "Storage", &s.Storage) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &s.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServerPropertiesForUpdate. +func (s ServerPropertiesForUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "administratorLoginPassword", s.AdministratorLoginPassword) + populate(objectMap, "backup", s.Backup) + populate(objectMap, "dataEncryption", s.DataEncryption) + populate(objectMap, "highAvailability", s.HighAvailability) + populate(objectMap, "maintenanceWindow", s.MaintenanceWindow) + populate(objectMap, "replicationRole", s.ReplicationRole) + populate(objectMap, "storage", s.Storage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerPropertiesForUpdate. +func (s *ServerPropertiesForUpdate) 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 "administratorLoginPassword": + err = unpopulate(val, "AdministratorLoginPassword", &s.AdministratorLoginPassword) + delete(rawMsg, key) + case "backup": + err = unpopulate(val, "Backup", &s.Backup) + delete(rawMsg, key) + case "dataEncryption": + err = unpopulate(val, "DataEncryption", &s.DataEncryption) + delete(rawMsg, key) + case "highAvailability": + err = unpopulate(val, "HighAvailability", &s.HighAvailability) + delete(rawMsg, key) + case "maintenanceWindow": + err = unpopulate(val, "MaintenanceWindow", &s.MaintenanceWindow) + delete(rawMsg, key) + case "replicationRole": + err = unpopulate(val, "ReplicationRole", &s.ReplicationRole) + delete(rawMsg, key) + case "storage": + err = unpopulate(val, "Storage", &s.Storage) + 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 ServerRestartParameter. +func (s ServerRestartParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "maxFailoverSeconds", s.MaxFailoverSeconds) + populate(objectMap, "restartWithFailover", s.RestartWithFailover) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerRestartParameter. +func (s *ServerRestartParameter) 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 "maxFailoverSeconds": + err = unpopulate(val, "MaxFailoverSeconds", &s.MaxFailoverSeconds) + delete(rawMsg, key) + case "restartWithFailover": + err = unpopulate(val, "RestartWithFailover", &s.RestartWithFailover) + 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 ServerVersionCapability. +func (s ServerVersionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + populate(objectMap, "supportedSkus", s.SupportedSKUs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerVersionCapability. +func (s *ServerVersionCapability) 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 "supportedSkus": + err = unpopulate(val, "SupportedSKUs", &s.SupportedSKUs) + 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 Storage. +func (s Storage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "autoGrow", s.AutoGrow) + populate(objectMap, "iops", s.Iops) + populate(objectMap, "storageSku", s.StorageSKU) + populate(objectMap, "storageSizeGB", s.StorageSizeGB) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Storage. +func (s *Storage) 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 "autoGrow": + err = unpopulate(val, "AutoGrow", &s.AutoGrow) + delete(rawMsg, key) + case "iops": + err = unpopulate(val, "Iops", &s.Iops) + delete(rawMsg, key) + case "storageSku": + err = unpopulate(val, "StorageSKU", &s.StorageSKU) + delete(rawMsg, key) + case "storageSizeGB": + err = unpopulate(val, "StorageSizeGB", &s.StorageSizeGB) + 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 StorageEditionCapability. +func (s StorageEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "maxBackupRetentionDays", s.MaxBackupRetentionDays) + populate(objectMap, "maxStorageSize", s.MaxStorageSize) + populate(objectMap, "minBackupRetentionDays", s.MinBackupRetentionDays) + populate(objectMap, "minStorageSize", s.MinStorageSize) + populate(objectMap, "name", s.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageEditionCapability. +func (s *StorageEditionCapability) 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 "maxBackupRetentionDays": + err = unpopulate(val, "MaxBackupRetentionDays", &s.MaxBackupRetentionDays) + delete(rawMsg, key) + case "maxStorageSize": + err = unpopulate(val, "MaxStorageSize", &s.MaxStorageSize) + delete(rawMsg, key) + case "minBackupRetentionDays": + err = unpopulate(val, "MinBackupRetentionDays", &s.MinBackupRetentionDays) + delete(rawMsg, key) + case "minStorageSize": + err = unpopulate(val, "MinStorageSize", &s.MinStorageSize) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + 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]any) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. +func (t *TrackedResource) 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 "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, 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 UserAssignedIdentity. +func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentity. +func (u *UserAssignedIdentity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworkSubnetUsageParameter. +func (v VirtualNetworkSubnetUsageParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "virtualNetworkResourceId", v.VirtualNetworkResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworkSubnetUsageParameter. +func (v *VirtualNetworkSubnetUsageParameter) 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 "virtualNetworkResourceId": + err = unpopulate(val, "VirtualNetworkResourceID", &v.VirtualNetworkResourceID) + 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 VirtualNetworkSubnetUsageResult. +func (v VirtualNetworkSubnetUsageResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "delegatedSubnetsUsage", v.DelegatedSubnetsUsage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworkSubnetUsageResult. +func (v *VirtualNetworkSubnetUsageResult) 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 "delegatedSubnetsUsage": + err = unpopulate(val, "DelegatedSubnetsUsage", &v.DelegatedSubnetsUsage) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_operations_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/operations_client.go similarity index 77% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_operations_client.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/operations_client.go index eac8e523877b..8daaa3b82d47 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_operations_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/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 armmysqlflexibleservers @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,36 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists all of the available REST API operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -68,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -83,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.DBforMySQL/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/operations_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/operations_client_example_test.go new file mode 100644 index 000000000000..3e71889096dc --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/operations_client_example_test.go @@ -0,0 +1,223 @@ +//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 armmysqlflexibleservers_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-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() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationListResult = armmysqlflexibleservers.OperationListResult{ + // Value: []*armmysqlflexibleservers.Operation{ + // { + // Name: to.Ptr("Microsoft.DBforMySQL/flexibleServers/firewallRules/read"), + // Display: &armmysqlflexibleservers.OperationDisplay{ + // Description: to.Ptr("Return the list of firewall rules for a server or gets the properties for the specified firewall rule."), + // Operation: to.Ptr("List/Get Firewall Rules"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("Firewall Rules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/flexibleServers/firewallRules/write"), + // Display: &armmysqlflexibleservers.OperationDisplay{ + // Description: to.Ptr("Creates a firewall rule with the specified parameters or update an existing rule."), + // Operation: to.Ptr("Create/Update Firewall Rule"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("Firewall Rules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/flexibleServers/firewallRules/delete"), + // Display: &armmysqlflexibleservers.OperationDisplay{ + // Description: to.Ptr("Deletes an existing firewall rule."), + // Operation: to.Ptr("Delete Firewall Rule"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("Firewall Rules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/flexibleServers/read"), + // Display: &armmysqlflexibleservers.OperationDisplay{ + // Description: to.Ptr("Return the list of servers or gets the properties for the specified server."), + // Operation: to.Ptr("List/Get MySQL Servers"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("MySQL Server"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/flexibleServers/write"), + // Display: &armmysqlflexibleservers.OperationDisplay{ + // Description: to.Ptr("Creates a server with the specified parameters or update the properties or tags for the specified server."), + // Operation: to.Ptr("Create/Update MySQL Server"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("MySQL Server"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/flexibleServers/delete"), + // Display: &armmysqlflexibleservers.OperationDisplay{ + // Description: to.Ptr("Deletes an existing server."), + // Operation: to.Ptr("Delete MySQL Server"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("MySQL Server"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/flexibleServers/providers/Microsoft.Insights/metricDefinitions/read"), + // Display: &armmysqlflexibleservers.OperationDisplay{ + // Description: to.Ptr("Return types of metrics that are available for databases"), + // Operation: to.Ptr("Get database metric definitions"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("Database Metric Definition"), + // }, + // Properties: map[string]any{ + // "serviceSpecification": map[string]any{ + // "metricSpecifications":[]any{ + // map[string]any{ + // "name": "cpu_percent", + // "aggregationType": "Average", + // "displayDescription": "CPU percent", + // "displayName": "CPU percent", + // "fillGapWithZero": true, + // "unit": "Percent", + // }, + // map[string]any{ + // "name": "memory_percent", + // "aggregationType": "Average", + // "displayDescription": "Memory percent", + // "displayName": "Memory percent", + // "fillGapWithZero": true, + // "unit": "Percent", + // }, + // map[string]any{ + // "name": "io_consumption_percent", + // "aggregationType": "Average", + // "displayDescription": "IO percent", + // "displayName": "IO percent", + // "fillGapWithZero": true, + // "unit": "Percent", + // }, + // map[string]any{ + // "name": "storage_percent", + // "aggregationType": "Average", + // "displayDescription": "Storage percentage", + // "displayName": "Storage percentage", + // "unit": "Percent", + // }, + // map[string]any{ + // "name": "storage_used", + // "aggregationType": "Average", + // "displayDescription": "Storage used", + // "displayName": "Storage used", + // "unit": "Bytes", + // }, + // map[string]any{ + // "name": "storage_limit", + // "aggregationType": "Average", + // "displayDescription": "Storage limit", + // "displayName": "Storage limit", + // "unit": "Bytes", + // }, + // map[string]any{ + // "name": "serverlog_storage_percent", + // "aggregationType": "Average", + // "displayDescription": "Server Log storage percent", + // "displayName": "Server Log storage percent", + // "unit": "Percent", + // }, + // map[string]any{ + // "name": "serverlog_storage_usage", + // "aggregationType": "Average", + // "displayDescription": "Server Log storage used", + // "displayName": "Server Log storage used", + // "unit": "Bytes", + // }, + // map[string]any{ + // "name": "serverlog_storage_limit", + // "aggregationType": "Average", + // "displayDescription": "Server Log storage limit", + // "displayName": "Server Log storage limit", + // "unit": "Bytes", + // }, + // map[string]any{ + // "name": "active_connections", + // "aggregationType": "Average", + // "displayDescription": "Total active connections", + // "displayName": "Total active connections", + // "fillGapWithZero": true, + // "unit": "Count", + // }, + // map[string]any{ + // "name": "connections_failed", + // "aggregationType": "Average", + // "displayDescription": "Total failed connections", + // "displayName": "Total failed connections", + // "fillGapWithZero": true, + // "unit": "Count", + // }, + // map[string]any{ + // "name": "seconds_behind_master", + // "aggregationType": "Average", + // "displayDescription": "Replication lag in seconds", + // "displayName": "Replication lag in seconds", + // "fillGapWithZero": true, + // "unit": "Count", + // }, + // }, + // }, + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/flexibleServers/providers/Microsoft.Insights/diagnosticSettings/read"), + // Display: &armmysqlflexibleservers.OperationDisplay{ + // Description: to.Ptr("Gets the disagnostic setting for the resource"), + // Operation: to.Ptr("Read diagnostic setting"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("Database Metric Definition"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DBforMySQL/flexibleServers/providers/Microsoft.Insights/diagnosticSettings/write"), + // Display: &armmysqlflexibleservers.OperationDisplay{ + // Description: to.Ptr("Creates or updates the diagnostic setting for the resource"), + // Operation: to.Ptr("Write diagnostic setting"), + // Provider: to.Ptr("Microsoft DB for MySQL"), + // Resource: to.Ptr("Database Metric Definition"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_replicas_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/replicas_client.go similarity index 78% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_replicas_client.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/replicas_client.go index 7bae208986c9..755f87e68205 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_replicas_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/replicas_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 armmysqlflexibleservers @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,41 +24,33 @@ import ( // ReplicasClient contains the methods for the Replicas group. // Don't use this type directly, use NewReplicasClient() instead. type ReplicasClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewReplicasClient creates a new instance of ReplicasClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewReplicasClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ReplicasClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ReplicasClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ReplicasClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListByServerPager - List all the replicas for a given server. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ReplicasClientListByServerOptions contains the optional parameters for the ReplicasClient.ListByServer method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ReplicasClientListByServerOptions contains the optional parameters for the ReplicasClient.NewListByServerPager +// method. func (client *ReplicasClient) NewListByServerPager(resourceGroupName string, serverName string, options *ReplicasClientListByServerOptions) *runtime.Pager[ReplicasClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[ReplicasClientListByServerResponse]{ More: func(page ReplicasClientListByServerResponse) bool { @@ -76,7 +67,7 @@ func (client *ReplicasClient) NewListByServerPager(resourceGroupName string, ser if err != nil { return ReplicasClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ReplicasClientListByServerResponse{}, err } @@ -103,7 +94,7 @@ func (client *ReplicasClient) listByServerCreateRequest(ctx context.Context, res return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/replicas_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/replicas_client_example_test.go new file mode 100644 index 000000000000..70eb44a6e31d --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/replicas_client_example_test.go @@ -0,0 +1,128 @@ +//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 armmysqlflexibleservers_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ReplicasListByServer.json +func ExampleReplicasClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewReplicasClient().NewListByServerPager("TestGroup", "mysqltestserver", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ServerListResult = armmysqlflexibleservers.ServerListResult{ + // Value: []*armmysqlflexibleservers.Server{ + // { + // Name: to.Ptr("mysqltestserver-repl"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver-repl"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("1"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-24T08:19:18.00+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("mysqltestserver-repl.orcabrci-seas1-a.mscds.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](0), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleReplica), + // SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver"), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](360), + // StorageSizeGB: to.Ptr[int32](20), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_D2ds_v4"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierGeneralPurpose), + // }, + // }, + // { + // Name: to.Ptr("mysqltestserver-repl"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver-repl2"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("1"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-23T08:19:18.00+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("mysqltestserver-repl2.orcabrci-seas1-a.mscds.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](0), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleReplica), + // SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver"), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](360), + // StorageSizeGB: to.Ptr[int32](20), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_D2ds_v4"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierGeneralPurpose), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_response_types.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/response_types.go similarity index 84% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_response_types.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/response_types.go index a2f1292a4e0e..1f95c4eba075 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_response_types.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/response_types.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armmysqlflexibleservers @@ -13,7 +14,7 @@ type BackupsClientGetResponse struct { ServerBackup } -// BackupsClientListByServerResponse contains the response from method BackupsClient.ListByServer. +// BackupsClientListByServerResponse contains the response from method BackupsClient.NewListByServerPager. type BackupsClientListByServerResponse struct { ServerBackupListResult } @@ -28,7 +29,7 @@ type CheckVirtualNetworkSubnetUsageClientExecuteResponse struct { VirtualNetworkSubnetUsageResult } -// ConfigurationsClientBatchUpdateResponse contains the response from method ConfigurationsClient.BatchUpdate. +// ConfigurationsClientBatchUpdateResponse contains the response from method ConfigurationsClient.BeginBatchUpdate. type ConfigurationsClientBatchUpdateResponse struct { ConfigurationListResult } @@ -38,22 +39,22 @@ type ConfigurationsClientGetResponse struct { Configuration } -// ConfigurationsClientListByServerResponse contains the response from method ConfigurationsClient.ListByServer. +// ConfigurationsClientListByServerResponse contains the response from method ConfigurationsClient.NewListByServerPager. type ConfigurationsClientListByServerResponse struct { ConfigurationListResult } -// ConfigurationsClientUpdateResponse contains the response from method ConfigurationsClient.Update. +// ConfigurationsClientUpdateResponse contains the response from method ConfigurationsClient.BeginUpdate. type ConfigurationsClientUpdateResponse struct { Configuration } -// DatabasesClientCreateOrUpdateResponse contains the response from method DatabasesClient.CreateOrUpdate. +// DatabasesClientCreateOrUpdateResponse contains the response from method DatabasesClient.BeginCreateOrUpdate. type DatabasesClientCreateOrUpdateResponse struct { Database } -// DatabasesClientDeleteResponse contains the response from method DatabasesClient.Delete. +// DatabasesClientDeleteResponse contains the response from method DatabasesClient.BeginDelete. type DatabasesClientDeleteResponse struct { // placeholder for future response values } @@ -63,17 +64,17 @@ type DatabasesClientGetResponse struct { Database } -// DatabasesClientListByServerResponse contains the response from method DatabasesClient.ListByServer. +// DatabasesClientListByServerResponse contains the response from method DatabasesClient.NewListByServerPager. type DatabasesClientListByServerResponse struct { DatabaseListResult } -// FirewallRulesClientCreateOrUpdateResponse contains the response from method FirewallRulesClient.CreateOrUpdate. +// FirewallRulesClientCreateOrUpdateResponse contains the response from method FirewallRulesClient.BeginCreateOrUpdate. type FirewallRulesClientCreateOrUpdateResponse struct { FirewallRule } -// FirewallRulesClientDeleteResponse contains the response from method FirewallRulesClient.Delete. +// FirewallRulesClientDeleteResponse contains the response from method FirewallRulesClient.BeginDelete. type FirewallRulesClientDeleteResponse struct { // placeholder for future response values } @@ -83,7 +84,7 @@ type FirewallRulesClientGetResponse struct { FirewallRule } -// FirewallRulesClientListByServerResponse contains the response from method FirewallRulesClient.ListByServer. +// FirewallRulesClientListByServerResponse contains the response from method FirewallRulesClient.NewListByServerPager. type FirewallRulesClientListByServerResponse struct { FirewallRuleListResult } @@ -93,32 +94,32 @@ type GetPrivateDNSZoneSuffixClientExecuteResponse struct { GetPrivateDNSZoneSuffixResponse } -// LocationBasedCapabilitiesClientListResponse contains the response from method LocationBasedCapabilitiesClient.List. +// LocationBasedCapabilitiesClientListResponse contains the response from method LocationBasedCapabilitiesClient.NewListPager. type LocationBasedCapabilitiesClientListResponse struct { CapabilitiesListResult } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult } -// ReplicasClientListByServerResponse contains the response from method ReplicasClient.ListByServer. +// ReplicasClientListByServerResponse contains the response from method ReplicasClient.NewListByServerPager. type ReplicasClientListByServerResponse struct { ServerListResult } -// ServersClientCreateResponse contains the response from method ServersClient.Create. +// ServersClientCreateResponse contains the response from method ServersClient.BeginCreate. type ServersClientCreateResponse struct { Server } -// ServersClientDeleteResponse contains the response from method ServersClient.Delete. +// ServersClientDeleteResponse contains the response from method ServersClient.BeginDelete. type ServersClientDeleteResponse struct { // placeholder for future response values } -// ServersClientFailoverResponse contains the response from method ServersClient.Failover. +// ServersClientFailoverResponse contains the response from method ServersClient.BeginFailover. type ServersClientFailoverResponse struct { // placeholder for future response values } @@ -128,32 +129,32 @@ type ServersClientGetResponse struct { Server } -// ServersClientListByResourceGroupResponse contains the response from method ServersClient.ListByResourceGroup. +// ServersClientListByResourceGroupResponse contains the response from method ServersClient.NewListByResourceGroupPager. type ServersClientListByResourceGroupResponse struct { ServerListResult } -// ServersClientListResponse contains the response from method ServersClient.List. +// ServersClientListResponse contains the response from method ServersClient.NewListPager. type ServersClientListResponse struct { ServerListResult } -// ServersClientRestartResponse contains the response from method ServersClient.Restart. +// ServersClientRestartResponse contains the response from method ServersClient.BeginRestart. type ServersClientRestartResponse struct { // placeholder for future response values } -// ServersClientStartResponse contains the response from method ServersClient.Start. +// ServersClientStartResponse contains the response from method ServersClient.BeginStart. type ServersClientStartResponse struct { // placeholder for future response values } -// ServersClientStopResponse contains the response from method ServersClient.Stop. +// ServersClientStopResponse contains the response from method ServersClient.BeginStop. type ServersClientStopResponse struct { // placeholder for future response values } -// ServersClientUpdateResponse contains the response from method ServersClient.Update. +// ServersClientUpdateResponse contains the response from method ServersClient.BeginUpdate. type ServersClientUpdateResponse struct { Server } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_servers_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/servers_client.go similarity index 85% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_servers_client.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/servers_client.go index 079e51f0fc7e..2cb55bbc4ecd 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_servers_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/servers_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 armmysqlflexibleservers @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,63 +24,56 @@ import ( // ServersClient contains the methods for the Servers group. // Don't use this type directly, use NewServersClient() instead. type ServersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServersClient creates a new instance of ServersClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ServersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Creates a new server or updates an existing server. The update action will overwrite the existing server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// parameters - The required parameters for creating or updating a server. -// options - ServersClientBeginCreateOptions contains the optional parameters for the ServersClient.BeginCreate method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - parameters - The required parameters for creating or updating a server. +// - options - ServersClientBeginCreateOptions contains the optional parameters for the ServersClient.BeginCreate method. func (client *ServersClient) BeginCreate(ctx context.Context, resourceGroupName string, serverName string, parameters Server, options *ServersClientBeginCreateOptions) (*runtime.Poller[ServersClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[ServersClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[ServersClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServersClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Creates a new server or updates an existing server. The update action will overwrite the existing server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *ServersClient) create(ctx context.Context, resourceGroupName string, serverName string, parameters Server, options *ServersClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -106,7 +98,7 @@ func (client *ServersClient) createCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -119,31 +111,33 @@ func (client *ServersClient) createCreateRequest(ctx context.Context, resourceGr // BeginDelete - Deletes a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServersClientBeginDeleteOptions contains the optional parameters for the ServersClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServersClientBeginDeleteOptions contains the optional parameters for the ServersClient.BeginDelete method. func (client *ServersClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginDeleteOptions) (*runtime.Poller[ServersClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - return runtime.NewPoller[ServersClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[ServersClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServersClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *ServersClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -168,7 +162,7 @@ func (client *ServersClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -181,31 +175,33 @@ func (client *ServersClient) deleteCreateRequest(ctx context.Context, resourceGr // BeginFailover - Manual failover a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServersClientBeginFailoverOptions contains the optional parameters for the ServersClient.BeginFailover method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServersClientBeginFailoverOptions contains the optional parameters for the ServersClient.BeginFailover method. func (client *ServersClient) BeginFailover(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginFailoverOptions) (*runtime.Poller[ServersClientFailoverResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.failover(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - return runtime.NewPoller[ServersClientFailoverResponse](resp, client.pl, nil) + return runtime.NewPoller[ServersClientFailoverResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServersClientFailoverResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientFailoverResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Failover - Manual failover a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *ServersClient) failover(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginFailoverOptions) (*http.Response, error) { req, err := client.failoverCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -230,7 +226,7 @@ func (client *ServersClient) failoverCreateRequest(ctx context.Context, resource return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -243,16 +239,17 @@ func (client *ServersClient) failoverCreateRequest(ctx context.Context, resource // Get - Gets information about a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServersClientGetOptions contains the optional parameters for the ServersClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServersClientGetOptions contains the optional parameters for the ServersClient.Get method. func (client *ServersClient) Get(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientGetOptions) (ServersClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return ServersClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientGetResponse{}, err } @@ -277,7 +274,7 @@ func (client *ServersClient) getCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -298,9 +295,9 @@ func (client *ServersClient) getHandleResponse(resp *http.Response) (ServersClie } // NewListPager - List all the servers in a given subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// options - ServersClientListOptions contains the optional parameters for the ServersClient.List method. +// - options - ServersClientListOptions contains the optional parameters for the ServersClient.NewListPager method. func (client *ServersClient) NewListPager(options *ServersClientListOptions) *runtime.Pager[ServersClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ServersClientListResponse]{ More: func(page ServersClientListResponse) bool { @@ -317,7 +314,7 @@ func (client *ServersClient) NewListPager(options *ServersClientListOptions) *ru if err != nil { return ServersClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientListResponse{}, err } @@ -336,7 +333,7 @@ func (client *ServersClient) listCreateRequest(ctx context.Context, options *Ser return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -357,11 +354,11 @@ func (client *ServersClient) listHandleResponse(resp *http.Response) (ServersCli } // NewListByResourceGroupPager - List all the servers in a given resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.NewListByResourceGroupPager +// method. func (client *ServersClient) NewListByResourceGroupPager(resourceGroupName string, options *ServersClientListByResourceGroupOptions) *runtime.Pager[ServersClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[ServersClientListByResourceGroupResponse]{ More: func(page ServersClientListByResourceGroupResponse) bool { @@ -378,7 +375,7 @@ func (client *ServersClient) NewListByResourceGroupPager(resourceGroupName strin if err != nil { return ServersClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientListByResourceGroupResponse{}, err } @@ -401,7 +398,7 @@ func (client *ServersClient) listByResourceGroupCreateRequest(ctx context.Contex return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -423,32 +420,34 @@ func (client *ServersClient) listByResourceGroupHandleResponse(resp *http.Respon // BeginRestart - Restarts a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// parameters - The required parameters for restarting a server. -// options - ServersClientBeginRestartOptions contains the optional parameters for the ServersClient.BeginRestart method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - parameters - The required parameters for restarting a server. +// - options - ServersClientBeginRestartOptions contains the optional parameters for the ServersClient.BeginRestart method. func (client *ServersClient) BeginRestart(ctx context.Context, resourceGroupName string, serverName string, parameters ServerRestartParameter, options *ServersClientBeginRestartOptions) (*runtime.Poller[ServersClientRestartResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.restart(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[ServersClientRestartResponse](resp, client.pl, nil) + return runtime.NewPoller[ServersClientRestartResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServersClientRestartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientRestartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Restart - Restarts a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *ServersClient) restart(ctx context.Context, resourceGroupName string, serverName string, parameters ServerRestartParameter, options *ServersClientBeginRestartOptions) (*http.Response, error) { req, err := client.restartCreateRequest(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -473,7 +472,7 @@ func (client *ServersClient) restartCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -486,31 +485,33 @@ func (client *ServersClient) restartCreateRequest(ctx context.Context, resourceG // BeginStart - Starts a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServersClientBeginStartOptions contains the optional parameters for the ServersClient.BeginStart method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServersClientBeginStartOptions contains the optional parameters for the ServersClient.BeginStart method. func (client *ServersClient) BeginStart(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginStartOptions) (*runtime.Poller[ServersClientStartResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.start(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - return runtime.NewPoller[ServersClientStartResponse](resp, client.pl, nil) + return runtime.NewPoller[ServersClientStartResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServersClientStartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Start - Starts a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *ServersClient) start(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginStartOptions) (*http.Response, error) { req, err := client.startCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -535,7 +536,7 @@ func (client *ServersClient) startCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -548,31 +549,33 @@ func (client *ServersClient) startCreateRequest(ctx context.Context, resourceGro // BeginStop - Stops a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServersClientBeginStopOptions contains the optional parameters for the ServersClient.BeginStop method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServersClientBeginStopOptions contains the optional parameters for the ServersClient.BeginStop method. func (client *ServersClient) BeginStop(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginStopOptions) (*runtime.Poller[ServersClientStopResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.stop(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - return runtime.NewPoller[ServersClientStopResponse](resp, client.pl, nil) + return runtime.NewPoller[ServersClientStopResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServersClientStopResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Stop - Stops a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *ServersClient) stop(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginStopOptions) (*http.Response, error) { req, err := client.stopCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -597,7 +600,7 @@ func (client *ServersClient) stopCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -611,33 +614,35 @@ func (client *ServersClient) stopCreateRequest(ctx context.Context, resourceGrou // BeginUpdate - Updates an existing server. The request body can contain one to many of the properties present in the normal // server definition. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// parameters - The required parameters for updating a server. -// options - ServersClientBeginUpdateOptions contains the optional parameters for the ServersClient.BeginUpdate method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - parameters - The required parameters for updating a server. +// - options - ServersClientBeginUpdateOptions contains the optional parameters for the ServersClient.BeginUpdate method. func (client *ServersClient) BeginUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForUpdate, options *ServersClientBeginUpdateOptions) (*runtime.Poller[ServersClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[ServersClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[ServersClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServersClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates an existing server. The request body can contain one to many of the properties present in the normal server // definition. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *ServersClient) update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForUpdate, options *ServersClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -662,7 +667,7 @@ func (client *ServersClient) updateCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/servers_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/servers_client_example_test.go new file mode 100644 index 000000000000..125077f87480 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/servers_client_example_test.go @@ -0,0 +1,1212 @@ +//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 armmysqlflexibleservers_test + +import ( + "context" + "log" + + "time" + + "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/mysql/armmysqlflexibleservers" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerCreate.json +func ExampleServersClient_BeginCreate_createANewServer() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginCreate(ctx, "testrg", "mysqltestserver", armmysqlflexibleservers.Server{ + Location: to.Ptr("southeastasia"), + Tags: map[string]*string{ + "num": to.Ptr("1"), + }, + Properties: &armmysqlflexibleservers.ServerProperties{ + AdministratorLogin: to.Ptr("cloudsa"), + AdministratorLoginPassword: to.Ptr("your_password"), + AvailabilityZone: to.Ptr("1"), + Backup: &armmysqlflexibleservers.Backup{ + BackupRetentionDays: to.Ptr[int32](7), + GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + }, + CreateMode: to.Ptr(armmysqlflexibleservers.CreateModeDefault), + HighAvailability: &armmysqlflexibleservers.HighAvailability{ + Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeZoneRedundant), + StandbyAvailabilityZone: to.Ptr("3"), + }, + Storage: &armmysqlflexibleservers.Storage{ + AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + Iops: to.Ptr[int32](600), + StorageSizeGB: to.Ptr[int32](100), + }, + Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + }, + SKU: &armmysqlflexibleservers.SKU{ + Name: to.Ptr("Standard_D2ds_v4"), + Tier: to.Ptr(armmysqlflexibleservers.SKUTierGeneralPurpose), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Server = armmysqlflexibleservers.Server{ + // Name: to.Ptr("mysqltestserver"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("1"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T06:11:38.4150019+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("mysqltestserver.database.mysql.azure.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeZoneRedundant), + // StandbyAvailabilityZone: to.Ptr("3"), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateHealthy), + // }, + // MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + // CustomWindow: to.Ptr("Disabled"), + // DayOfWeek: to.Ptr[int32](0), + // StartHour: to.Ptr[int32](0), + // StartMinute: to.Ptr[int32](0), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](10), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](600), + // StorageSizeGB: to.Ptr[int32](100), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_D2ds_v4"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierGeneralPurpose), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerCreateReplica.json +func ExampleServersClient_BeginCreate_createAReplicaServer() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginCreate(ctx, "testgr", "replica-server", armmysqlflexibleservers.Server{ + Location: to.Ptr("SoutheastAsia"), + Properties: &armmysqlflexibleservers.ServerProperties{ + CreateMode: to.Ptr(armmysqlflexibleservers.CreateModeReplica), + SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testgr/providers/Microsoft.DBforMySQL/flexibleServers/source-server"), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Server = armmysqlflexibleservers.Server{ + // Name: to.Ptr("replica-server"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testgr/providers/Microsoft.DBforMySQL/flexibleServers/replica-server"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "ElasticServer": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("3"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-24T08:19:18.5729164+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("replica-server.database.mysql.azure.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled), + // }, + // MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + // CustomWindow: to.Ptr("Disabled"), + // DayOfWeek: to.Ptr[int32](0), + // StartHour: to.Ptr[int32](0), + // StartMinute: to.Ptr[int32](0), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](0), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleReplica), + // SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testgr/providers/Microsoft.DBforMySQL/flexibleServers/source-server"), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](360), + // StorageSizeGB: to.Ptr[int32](20), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_D2ds_v4"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierGeneralPurpose), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerCreateWithPointInTimeRestore.json +func ExampleServersClient_BeginCreate_createAServerAsAPointInTimeRestore() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginCreate(ctx, "TargetResourceGroup", "targetserver", armmysqlflexibleservers.Server{ + Location: to.Ptr("SoutheastAsia"), + Tags: map[string]*string{ + "num": to.Ptr("1"), + }, + Properties: &armmysqlflexibleservers.ServerProperties{ + CreateMode: to.Ptr(armmysqlflexibleservers.CreateModePointInTimeRestore), + RestorePointInTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-24T00:00:37.467Z"); return t }()), + SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/flexibleServers/sourceserver"), + }, + SKU: &armmysqlflexibleservers.SKU{ + Name: to.Ptr("Standard_D14_v2"), + Tier: to.Ptr(armmysqlflexibleservers.SKUTierGeneralPurpose), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Server = armmysqlflexibleservers.Server{ + // Name: to.Ptr("targetserver"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TargetResourceGroup/providers/Microsoft.DBforMySQL/flexibleServers/targetserver"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("adminuser"), + // AvailabilityZone: to.Ptr("1"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-24T00:15:24.00+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("targetserver.database.mysql.azure.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled), + // }, + // MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + // CustomWindow: to.Ptr("Disabled"), + // DayOfWeek: to.Ptr[int32](0), + // StartHour: to.Ptr[int32](0), + // StartMinute: to.Ptr[int32](0), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](10), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](360), + // StorageSizeGB: to.Ptr[int32](20), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_D2ds_v4"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierGeneralPurpose), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerCreateWithBYOK.json +func ExampleServersClient_BeginCreate_createAServerWithByok() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginCreate(ctx, "testrg", "mysqltestserver", armmysqlflexibleservers.Server{ + Location: to.Ptr("southeastasia"), + Tags: map[string]*string{ + "num": to.Ptr("1"), + }, + Identity: &armmysqlflexibleservers.Identity{ + Type: to.Ptr("UserAssigned"), + UserAssignedIdentities: map[string]any{ + "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": map[string]any{}, + }, + }, + Properties: &armmysqlflexibleservers.ServerProperties{ + AdministratorLogin: to.Ptr("cloudsa"), + AdministratorLoginPassword: to.Ptr("your_password"), + AvailabilityZone: to.Ptr("1"), + Backup: &armmysqlflexibleservers.Backup{ + BackupRetentionDays: to.Ptr[int32](7), + GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + }, + CreateMode: to.Ptr(armmysqlflexibleservers.CreateModeDefault), + DataEncryption: &armmysqlflexibleservers.DataEncryption{ + Type: to.Ptr(armmysqlflexibleservers.DataEncryptionTypeAzureKeyVault), + GeoBackupKeyURI: to.Ptr("https://test-geo.vault.azure.net/keys/key/c8a92236622244c0a4fdb892666f671a"), + GeoBackupUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-identity"), + PrimaryKeyURI: to.Ptr("https://test.vault.azure.net/keys/key/c8a92236622244c0a4fdb892666f671a"), + PrimaryUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity"), + }, + HighAvailability: &armmysqlflexibleservers.HighAvailability{ + Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeZoneRedundant), + StandbyAvailabilityZone: to.Ptr("3"), + }, + Storage: &armmysqlflexibleservers.Storage{ + AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + Iops: to.Ptr[int32](600), + StorageSizeGB: to.Ptr[int32](100), + }, + Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + }, + SKU: &armmysqlflexibleservers.SKU{ + Name: to.Ptr("Standard_D2ds_v4"), + Tier: to.Ptr(armmysqlflexibleservers.SKUTierGeneralPurpose), + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Server = armmysqlflexibleservers.Server{ + // Name: to.Ptr("mysqltestserver"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("1"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T06:11:38.4150019+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("mysqltestserver.database.mysql.azure.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeZoneRedundant), + // StandbyAvailabilityZone: to.Ptr("3"), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateHealthy), + // }, + // MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + // CustomWindow: to.Ptr("Disabled"), + // DayOfWeek: to.Ptr[int32](0), + // StartHour: to.Ptr[int32](0), + // StartMinute: to.Ptr[int32](0), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](10), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](600), + // StorageSizeGB: to.Ptr[int32](100), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_D2ds_v4"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierGeneralPurpose), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerUpdate.json +func ExampleServersClient_BeginUpdate_updateAServer() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginUpdate(ctx, "testrg", "mysqltestserver", armmysqlflexibleservers.ServerForUpdate{ + Properties: &armmysqlflexibleservers.ServerPropertiesForUpdate{ + Storage: &armmysqlflexibleservers.Storage{ + AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + Iops: to.Ptr[int32](200), + StorageSizeGB: to.Ptr[int32](30), + }, + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Server = armmysqlflexibleservers.Server{ + // Name: to.Ptr("mysqltestserver"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("3"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T06:11:38.4150019+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("mysqltestserver.database.mysql.azure.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled), + // }, + // MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + // CustomWindow: to.Ptr("Enabled"), + // DayOfWeek: to.Ptr[int32](1), + // StartHour: to.Ptr[int32](1), + // StartMinute: to.Ptr[int32](0), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](10), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // Iops: to.Ptr[int32](200), + // StorageSizeGB: to.Ptr[int32](30), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_D2ds_v4"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierGeneralPurpose), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerUpdateWithCustomerMaintenanceWindow.json +func ExampleServersClient_BeginUpdate_updateServerCustomerMaintenanceWindow() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginUpdate(ctx, "testrg", "mysqltestserver", armmysqlflexibleservers.ServerForUpdate{ + Properties: &armmysqlflexibleservers.ServerPropertiesForUpdate{ + MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + CustomWindow: to.Ptr("Enabled"), + DayOfWeek: to.Ptr[int32](1), + StartHour: to.Ptr[int32](8), + StartMinute: to.Ptr[int32](0), + }, + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Server = armmysqlflexibleservers.Server{ + // Name: to.Ptr("mysqltestserver"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("3"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T06:11:38.4150019+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("mysqltestserver.database.mysql.azure.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled), + // }, + // MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + // CustomWindow: to.Ptr("Enabled"), + // DayOfWeek: to.Ptr[int32](1), + // StartHour: to.Ptr[int32](8), + // StartMinute: to.Ptr[int32](0), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](10), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](600), + // StorageSizeGB: to.Ptr[int32](100), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_D2ds_v4"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierGeneralPurpose), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerUpdateWithBYOK.json +func ExampleServersClient_BeginUpdate_updateServerWithByok() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginUpdate(ctx, "testrg", "mysqltestserver", armmysqlflexibleservers.ServerForUpdate{ + Identity: &armmysqlflexibleservers.Identity{ + Type: to.Ptr("UserAssigned"), + UserAssignedIdentities: map[string]any{ + "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": map[string]any{}, + }, + }, + Properties: &armmysqlflexibleservers.ServerPropertiesForUpdate{ + DataEncryption: &armmysqlflexibleservers.DataEncryption{ + Type: to.Ptr(armmysqlflexibleservers.DataEncryptionTypeAzureKeyVault), + GeoBackupKeyURI: to.Ptr("https://test-geo.vault.azure.net/keys/key/c8a92236622244c0a4fdb892666f671a"), + GeoBackupUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-identity"), + PrimaryKeyURI: to.Ptr("https://test.vault.azure.net/keys/key/c8a92236622244c0a4fdb892666f671a"), + PrimaryUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity"), + }, + }, + }, 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) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Server = armmysqlflexibleservers.Server{ + // Name: to.Ptr("mysqltestserver"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("1"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T06:11:38.4150019+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("mysqltestserver.database.mysql.azure.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeZoneRedundant), + // StandbyAvailabilityZone: to.Ptr("3"), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateHealthy), + // }, + // MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + // CustomWindow: to.Ptr("Disabled"), + // DayOfWeek: to.Ptr[int32](0), + // StartHour: to.Ptr[int32](0), + // StartMinute: to.Ptr[int32](0), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](10), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](600), + // StorageSizeGB: to.Ptr[int32](100), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_D2ds_v4"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierGeneralPurpose), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerDelete.json +func ExampleServersClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginDelete(ctx, "TestGroup", "testserver", 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerGet.json +func ExampleServersClient_Get_getAServer() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServersClient().Get(ctx, "testrg", "mysqltestserver", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Server = armmysqlflexibleservers.Server{ + // Name: to.Ptr("mysqltestserver"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("3"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T06:11:38.4150019+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("mysqltestserver.database.mysql.azure.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled), + // }, + // MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + // CustomWindow: to.Ptr("Enabled"), + // DayOfWeek: to.Ptr[int32](1), + // StartHour: to.Ptr[int32](1), + // StartMinute: to.Ptr[int32](0), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](10), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](600), + // StorageSizeGB: to.Ptr[int32](100), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_D2ds_v4"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierGeneralPurpose), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerGetWithVnet.json +func ExampleServersClient_Get_getAServerWithVnet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServersClient().Get(ctx, "testrg", "mysqltestserver", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Server = armmysqlflexibleservers.Server{ + // Name: to.Ptr("mysqltestserver"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("3"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T06:11:38.4150019+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("mysqltestserver.database.mysql.azure.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled), + // }, + // MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + // CustomWindow: to.Ptr("Disabled"), + // DayOfWeek: to.Ptr[int32](0), + // StartHour: to.Ptr[int32](0), + // StartMinute: to.Ptr[int32](0), + // }, + // Network: &armmysqlflexibleservers.Network{ + // DelegatedSubnetResourceID: to.Ptr("/subscriptions/2941a09d-7bcf-42fe-91ca-1765f521c829/resourceGroups/OrcabrCI-Vnet-Resource-Group/providers/Microsoft.Network/virtualNetworks/OrcabrCI-Vnet/subnets/mysql-subnet"), + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // ReplicaCapacity: to.Ptr[int32](10), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](600), + // StorageSizeGB: to.Ptr[int32](100), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_D2ds_v4"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierGeneralPurpose), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServersListByResourceGroup.json +func ExampleServersClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServersClient().NewListByResourceGroupPager("TestGroup", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ServerListResult = armmysqlflexibleservers.ServerListResult{ + // Value: []*armmysqlflexibleservers.Server{ + // { + // Name: to.Ptr("mysqltestserver1"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver1"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("1"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T07:08:17.4259886+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("mysqltestserver1.database.mysql.azure.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled), + // }, + // MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + // CustomWindow: to.Ptr("Disabled"), + // DayOfWeek: to.Ptr[int32](0), + // StartHour: to.Ptr[int32](0), + // StartMinute: to.Ptr[int32](0), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](10), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](369), + // StorageSizeGB: to.Ptr[int32](23), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_B1ms"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierBurstable), + // }, + // }, + // { + // Name: to.Ptr("mysqltestserver2"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver2"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("2"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T07:08:17.4259886+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("mysqltestserver2.mysql.database.azure.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled), + // }, + // MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + // CustomWindow: to.Ptr("Disabled"), + // DayOfWeek: to.Ptr[int32](0), + // StartHour: to.Ptr[int32](0), + // StartMinute: to.Ptr[int32](0), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](10), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](369), + // StorageSizeGB: to.Ptr[int32](23), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_B1ms"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierBurstable), + // }, + // }, + // { + // Name: to.Ptr("mysqltestserver3"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver3"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("1"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-24T06:28:19.0611667+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("mysqltestserver3.mysql.database.azure.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled), + // }, + // MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + // CustomWindow: to.Ptr("Disabled"), + // DayOfWeek: to.Ptr[int32](0), + // StartHour: to.Ptr[int32](0), + // StartMinute: to.Ptr[int32](0), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](10), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](600), + // StorageSizeGB: to.Ptr[int32](100), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_E2ds_v4"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierMemoryOptimized), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServersList.json +func ExampleServersClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServersClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ServerListResult = armmysqlflexibleservers.ServerListResult{ + // Value: []*armmysqlflexibleservers.Server{ + // { + // Name: to.Ptr("mysqltestserver1"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver1"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("1"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T07:08:17.4259886+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("mysqltestserver1.database.mysql.azure.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled), + // }, + // MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + // CustomWindow: to.Ptr("Disabled"), + // DayOfWeek: to.Ptr[int32](0), + // StartHour: to.Ptr[int32](0), + // StartMinute: to.Ptr[int32](0), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](10), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](369), + // StorageSizeGB: to.Ptr[int32](23), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_B1ms"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierBurstable), + // }, + // }, + // { + // Name: to.Ptr("mysqltestserver2"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup2/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver2"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("2"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T07:08:17.4259886+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("mysqltestserver2.mysql.database.azure.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled), + // }, + // MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + // CustomWindow: to.Ptr("Disabled"), + // DayOfWeek: to.Ptr[int32](0), + // StartHour: to.Ptr[int32](0), + // StartMinute: to.Ptr[int32](0), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](10), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](369), + // StorageSizeGB: to.Ptr[int32](23), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_B1ms"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierBurstable), + // }, + // }, + // { + // Name: to.Ptr("mysqltestserver3"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup3/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver3"), + // Location: to.Ptr("Southeast Asia"), + // Tags: map[string]*string{ + // "num": to.Ptr("1"), + // }, + // Properties: &armmysqlflexibleservers.ServerProperties{ + // AdministratorLogin: to.Ptr("cloudsa"), + // AvailabilityZone: to.Ptr("1"), + // Backup: &armmysqlflexibleservers.Backup{ + // BackupRetentionDays: to.Ptr[int32](7), + // EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-24T06:28:19.0611667+00:00"); return t}()), + // GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // }, + // FullyQualifiedDomainName: to.Ptr("mysqltestserver3.mysql.database.azure.com"), + // HighAvailability: &armmysqlflexibleservers.HighAvailability{ + // Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled), + // State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled), + // }, + // MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{ + // CustomWindow: to.Ptr("Disabled"), + // DayOfWeek: to.Ptr[int32](0), + // StartHour: to.Ptr[int32](0), + // StartMinute: to.Ptr[int32](0), + // }, + // Network: &armmysqlflexibleservers.Network{ + // PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // }, + // ReplicaCapacity: to.Ptr[int32](10), + // ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone), + // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), + // Storage: &armmysqlflexibleservers.Storage{ + // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // Iops: to.Ptr[int32](600), + // StorageSizeGB: to.Ptr[int32](100), + // StorageSKU: to.Ptr("Premium_LRS"), + // }, + // Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), + // }, + // SKU: &armmysqlflexibleservers.SKU{ + // Name: to.Ptr("Standard_E2ds_v4"), + // Tier: to.Ptr(armmysqlflexibleservers.SKUTierMemoryOptimized), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerFailover.json +func ExampleServersClient_BeginFailover() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginFailover(ctx, "TestGroup", "testserver", 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerRestart.json +func ExampleServersClient_BeginRestart() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginRestart(ctx, "TestGroup", "testserver", armmysqlflexibleservers.ServerRestartParameter{ + MaxFailoverSeconds: to.Ptr[int32](60), + RestartWithFailover: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + }, 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerStart.json +func ExampleServersClient_BeginStart() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginStart(ctx, "TestGroup", "testserver", 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerStop.json +func ExampleServersClient_BeginStop() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginStop(ctx, "TestGroup", "testserver", 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) + } +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_time_rfc3339.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/mysql/armmysqlflexibleservers/time_rfc3339.go index 470c33714de5..c8379cd58840 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/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 armmysqlflexibleservers @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_backups_client_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_backups_client_test.go deleted file mode 100644 index 454678165fd0..000000000000 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_backups_client_test.go +++ /dev/null @@ -1,66 +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 armmysqlflexibleservers_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/BackupGet.json -func ExampleBackupsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewBackupsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "TestGroup", - "mysqltestserver", - "daily_20210615T160516", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/BackupsListByServer.json -func ExampleBackupsClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewBackupsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("TestGroup", - "mysqltestserver", - 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/mysql/armmysqlflexibleservers/ze_generated_example_checkvirtualnetworksubnetusage_client_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_checkvirtualnetworksubnetusage_client_test.go deleted file mode 100644 index 165dec2fcecf..000000000000 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_checkvirtualnetworksubnetusage_client_test.go +++ /dev/null @@ -1,42 +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 armmysqlflexibleservers_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/mysql/armmysqlflexibleservers" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/CheckVirtualNetworkSubnetUsage.json -func ExampleCheckVirtualNetworkSubnetUsageClient_Execute() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewCheckVirtualNetworkSubnetUsageClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Execute(ctx, - "WestUS", - armmysqlflexibleservers.VirtualNetworkSubnetUsageParameter{ - VirtualNetworkResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/testvnet"), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_configurations_client_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_configurations_client_test.go deleted file mode 100644 index 1a700718bade..000000000000 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_configurations_client_test.go +++ /dev/null @@ -1,141 +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 armmysqlflexibleservers_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/mysql/armmysqlflexibleservers" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ConfigurationUpdate.json -func ExampleConfigurationsClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewConfigurationsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "testrg", - "testserver", - "event_scheduler", - armmysqlflexibleservers.Configuration{ - Properties: &armmysqlflexibleservers.ConfigurationProperties{ - Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceUserOverride), - Value: to.Ptr("on"), - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ConfigurationGet.json -func ExampleConfigurationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewConfigurationsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "TestGroup", - "testserver", - "event_scheduler", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ConfigurationsBatchUpdate.json -func ExampleConfigurationsClient_BeginBatchUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewConfigurationsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginBatchUpdate(ctx, - "testrg", - "mysqltestserver", - armmysqlflexibleservers.ConfigurationListForBatchUpdate{ - Value: []*armmysqlflexibleservers.ConfigurationForBatchUpdate{ - { - Name: to.Ptr("event_scheduler"), - Properties: &armmysqlflexibleservers.ConfigurationForBatchUpdateProperties{ - Value: to.Ptr("OFF"), - }, - }, - { - Name: to.Ptr("div_precision_increment"), - Properties: &armmysqlflexibleservers.ConfigurationForBatchUpdateProperties{ - Value: to.Ptr("8"), - }, - }}, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ConfigurationsListByServer.json -func ExampleConfigurationsClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewConfigurationsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("testrg", - "mysqltestserver", - 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/mysql/armmysqlflexibleservers/ze_generated_example_databases_client_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_databases_client_test.go deleted file mode 100644 index d3fcaea3c5dc..000000000000 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_databases_client_test.go +++ /dev/null @@ -1,125 +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 armmysqlflexibleservers_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/mysql/armmysqlflexibleservers" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/DatabaseCreate.json -func ExampleDatabasesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewDatabasesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "TestGroup", - "testserver", - "db1", - armmysqlflexibleservers.Database{ - Properties: &armmysqlflexibleservers.DatabaseProperties{ - Charset: to.Ptr("utf8"), - Collation: to.Ptr("utf8_general_ci"), - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/DatabaseDelete.json -func ExampleDatabasesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewDatabasesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "TestGroup", - "testserver", - "db1", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/DatabaseGet.json -func ExampleDatabasesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewDatabasesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "TestGroup", - "testserver", - "db1", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/DatabasesListByServer.json -func ExampleDatabasesClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewDatabasesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("TestGroup", - "testserver", - 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/mysql/armmysqlflexibleservers/ze_generated_example_firewallrules_client_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_firewallrules_client_test.go deleted file mode 100644 index 5c7a13ab379e..000000000000 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_firewallrules_client_test.go +++ /dev/null @@ -1,125 +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 armmysqlflexibleservers_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/mysql/armmysqlflexibleservers" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/FirewallRuleCreate.json -func ExampleFirewallRulesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewFirewallRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "TestGroup", - "testserver", - "rule1", - armmysqlflexibleservers.FirewallRule{ - Properties: &armmysqlflexibleservers.FirewallRuleProperties{ - EndIPAddress: to.Ptr("255.255.255.255"), - StartIPAddress: to.Ptr("0.0.0.0"), - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/FirewallRuleDelete.json -func ExampleFirewallRulesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewFirewallRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "TestGroup", - "testserver", - "rule1", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/FirewallRuleGet.json -func ExampleFirewallRulesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewFirewallRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "TestGroup", - "testserver", - "rule1", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/FirewallRulesListByServer.json -func ExampleFirewallRulesClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewFirewallRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("TestGroup", - "testserver", - 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/mysql/armmysqlflexibleservers/ze_generated_example_locationbasedcapabilities_client_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_locationbasedcapabilities_client_test.go deleted file mode 100644 index b25bd3b6e632..000000000000 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_locationbasedcapabilities_client_test.go +++ /dev/null @@ -1,42 +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 armmysqlflexibleservers_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/CapabilitiesByLocationList.json -func ExampleLocationBasedCapabilitiesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewLocationBasedCapabilitiesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("WestUS", - 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/mysql/armmysqlflexibleservers/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_operations_client_test.go deleted file mode 100644 index 85efde524d03..000000000000 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/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 armmysqlflexibleservers_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-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 := armmysqlflexibleservers.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/mysql/armmysqlflexibleservers/ze_generated_example_replicas_client_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_replicas_client_test.go deleted file mode 100644 index eff92f3584b5..000000000000 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_replicas_client_test.go +++ /dev/null @@ -1,43 +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 armmysqlflexibleservers_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ReplicasListByServer.json -func ExampleReplicasClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewReplicasClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("TestGroup", - "mysqltestserver", - 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/mysql/armmysqlflexibleservers/ze_generated_example_servers_client_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_servers_client_test.go deleted file mode 100644 index 9afa86f855e8..000000000000 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/ze_generated_example_servers_client_test.go +++ /dev/null @@ -1,304 +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 armmysqlflexibleservers_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/mysql/armmysqlflexibleservers" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerCreate.json -func ExampleServersClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "testrg", - "mysqltestserver", - armmysqlflexibleservers.Server{ - Location: to.Ptr("southeastasia"), - Tags: map[string]*string{ - "num": to.Ptr("1"), - }, - Properties: &armmysqlflexibleservers.ServerProperties{ - AdministratorLogin: to.Ptr("cloudsa"), - AdministratorLoginPassword: to.Ptr("your_password"), - AvailabilityZone: to.Ptr("1"), - Backup: &armmysqlflexibleservers.Backup{ - BackupRetentionDays: to.Ptr[int32](7), - GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), - }, - CreateMode: to.Ptr(armmysqlflexibleservers.CreateModeDefault), - HighAvailability: &armmysqlflexibleservers.HighAvailability{ - Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeZoneRedundant), - StandbyAvailabilityZone: to.Ptr("3"), - }, - Storage: &armmysqlflexibleservers.Storage{ - AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), - Iops: to.Ptr[int32](600), - StorageSizeGB: to.Ptr[int32](100), - }, - Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7), - }, - SKU: &armmysqlflexibleservers.SKU{ - Name: to.Ptr("Standard_D2ds_v4"), - Tier: to.Ptr(armmysqlflexibleservers.SKUTierGeneralPurpose), - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerUpdate.json -func ExampleServersClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "testrg", - "mysqltestserver", - armmysqlflexibleservers.ServerForUpdate{ - Properties: &armmysqlflexibleservers.ServerPropertiesForUpdate{ - Storage: &armmysqlflexibleservers.Storage{ - AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), - Iops: to.Ptr[int32](200), - StorageSizeGB: to.Ptr[int32](30), - }, - }, - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerDelete.json -func ExampleServersClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "TestGroup", - "testserver", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerGet.json -func ExampleServersClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "testrg", - "mysqltestserver", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServersListByResourceGroup.json -func ExampleServersClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("TestGroup", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServersList.json -func ExampleServersClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", 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 - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerFailover.json -func ExampleServersClient_BeginFailover() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginFailover(ctx, - "TestGroup", - "testserver", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerRestart.json -func ExampleServersClient_BeginRestart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginRestart(ctx, - "TestGroup", - "testserver", - armmysqlflexibleservers.ServerRestartParameter{ - MaxFailoverSeconds: to.Ptr[int32](60), - RestartWithFailover: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), - }, - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerStart.json -func ExampleServersClient_BeginStart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStart(ctx, - "TestGroup", - "testserver", - 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/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerStop.json -func ExampleServersClient_BeginStop() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmysqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStop(ctx, - "TestGroup", - "testserver", - 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) - } -} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_models_serde.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_models_serde.go deleted file mode 100644 index d4d6639a7711..000000000000 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/zz_generated_models_serde.go +++ /dev/null @@ -1,308 +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 armmysqlflexibleservers - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type Backup. -func (b Backup) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "backupRetentionDays", b.BackupRetentionDays) - populateTimeRFC3339(objectMap, "earliestRestoreDate", b.EarliestRestoreDate) - populate(objectMap, "geoRedundantBackup", b.GeoRedundantBackup) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Backup. -func (b *Backup) 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", b, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "backupRetentionDays": - err = unpopulate(val, "BackupRetentionDays", &b.BackupRetentionDays) - delete(rawMsg, key) - case "earliestRestoreDate": - err = unpopulateTimeRFC3339(val, "EarliestRestoreDate", &b.EarliestRestoreDate) - delete(rawMsg, key) - case "geoRedundantBackup": - err = unpopulate(val, "GeoRedundantBackup", &b.GeoRedundantBackup) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Configuration. -func (c Configuration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", c.ID) - populate(objectMap, "name", c.Name) - populate(objectMap, "properties", c.Properties) - populate(objectMap, "systemData", c.SystemData) - populate(objectMap, "type", c.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ConfigurationListForBatchUpdate. -func (c ConfigurationListForBatchUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "value", c.Value) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Identity. -func (i Identity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "principalId", i.PrincipalID) - populate(objectMap, "tenantId", i.TenantID) - populate(objectMap, "type", i.Type) - populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Server. -func (s Server) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", s.ID) - populate(objectMap, "identity", s.Identity) - populate(objectMap, "location", s.Location) - populate(objectMap, "name", s.Name) - populate(objectMap, "properties", s.Properties) - populate(objectMap, "sku", s.SKU) - populate(objectMap, "systemData", s.SystemData) - populate(objectMap, "tags", s.Tags) - populate(objectMap, "type", s.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ServerBackupProperties. -func (s ServerBackupProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "backupType", s.BackupType) - populateTimeRFC3339(objectMap, "completedTime", s.CompletedTime) - populate(objectMap, "source", s.Source) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ServerBackupProperties. -func (s *ServerBackupProperties) 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 "backupType": - err = unpopulate(val, "BackupType", &s.BackupType) - delete(rawMsg, key) - case "completedTime": - err = unpopulateTimeRFC3339(val, "CompletedTime", &s.CompletedTime) - delete(rawMsg, key) - case "source": - err = unpopulate(val, "Source", &s.Source) - 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 ServerForUpdate. -func (s ServerForUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "identity", s.Identity) - populate(objectMap, "properties", s.Properties) - populate(objectMap, "sku", s.SKU) - populate(objectMap, "tags", s.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ServerProperties. -func (s ServerProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "administratorLogin", s.AdministratorLogin) - populate(objectMap, "administratorLoginPassword", s.AdministratorLoginPassword) - populate(objectMap, "availabilityZone", s.AvailabilityZone) - populate(objectMap, "backup", s.Backup) - populate(objectMap, "createMode", s.CreateMode) - populate(objectMap, "dataEncryption", s.DataEncryption) - populate(objectMap, "fullyQualifiedDomainName", s.FullyQualifiedDomainName) - populate(objectMap, "highAvailability", s.HighAvailability) - populate(objectMap, "maintenanceWindow", s.MaintenanceWindow) - populate(objectMap, "network", s.Network) - populate(objectMap, "replicaCapacity", s.ReplicaCapacity) - populate(objectMap, "replicationRole", s.ReplicationRole) - populateTimeRFC3339(objectMap, "restorePointInTime", s.RestorePointInTime) - populate(objectMap, "sourceServerResourceId", s.SourceServerResourceID) - populate(objectMap, "state", s.State) - populate(objectMap, "storage", s.Storage) - populate(objectMap, "version", s.Version) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ServerProperties. -func (s *ServerProperties) 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 "administratorLogin": - err = unpopulate(val, "AdministratorLogin", &s.AdministratorLogin) - delete(rawMsg, key) - case "administratorLoginPassword": - err = unpopulate(val, "AdministratorLoginPassword", &s.AdministratorLoginPassword) - delete(rawMsg, key) - case "availabilityZone": - err = unpopulate(val, "AvailabilityZone", &s.AvailabilityZone) - delete(rawMsg, key) - case "backup": - err = unpopulate(val, "Backup", &s.Backup) - delete(rawMsg, key) - case "createMode": - err = unpopulate(val, "CreateMode", &s.CreateMode) - delete(rawMsg, key) - case "dataEncryption": - err = unpopulate(val, "DataEncryption", &s.DataEncryption) - delete(rawMsg, key) - case "fullyQualifiedDomainName": - err = unpopulate(val, "FullyQualifiedDomainName", &s.FullyQualifiedDomainName) - delete(rawMsg, key) - case "highAvailability": - err = unpopulate(val, "HighAvailability", &s.HighAvailability) - delete(rawMsg, key) - case "maintenanceWindow": - err = unpopulate(val, "MaintenanceWindow", &s.MaintenanceWindow) - delete(rawMsg, key) - case "network": - err = unpopulate(val, "Network", &s.Network) - delete(rawMsg, key) - case "replicaCapacity": - err = unpopulate(val, "ReplicaCapacity", &s.ReplicaCapacity) - delete(rawMsg, key) - case "replicationRole": - err = unpopulate(val, "ReplicationRole", &s.ReplicationRole) - delete(rawMsg, key) - case "restorePointInTime": - err = unpopulateTimeRFC3339(val, "RestorePointInTime", &s.RestorePointInTime) - delete(rawMsg, key) - case "sourceServerResourceId": - err = unpopulate(val, "SourceServerResourceID", &s.SourceServerResourceID) - delete(rawMsg, key) - case "state": - err = unpopulate(val, "State", &s.State) - delete(rawMsg, key) - case "storage": - err = unpopulate(val, "Storage", &s.Storage) - delete(rawMsg, key) - case "version": - err = unpopulate(val, "Version", &s.Version) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - 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 TrackedResource. -func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -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/networkfunction/armnetworkfunction/CHANGELOG.md b/sdk/resourcemanager/networkfunction/armnetworkfunction/CHANGELOG.md index 04923715da17..d773a1ee5e51 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/CHANGELOG.md +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 2.1.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 2.0.0 (2022-12-23) ### Breaking Changes diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/README.md b/sdk/resourcemanager/networkfunction/armnetworkfunction/README.md index 5d90cf390598..521154a2e784 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/README.md +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/README.md @@ -33,23 +33,31 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Network Function Manager modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Network Function Manager module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armnetworkfunction.NewAzureTrafficCollectorsClient(, cred, nil) +clientFactory, err := armnetworkfunction.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). ```go -options := arm.ClientOptions{ +options := arm.ClientOptions { ClientOptions: azcore.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armnetworkfunction.NewAzureTrafficCollectorsClient(, cred, &options) +clientFactory, err := armnetworkfunction.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/autorest.md b/sdk/resourcemanager/networkfunction/armnetworkfunction/autorest.md index f09192912228..56bf15f0f5c3 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/autorest.md +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/527f6d35fb0d85c48210ca0f6f6f42814d63bd33/specification/networkfunction/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/527f6d35fb0d85c48210ca0f6f6f42814d63bd33/specification/networkfunction/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.0.0 +module-version: 2.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectors_client.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectors_client.go index 7267cb8e57cd..f5359df79380 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectors_client.go +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectors_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,66 +24,59 @@ import ( // AzureTrafficCollectorsClient contains the methods for the AzureTrafficCollectors group. // Don't use this type directly, use NewAzureTrafficCollectorsClient() instead. type AzureTrafficCollectorsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAzureTrafficCollectorsClient creates a new instance of AzureTrafficCollectorsClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAzureTrafficCollectorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AzureTrafficCollectorsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AzureTrafficCollectorsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AzureTrafficCollectorsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a Azure Traffic Collector resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. -// azureTrafficCollectorName - Azure Traffic Collector name -// parameters - The parameters to provide for the created Azure Traffic Collector. -// options - AzureTrafficCollectorsClientBeginCreateOrUpdateOptions contains the optional parameters for the AzureTrafficCollectorsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - azureTrafficCollectorName - Azure Traffic Collector name +// - parameters - The parameters to provide for the created Azure Traffic Collector. +// - options - AzureTrafficCollectorsClientBeginCreateOrUpdateOptions contains the optional parameters for the AzureTrafficCollectorsClient.BeginCreateOrUpdate +// method. func (client *AzureTrafficCollectorsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, azureTrafficCollectorName string, parameters AzureTrafficCollector, options *AzureTrafficCollectorsClientBeginCreateOrUpdateOptions) (*runtime.Poller[AzureTrafficCollectorsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, azureTrafficCollectorName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AzureTrafficCollectorsClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AzureTrafficCollectorsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[AzureTrafficCollectorsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AzureTrafficCollectorsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a Azure Traffic Collector resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *AzureTrafficCollectorsClient) createOrUpdate(ctx context.Context, resourceGroupName string, azureTrafficCollectorName string, parameters AzureTrafficCollector, options *AzureTrafficCollectorsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, azureTrafficCollectorName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -110,7 +101,7 @@ func (client *AzureTrafficCollectorsClient) createOrUpdateCreateRequest(ctx cont return nil, errors.New("parameter azureTrafficCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{azureTrafficCollectorName}", url.PathEscape(azureTrafficCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -123,34 +114,36 @@ func (client *AzureTrafficCollectorsClient) createOrUpdateCreateRequest(ctx cont // BeginDelete - Deletes a specified Azure Traffic Collector resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. -// azureTrafficCollectorName - Azure Traffic Collector name -// options - AzureTrafficCollectorsClientBeginDeleteOptions contains the optional parameters for the AzureTrafficCollectorsClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. +// - azureTrafficCollectorName - Azure Traffic Collector name +// - options - AzureTrafficCollectorsClientBeginDeleteOptions contains the optional parameters for the AzureTrafficCollectorsClient.BeginDelete +// method. func (client *AzureTrafficCollectorsClient) BeginDelete(ctx context.Context, resourceGroupName string, azureTrafficCollectorName string, options *AzureTrafficCollectorsClientBeginDeleteOptions) (*runtime.Poller[AzureTrafficCollectorsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, azureTrafficCollectorName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AzureTrafficCollectorsClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AzureTrafficCollectorsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[AzureTrafficCollectorsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AzureTrafficCollectorsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a specified Azure Traffic Collector resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *AzureTrafficCollectorsClient) deleteOperation(ctx context.Context, resourceGroupName string, azureTrafficCollectorName string, options *AzureTrafficCollectorsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, azureTrafficCollectorName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -175,7 +168,7 @@ func (client *AzureTrafficCollectorsClient) deleteCreateRequest(ctx context.Cont return nil, errors.New("parameter azureTrafficCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{azureTrafficCollectorName}", url.PathEscape(azureTrafficCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -188,17 +181,18 @@ func (client *AzureTrafficCollectorsClient) deleteCreateRequest(ctx context.Cont // Get - Gets the specified Azure Traffic Collector in a specified resource group // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. -// azureTrafficCollectorName - Azure Traffic Collector name -// options - AzureTrafficCollectorsClientGetOptions contains the optional parameters for the AzureTrafficCollectorsClient.Get -// method. +// - resourceGroupName - The name of the resource group. +// - azureTrafficCollectorName - Azure Traffic Collector name +// - options - AzureTrafficCollectorsClientGetOptions contains the optional parameters for the AzureTrafficCollectorsClient.Get +// method. func (client *AzureTrafficCollectorsClient) Get(ctx context.Context, resourceGroupName string, azureTrafficCollectorName string, options *AzureTrafficCollectorsClientGetOptions) (AzureTrafficCollectorsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, azureTrafficCollectorName, options) if err != nil { return AzureTrafficCollectorsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AzureTrafficCollectorsClientGetResponse{}, err } @@ -223,7 +217,7 @@ func (client *AzureTrafficCollectorsClient) getCreateRequest(ctx context.Context return nil, errors.New("parameter azureTrafficCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{azureTrafficCollectorName}", url.PathEscape(azureTrafficCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -245,18 +239,19 @@ func (client *AzureTrafficCollectorsClient) getHandleResponse(resp *http.Respons // UpdateTags - Updates the specified Azure Traffic Collector tags. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. -// azureTrafficCollectorName - Azure Traffic Collector name -// parameters - Parameters supplied to update Azure Traffic Collector tags. -// options - AzureTrafficCollectorsClientUpdateTagsOptions contains the optional parameters for the AzureTrafficCollectorsClient.UpdateTags -// method. +// - resourceGroupName - The name of the resource group. +// - azureTrafficCollectorName - Azure Traffic Collector name +// - parameters - Parameters supplied to update Azure Traffic Collector tags. +// - options - AzureTrafficCollectorsClientUpdateTagsOptions contains the optional parameters for the AzureTrafficCollectorsClient.UpdateTags +// method. func (client *AzureTrafficCollectorsClient) UpdateTags(ctx context.Context, resourceGroupName string, azureTrafficCollectorName string, parameters TagsObject, options *AzureTrafficCollectorsClientUpdateTagsOptions) (AzureTrafficCollectorsClientUpdateTagsResponse, error) { req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, azureTrafficCollectorName, parameters, options) if err != nil { return AzureTrafficCollectorsClientUpdateTagsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AzureTrafficCollectorsClientUpdateTagsResponse{}, err } @@ -281,7 +276,7 @@ func (client *AzureTrafficCollectorsClient) updateTagsCreateRequest(ctx context. return nil, errors.New("parameter azureTrafficCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{azureTrafficCollectorName}", url.PathEscape(azureTrafficCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectors_client_example_test.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectors_client_example_test.go index 000cb266c08c..74b3cdfafc4b 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectors_client_example_test.go +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectors_client_example_test.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 armnetworkfunction_test @@ -17,37 +18,53 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkfunction/armnetworkfunction/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/527f6d35fb0d85c48210ca0f6f6f42814d63bd33/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorGet.json func ExampleAzureTrafficCollectorsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnetworkfunction.NewAzureTrafficCollectorsClient("subid", cred, nil) + clientFactory, err := armnetworkfunction.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rg1", "atc", nil) + res, err := clientFactory.NewAzureTrafficCollectorsClient().Get(ctx, "rg1", "atc", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AzureTrafficCollector = armnetworkfunction.AzureTrafficCollector{ + // Name: to.Ptr("atc"), + // Type: to.Ptr("Microsoft.NetworkFunction/azureTrafficCollectors"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("w/\\00000000-0000-0000-0000-000000000000\\"), + // Properties: &armnetworkfunction.AzureTrafficCollectorPropertiesFormat{ + // CollectorPolicies: []*armnetworkfunction.ResourceReference{ + // }, + // ProvisioningState: to.Ptr(armnetworkfunction.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/527f6d35fb0d85c48210ca0f6f6f42814d63bd33/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorCreate.json func ExampleAzureTrafficCollectorsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnetworkfunction.NewAzureTrafficCollectorsClient("subid", cred, nil) + clientFactory, err := armnetworkfunction.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "atc", armnetworkfunction.AzureTrafficCollector{ + poller, err := clientFactory.NewAzureTrafficCollectorsClient().BeginCreateOrUpdate(ctx, "rg1", "atc", armnetworkfunction.AzureTrafficCollector{ Location: to.Ptr("West US"), Tags: map[string]*string{ "key1": to.Ptr("value1"), @@ -61,22 +78,38 @@ func ExampleAzureTrafficCollectorsClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AzureTrafficCollector = armnetworkfunction.AzureTrafficCollector{ + // Name: to.Ptr("atc"), + // Type: to.Ptr("Microsoft.NetworkFunction/azureTrafficCollectors"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("w/\\00000000-0000-0000-0000-000000000000\\"), + // Properties: &armnetworkfunction.AzureTrafficCollectorPropertiesFormat{ + // CollectorPolicies: []*armnetworkfunction.ResourceReference{ + // }, + // ProvisioningState: to.Ptr(armnetworkfunction.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/527f6d35fb0d85c48210ca0f6f6f42814d63bd33/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorDelete.json func ExampleAzureTrafficCollectorsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnetworkfunction.NewAzureTrafficCollectorsClient("subid", cred, nil) + clientFactory, err := armnetworkfunction.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rg1", "atc", nil) + poller, err := clientFactory.NewAzureTrafficCollectorsClient().BeginDelete(ctx, "rg1", "atc", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -86,18 +119,18 @@ func ExampleAzureTrafficCollectorsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorUpdateTags.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/527f6d35fb0d85c48210ca0f6f6f42814d63bd33/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorUpdateTags.json func ExampleAzureTrafficCollectorsClient_UpdateTags() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnetworkfunction.NewAzureTrafficCollectorsClient("subid", cred, nil) + clientFactory, err := armnetworkfunction.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.UpdateTags(ctx, "rg1", "atc", armnetworkfunction.TagsObject{ + res, err := clientFactory.NewAzureTrafficCollectorsClient().UpdateTags(ctx, "rg1", "atc", armnetworkfunction.TagsObject{ Tags: map[string]*string{ "key1": to.Ptr("value1"), "key2": to.Ptr("value2"), @@ -106,6 +139,23 @@ func ExampleAzureTrafficCollectorsClient_UpdateTags() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AzureTrafficCollector = armnetworkfunction.AzureTrafficCollector{ + // Name: to.Ptr("atc"), + // Type: to.Ptr("Microsoft.NetworkFunction/azureTrafficCollectors"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Etag: to.Ptr("w/\\00000000-0000-0000-0000-000000000000\\"), + // Properties: &armnetworkfunction.AzureTrafficCollectorPropertiesFormat{ + // CollectorPolicies: []*armnetworkfunction.ResourceReference{ + // }, + // ProvisioningState: to.Ptr(armnetworkfunction.ProvisioningStateSucceeded), + // }, + // } } diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbyresourcegroup_client.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbyresourcegroup_client.go index 90c6826fb7b3..a7b927408835 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbyresourcegroup_client.go +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbyresourcegroup_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,40 +24,32 @@ import ( // AzureTrafficCollectorsByResourceGroupClient contains the methods for the AzureTrafficCollectorsByResourceGroup group. // Don't use this type directly, use NewAzureTrafficCollectorsByResourceGroupClient() instead. type AzureTrafficCollectorsByResourceGroupClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAzureTrafficCollectorsByResourceGroupClient creates a new instance of AzureTrafficCollectorsByResourceGroupClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAzureTrafficCollectorsByResourceGroupClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AzureTrafficCollectorsByResourceGroupClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AzureTrafficCollectorsByResourceGroupClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AzureTrafficCollectorsByResourceGroupClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Return list of Azure Traffic Collectors in a Resource Group +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. -// options - AzureTrafficCollectorsByResourceGroupClientListOptions contains the optional parameters for the AzureTrafficCollectorsByResourceGroupClient.List -// method. +// - resourceGroupName - The name of the resource group. +// - options - AzureTrafficCollectorsByResourceGroupClientListOptions contains the optional parameters for the AzureTrafficCollectorsByResourceGroupClient.NewListPager +// method. func (client *AzureTrafficCollectorsByResourceGroupClient) NewListPager(resourceGroupName string, options *AzureTrafficCollectorsByResourceGroupClientListOptions) *runtime.Pager[AzureTrafficCollectorsByResourceGroupClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AzureTrafficCollectorsByResourceGroupClientListResponse]{ More: func(page AzureTrafficCollectorsByResourceGroupClientListResponse) bool { @@ -76,7 +66,7 @@ func (client *AzureTrafficCollectorsByResourceGroupClient) NewListPager(resource if err != nil { return AzureTrafficCollectorsByResourceGroupClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AzureTrafficCollectorsByResourceGroupClientListResponse{}, err } @@ -99,7 +89,7 @@ func (client *AzureTrafficCollectorsByResourceGroupClient) listCreateRequest(ctx return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbyresourcegroup_client_example_test.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbyresourcegroup_client_example_test.go index f07647d1b92b..02e187c04cc9 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbyresourcegroup_client_example_test.go +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbyresourcegroup_client_example_test.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 armnetworkfunction_test @@ -16,26 +17,45 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkfunction/armnetworkfunction/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorsByResourceGroupList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/527f6d35fb0d85c48210ca0f6f6f42814d63bd33/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorsByResourceGroupList.json func ExampleAzureTrafficCollectorsByResourceGroupClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnetworkfunction.NewAzureTrafficCollectorsByResourceGroupClient("subid", cred, nil) + clientFactory, err := armnetworkfunction.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("rg1", nil) + pager := clientFactory.NewAzureTrafficCollectorsByResourceGroupClient().NewListPager("rg1", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AzureTrafficCollectorListResult = armnetworkfunction.AzureTrafficCollectorListResult{ + // Value: []*armnetworkfunction.AzureTrafficCollector{ + // { + // Name: to.Ptr("atc"), + // Type: to.Ptr("Microsoft.NetworkFunction/azureTrafficCollectors"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("w/\\00000000-0000-0000-0000-000000000000\\"), + // Properties: &armnetworkfunction.AzureTrafficCollectorPropertiesFormat{ + // CollectorPolicies: []*armnetworkfunction.ResourceReference{ + // }, + // ProvisioningState: to.Ptr(armnetworkfunction.ProvisioningStateSucceeded), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbysubscription_client.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbysubscription_client.go index 5091f00b6a3d..a30b5a51bcc2 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbysubscription_client.go +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbysubscription_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,39 +24,31 @@ import ( // AzureTrafficCollectorsBySubscriptionClient contains the methods for the AzureTrafficCollectorsBySubscription group. // Don't use this type directly, use NewAzureTrafficCollectorsBySubscriptionClient() instead. type AzureTrafficCollectorsBySubscriptionClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAzureTrafficCollectorsBySubscriptionClient creates a new instance of AzureTrafficCollectorsBySubscriptionClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAzureTrafficCollectorsBySubscriptionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AzureTrafficCollectorsBySubscriptionClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AzureTrafficCollectorsBySubscriptionClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AzureTrafficCollectorsBySubscriptionClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Return list of Azure Traffic Collectors in a subscription +// // Generated from API version 2022-11-01 -// options - AzureTrafficCollectorsBySubscriptionClientListOptions contains the optional parameters for the AzureTrafficCollectorsBySubscriptionClient.List -// method. +// - options - AzureTrafficCollectorsBySubscriptionClientListOptions contains the optional parameters for the AzureTrafficCollectorsBySubscriptionClient.NewListPager +// method. func (client *AzureTrafficCollectorsBySubscriptionClient) NewListPager(options *AzureTrafficCollectorsBySubscriptionClientListOptions) *runtime.Pager[AzureTrafficCollectorsBySubscriptionClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AzureTrafficCollectorsBySubscriptionClientListResponse]{ More: func(page AzureTrafficCollectorsBySubscriptionClientListResponse) bool { @@ -75,7 +65,7 @@ func (client *AzureTrafficCollectorsBySubscriptionClient) NewListPager(options * if err != nil { return AzureTrafficCollectorsBySubscriptionClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AzureTrafficCollectorsBySubscriptionClientListResponse{}, err } @@ -94,7 +84,7 @@ func (client *AzureTrafficCollectorsBySubscriptionClient) listCreateRequest(ctx return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbysubscription_client_example_test.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbysubscription_client_example_test.go index d0e0f04facb3..aaffb66c6271 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbysubscription_client_example_test.go +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/azuretrafficcollectorsbysubscription_client_example_test.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 armnetworkfunction_test @@ -16,26 +17,45 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkfunction/armnetworkfunction/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorsBySubscriptionList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/527f6d35fb0d85c48210ca0f6f6f42814d63bd33/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorsBySubscriptionList.json func ExampleAzureTrafficCollectorsBySubscriptionClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnetworkfunction.NewAzureTrafficCollectorsBySubscriptionClient("subid", cred, nil) + clientFactory, err := armnetworkfunction.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewAzureTrafficCollectorsBySubscriptionClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AzureTrafficCollectorListResult = armnetworkfunction.AzureTrafficCollectorListResult{ + // Value: []*armnetworkfunction.AzureTrafficCollector{ + // { + // Name: to.Ptr("atc"), + // Type: to.Ptr("Microsoft.NetworkFunction/azureTrafficCollectors"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("w/\\00000000-0000-0000-0000-000000000000\\"), + // Properties: &armnetworkfunction.AzureTrafficCollectorPropertiesFormat{ + // CollectorPolicies: []*armnetworkfunction.ResourceReference{ + // }, + // ProvisioningState: to.Ptr(armnetworkfunction.ProvisioningStateSucceeded), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/client.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/client.go index 2ad4764fe306..7813a0478ebd 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/client.go +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,35 +21,27 @@ import ( // Client contains the methods for the NetworkFunction group. // Don't use this type directly, use NewClient() instead. type Client struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewClient creates a new instance of Client with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".Client", moduleVersion, credential, options) if err != nil { return nil, err } client := &Client{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListOperationsPager - Lists all of the available NetworkFunction Rest API operations. +// // Generated from API version 2022-11-01 -// options - ClientListOperationsOptions contains the optional parameters for the Client.ListOperations method. +// - options - ClientListOperationsOptions contains the optional parameters for the Client.NewListOperationsPager method. func (client *Client) NewListOperationsPager(options *ClientListOperationsOptions) *runtime.Pager[ClientListOperationsResponse] { return runtime.NewPager(runtime.PagingHandler[ClientListOperationsResponse]{ More: func(page ClientListOperationsResponse) bool { @@ -62,7 +52,7 @@ func (client *Client) NewListOperationsPager(options *ClientListOperationsOption if err != nil { return ClientListOperationsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientListOperationsResponse{}, err } @@ -77,7 +67,7 @@ func (client *Client) NewListOperationsPager(options *ClientListOperationsOption // listOperationsCreateRequest creates the ListOperations request. func (client *Client) listOperationsCreateRequest(ctx context.Context, options *ClientListOperationsOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.NetworkFunction/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/client_example_test.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/client_example_test.go index 1b519880f729..fffb7cfff84f 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/client_example_test.go +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/client_example_test.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 armnetworkfunction_test @@ -16,26 +17,39 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkfunction/armnetworkfunction/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/OperationsList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/527f6d35fb0d85c48210ca0f6f6f42814d63bd33/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/OperationsList.json func ExampleClient_NewListOperationsPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnetworkfunction.NewClient(cred, nil) + clientFactory, err := armnetworkfunction.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListOperationsPager(nil) + pager := clientFactory.NewClient().NewListOperationsPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationListResult = armnetworkfunction.OperationListResult{ + // Value: []*armnetworkfunction.Operation{ + // { + // Name: to.Ptr("Microsoft.NetworkFunction/azureTrafficCollectors/write"), + // Display: &armnetworkfunction.OperationDisplay{ + // Description: to.Ptr("Creates or Update a azure traffic collector"), + // Operation: to.Ptr("Create/Update a azure traffic collector"), + // Provider: to.Ptr("Microsoft NetworkFunction"), + // Resource: to.Ptr("AzureTrafficCollector"), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/client_factory.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/client_factory.go new file mode 100644 index 000000000000..c47c0318b9f6 --- /dev/null +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/client_factory.go @@ -0,0 +1,64 @@ +//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 armnetworkfunction + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewClient() *Client { + subClient, _ := NewClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAzureTrafficCollectorsBySubscriptionClient() *AzureTrafficCollectorsBySubscriptionClient { + subClient, _ := NewAzureTrafficCollectorsBySubscriptionClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAzureTrafficCollectorsByResourceGroupClient() *AzureTrafficCollectorsByResourceGroupClient { + subClient, _ := NewAzureTrafficCollectorsByResourceGroupClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAzureTrafficCollectorsClient() *AzureTrafficCollectorsClient { + subClient, _ := NewAzureTrafficCollectorsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCollectorPoliciesClient() *CollectorPoliciesClient { + subClient, _ := NewCollectorPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/collectorpolicies_client.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/collectorpolicies_client.go index e2e7b61c6525..53b1ac28c0f5 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/collectorpolicies_client.go +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/collectorpolicies_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,67 +24,60 @@ import ( // CollectorPoliciesClient contains the methods for the CollectorPolicies group. // Don't use this type directly, use NewCollectorPoliciesClient() instead. type CollectorPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCollectorPoliciesClient creates a new instance of CollectorPoliciesClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCollectorPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CollectorPoliciesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CollectorPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CollectorPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a Collector Policy resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. -// azureTrafficCollectorName - Azure Traffic Collector name -// collectorPolicyName - Collector Policy Name -// parameters - The parameters to provide for the created Collector Policy. -// options - CollectorPoliciesClientBeginCreateOrUpdateOptions contains the optional parameters for the CollectorPoliciesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - azureTrafficCollectorName - Azure Traffic Collector name +// - collectorPolicyName - Collector Policy Name +// - parameters - The parameters to provide for the created Collector Policy. +// - options - CollectorPoliciesClientBeginCreateOrUpdateOptions contains the optional parameters for the CollectorPoliciesClient.BeginCreateOrUpdate +// method. func (client *CollectorPoliciesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, azureTrafficCollectorName string, collectorPolicyName string, parameters CollectorPolicy, options *CollectorPoliciesClientBeginCreateOrUpdateOptions) (*runtime.Poller[CollectorPoliciesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, azureTrafficCollectorName, collectorPolicyName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CollectorPoliciesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CollectorPoliciesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CollectorPoliciesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CollectorPoliciesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a Collector Policy resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *CollectorPoliciesClient) createOrUpdate(ctx context.Context, resourceGroupName string, azureTrafficCollectorName string, collectorPolicyName string, parameters CollectorPolicy, options *CollectorPoliciesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, azureTrafficCollectorName, collectorPolicyName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -115,7 +106,7 @@ func (client *CollectorPoliciesClient) createOrUpdateCreateRequest(ctx context.C return nil, errors.New("parameter collectorPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{collectorPolicyName}", url.PathEscape(collectorPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -128,35 +119,37 @@ func (client *CollectorPoliciesClient) createOrUpdateCreateRequest(ctx context.C // BeginDelete - Deletes a specified Collector Policy resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. -// azureTrafficCollectorName - Azure Traffic Collector name -// collectorPolicyName - Collector Policy Name -// options - CollectorPoliciesClientBeginDeleteOptions contains the optional parameters for the CollectorPoliciesClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. +// - azureTrafficCollectorName - Azure Traffic Collector name +// - collectorPolicyName - Collector Policy Name +// - options - CollectorPoliciesClientBeginDeleteOptions contains the optional parameters for the CollectorPoliciesClient.BeginDelete +// method. func (client *CollectorPoliciesClient) BeginDelete(ctx context.Context, resourceGroupName string, azureTrafficCollectorName string, collectorPolicyName string, options *CollectorPoliciesClientBeginDeleteOptions) (*runtime.Poller[CollectorPoliciesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, azureTrafficCollectorName, collectorPolicyName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CollectorPoliciesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CollectorPoliciesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[CollectorPoliciesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CollectorPoliciesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a specified Collector Policy resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 func (client *CollectorPoliciesClient) deleteOperation(ctx context.Context, resourceGroupName string, azureTrafficCollectorName string, collectorPolicyName string, options *CollectorPoliciesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, azureTrafficCollectorName, collectorPolicyName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -185,7 +178,7 @@ func (client *CollectorPoliciesClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter collectorPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{collectorPolicyName}", url.PathEscape(collectorPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,17 +191,18 @@ func (client *CollectorPoliciesClient) deleteCreateRequest(ctx context.Context, // Get - Gets the collector policy in a specified Traffic Collector // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. -// azureTrafficCollectorName - Azure Traffic Collector name -// collectorPolicyName - Collector Policy Name -// options - CollectorPoliciesClientGetOptions contains the optional parameters for the CollectorPoliciesClient.Get method. +// - resourceGroupName - The name of the resource group. +// - azureTrafficCollectorName - Azure Traffic Collector name +// - collectorPolicyName - Collector Policy Name +// - options - CollectorPoliciesClientGetOptions contains the optional parameters for the CollectorPoliciesClient.Get method. func (client *CollectorPoliciesClient) Get(ctx context.Context, resourceGroupName string, azureTrafficCollectorName string, collectorPolicyName string, options *CollectorPoliciesClientGetOptions) (CollectorPoliciesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, azureTrafficCollectorName, collectorPolicyName, options) if err != nil { return CollectorPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CollectorPoliciesClientGetResponse{}, err } @@ -237,7 +231,7 @@ func (client *CollectorPoliciesClient) getCreateRequest(ctx context.Context, res return nil, errors.New("parameter collectorPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{collectorPolicyName}", url.PathEscape(collectorPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -258,10 +252,12 @@ func (client *CollectorPoliciesClient) getHandleResponse(resp *http.Response) (C } // NewListPager - Return list of Collector policies in a Azure Traffic Collector +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. -// azureTrafficCollectorName - Azure Traffic Collector name -// options - CollectorPoliciesClientListOptions contains the optional parameters for the CollectorPoliciesClient.List method. +// - resourceGroupName - The name of the resource group. +// - azureTrafficCollectorName - Azure Traffic Collector name +// - options - CollectorPoliciesClientListOptions contains the optional parameters for the CollectorPoliciesClient.NewListPager +// method. func (client *CollectorPoliciesClient) NewListPager(resourceGroupName string, azureTrafficCollectorName string, options *CollectorPoliciesClientListOptions) *runtime.Pager[CollectorPoliciesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[CollectorPoliciesClientListResponse]{ More: func(page CollectorPoliciesClientListResponse) bool { @@ -278,7 +274,7 @@ func (client *CollectorPoliciesClient) NewListPager(resourceGroupName string, az if err != nil { return CollectorPoliciesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CollectorPoliciesClientListResponse{}, err } @@ -305,7 +301,7 @@ func (client *CollectorPoliciesClient) listCreateRequest(ctx context.Context, re return nil, errors.New("parameter azureTrafficCollectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{azureTrafficCollectorName}", url.PathEscape(azureTrafficCollectorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -327,19 +323,20 @@ func (client *CollectorPoliciesClient) listHandleResponse(resp *http.Response) ( // UpdateTags - Updates the specified Collector Policy tags. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-11-01 -// resourceGroupName - The name of the resource group. -// azureTrafficCollectorName - Azure Traffic Collector name -// collectorPolicyName - Collector Policy Name -// parameters - Parameters supplied to update Collector Policy tags. -// options - CollectorPoliciesClientUpdateTagsOptions contains the optional parameters for the CollectorPoliciesClient.UpdateTags -// method. +// - resourceGroupName - The name of the resource group. +// - azureTrafficCollectorName - Azure Traffic Collector name +// - collectorPolicyName - Collector Policy Name +// - parameters - Parameters supplied to update Collector Policy tags. +// - options - CollectorPoliciesClientUpdateTagsOptions contains the optional parameters for the CollectorPoliciesClient.UpdateTags +// method. func (client *CollectorPoliciesClient) UpdateTags(ctx context.Context, resourceGroupName string, azureTrafficCollectorName string, collectorPolicyName string, parameters TagsObject, options *CollectorPoliciesClientUpdateTagsOptions) (CollectorPoliciesClientUpdateTagsResponse, error) { req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, azureTrafficCollectorName, collectorPolicyName, parameters, options) if err != nil { return CollectorPoliciesClientUpdateTagsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CollectorPoliciesClientUpdateTagsResponse{}, err } @@ -368,7 +365,7 @@ func (client *CollectorPoliciesClient) updateTagsCreateRequest(ctx context.Conte return nil, errors.New("parameter collectorPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{collectorPolicyName}", url.PathEscape(collectorPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/collectorpolicies_client_example_test.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/collectorpolicies_client_example_test.go index 99021275e7fb..38c4a491176f 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/collectorpolicies_client_example_test.go +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/collectorpolicies_client_example_test.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 armnetworkfunction_test @@ -17,61 +18,118 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkfunction/armnetworkfunction/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPoliciesList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/527f6d35fb0d85c48210ca0f6f6f42814d63bd33/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPoliciesList.json func ExampleCollectorPoliciesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnetworkfunction.NewCollectorPoliciesClient("subid", cred, nil) + clientFactory, err := armnetworkfunction.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("rg1", "atc", nil) + pager := clientFactory.NewCollectorPoliciesClient().NewListPager("rg1", "atc", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.CollectorPolicyListResult = armnetworkfunction.CollectorPolicyListResult{ + // Value: []*armnetworkfunction.CollectorPolicy{ + // { + // Name: to.Ptr("atc"), + // Type: to.Ptr("Microsoft.NetworkFunction/azureTrafficCollectors/collectorPolicies"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc/collectorPolicies/cp1"), + // Location: to.Ptr("westus"), + // Etag: to.Ptr("w/\\72090554-7e3b-43f2-80ad-99a9020dcb11\\"), + // Properties: &armnetworkfunction.CollectorPolicyPropertiesFormat{ + // EmissionPolicies: []*armnetworkfunction.EmissionPoliciesPropertiesFormat{ + // { + // EmissionDestinations: []*armnetworkfunction.EmissionPolicyDestination{ + // { + // DestinationType: to.Ptr(armnetworkfunction.DestinationTypeAzureMonitor), + // }}, + // EmissionType: to.Ptr(armnetworkfunction.EmissionTypeIPFIX), + // }}, + // IngestionPolicy: &armnetworkfunction.IngestionPolicyPropertiesFormat{ + // IngestionSources: []*armnetworkfunction.IngestionSourcesPropertiesFormat{ + // { + // ResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRouteCircuits/circuitName"), + // SourceType: to.Ptr(armnetworkfunction.SourceTypeResource), + // }}, + // IngestionType: to.Ptr(armnetworkfunction.IngestionTypeIPFIX), + // }, + // ProvisioningState: to.Ptr(armnetworkfunction.ProvisioningStateSucceeded), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPolicyGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/527f6d35fb0d85c48210ca0f6f6f42814d63bd33/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPolicyGet.json func ExampleCollectorPoliciesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnetworkfunction.NewCollectorPoliciesClient("subid", cred, nil) + clientFactory, err := armnetworkfunction.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rg1", "atc", "cp1", nil) + res, err := clientFactory.NewCollectorPoliciesClient().Get(ctx, "rg1", "atc", "cp1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CollectorPolicy = armnetworkfunction.CollectorPolicy{ + // Name: to.Ptr("atc"), + // Type: to.Ptr("Microsoft.NetworkFunction/azureTrafficCollectors/collectorPolicies"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc/collectorPolicies/cp1"), + // Location: to.Ptr("westus"), + // Etag: to.Ptr("w/\\72090554-7e3b-43f2-80ad-99a9020dcb11\\"), + // Properties: &armnetworkfunction.CollectorPolicyPropertiesFormat{ + // EmissionPolicies: []*armnetworkfunction.EmissionPoliciesPropertiesFormat{ + // { + // EmissionDestinations: []*armnetworkfunction.EmissionPolicyDestination{ + // { + // DestinationType: to.Ptr(armnetworkfunction.DestinationTypeAzureMonitor), + // }}, + // EmissionType: to.Ptr(armnetworkfunction.EmissionTypeIPFIX), + // }}, + // IngestionPolicy: &armnetworkfunction.IngestionPolicyPropertiesFormat{ + // IngestionSources: []*armnetworkfunction.IngestionSourcesPropertiesFormat{ + // { + // ResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRouteCircuits/circuitName"), + // SourceType: to.Ptr(armnetworkfunction.SourceTypeResource), + // }}, + // IngestionType: to.Ptr(armnetworkfunction.IngestionTypeIPFIX), + // }, + // ProvisioningState: to.Ptr(armnetworkfunction.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPolicyCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/527f6d35fb0d85c48210ca0f6f6f42814d63bd33/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPolicyCreate.json func ExampleCollectorPoliciesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnetworkfunction.NewCollectorPoliciesClient("subid", cred, nil) + clientFactory, err := armnetworkfunction.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "atc", "cp1", armnetworkfunction.CollectorPolicy{ + poller, err := clientFactory.NewCollectorPoliciesClient().BeginCreateOrUpdate(ctx, "rg1", "atc", "cp1", armnetworkfunction.CollectorPolicy{ Location: to.Ptr("West US"), Properties: &armnetworkfunction.CollectorPolicyPropertiesFormat{ EmissionPolicies: []*armnetworkfunction.EmissionPoliciesPropertiesFormat{ @@ -99,22 +157,49 @@ func ExampleCollectorPoliciesClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CollectorPolicy = armnetworkfunction.CollectorPolicy{ + // Name: to.Ptr("cp1"), + // Type: to.Ptr("Microsoft.NetworkFunction/azureTrafficCollectors/collectorPolicies"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/AzureTrafficCollector/atc/collectorPolicies/cp1"), + // Location: to.Ptr("westus"), + // Etag: to.Ptr("w/\\72090554-7e3b-43f2-80ad-99a9020dcb11\\"), + // Properties: &armnetworkfunction.CollectorPolicyPropertiesFormat{ + // EmissionPolicies: []*armnetworkfunction.EmissionPoliciesPropertiesFormat{ + // { + // EmissionDestinations: []*armnetworkfunction.EmissionPolicyDestination{ + // { + // DestinationType: to.Ptr(armnetworkfunction.DestinationTypeAzureMonitor), + // }}, + // EmissionType: to.Ptr(armnetworkfunction.EmissionTypeIPFIX), + // }}, + // IngestionPolicy: &armnetworkfunction.IngestionPolicyPropertiesFormat{ + // IngestionSources: []*armnetworkfunction.IngestionSourcesPropertiesFormat{ + // { + // ResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRouteCircuits/circuitName"), + // SourceType: to.Ptr(armnetworkfunction.SourceTypeResource), + // }}, + // IngestionType: to.Ptr(armnetworkfunction.IngestionTypeIPFIX), + // }, + // ProvisioningState: to.Ptr(armnetworkfunction.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPolicyDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/527f6d35fb0d85c48210ca0f6f6f42814d63bd33/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPolicyDelete.json func ExampleCollectorPoliciesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnetworkfunction.NewCollectorPoliciesClient("subid", cred, nil) + clientFactory, err := armnetworkfunction.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rg1", "atc", "cp1", nil) + poller, err := clientFactory.NewCollectorPoliciesClient().BeginDelete(ctx, "rg1", "atc", "cp1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -124,18 +209,18 @@ func ExampleCollectorPoliciesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPolicyUpdateTags.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/527f6d35fb0d85c48210ca0f6f6f42814d63bd33/specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPolicyUpdateTags.json func ExampleCollectorPoliciesClient_UpdateTags() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnetworkfunction.NewCollectorPoliciesClient("subid", cred, nil) + clientFactory, err := armnetworkfunction.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.UpdateTags(ctx, "rg1", "atc", "cp1", armnetworkfunction.TagsObject{ + res, err := clientFactory.NewCollectorPoliciesClient().UpdateTags(ctx, "rg1", "atc", "cp1", armnetworkfunction.TagsObject{ Tags: map[string]*string{ "key1": to.Ptr("value1"), "key2": to.Ptr("value2"), @@ -144,6 +229,37 @@ func ExampleCollectorPoliciesClient_UpdateTags() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CollectorPolicy = armnetworkfunction.CollectorPolicy{ + // Name: to.Ptr("atc"), + // Type: to.Ptr("Microsoft.NetworkFunction/azureTrafficCollectors/collectorPolicies"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc/collectorPolicies/cp1"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Etag: to.Ptr("w/\\72090554-7e3b-43f2-80ad-99a9020dcb11\\"), + // Properties: &armnetworkfunction.CollectorPolicyPropertiesFormat{ + // EmissionPolicies: []*armnetworkfunction.EmissionPoliciesPropertiesFormat{ + // { + // EmissionDestinations: []*armnetworkfunction.EmissionPolicyDestination{ + // { + // DestinationType: to.Ptr(armnetworkfunction.DestinationTypeAzureMonitor), + // }}, + // EmissionType: to.Ptr(armnetworkfunction.EmissionTypeIPFIX), + // }}, + // IngestionPolicy: &armnetworkfunction.IngestionPolicyPropertiesFormat{ + // IngestionSources: []*armnetworkfunction.IngestionSourcesPropertiesFormat{ + // { + // ResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRouteCircuits/circuitName"), + // SourceType: to.Ptr(armnetworkfunction.SourceTypeResource), + // }}, + // IngestionType: to.Ptr(armnetworkfunction.IngestionTypeIPFIX), + // }, + // ProvisioningState: to.Ptr(armnetworkfunction.ProvisioningStateSucceeded), + // }, + // } } diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/constants.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/constants.go index a6cf9deab261..33d4121da307 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/constants.go +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/constants.go @@ -11,7 +11,7 @@ package armnetworkfunction const ( moduleName = "armnetworkfunction" - moduleVersion = "v2.0.0" + moduleVersion = "v2.1.0" ) type APIVersionParameter string diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/go.mod b/sdk/resourcemanager/networkfunction/armnetworkfunction/go.mod index 066b5bb4f265..ff586a28d663 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/go.mod +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkfunction/arm 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.2.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 // indirect - github.com/golang-jwt/jwt/v4 v4.4.2 // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/go.sum b/sdk/resourcemanager/networkfunction/armnetworkfunction/go.sum index 8c0539b73123..8ba445a8c4da 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/go.sum +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/go.sum @@ -1,30 +1,31 @@ -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.2.0 h1:t/W5MYAuQy81cvM8VUNfRLzhtKpXhVUAN7Cd7KVbTyc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0/go.mod h1:NBanQUfSWiWn3QEpWDTCU0IjBECKOYvl2R8xdRtMtiM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.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.7.0 h1:VgSJlZH5u0k2qxSpqyghcFQKmvYckj46uymKK5XzkBM= -github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0/go.mod h1:BDJ5qMFKx9DugEg3+uQSDCdbYPr5s9vBTrL9P8TpqOU= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= 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/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= -github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -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/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/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/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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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-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= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/models.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/models.go index cdfca38ae0aa..c11d33011ba9 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/models.go +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/models.go @@ -59,13 +59,13 @@ type AzureTrafficCollectorPropertiesFormat struct { ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` } -// AzureTrafficCollectorsByResourceGroupClientListOptions contains the optional parameters for the AzureTrafficCollectorsByResourceGroupClient.List +// AzureTrafficCollectorsByResourceGroupClientListOptions contains the optional parameters for the AzureTrafficCollectorsByResourceGroupClient.NewListPager // method. type AzureTrafficCollectorsByResourceGroupClientListOptions struct { // placeholder for future optional parameters } -// AzureTrafficCollectorsBySubscriptionClientListOptions contains the optional parameters for the AzureTrafficCollectorsBySubscriptionClient.List +// AzureTrafficCollectorsBySubscriptionClientListOptions contains the optional parameters for the AzureTrafficCollectorsBySubscriptionClient.NewListPager // method. type AzureTrafficCollectorsBySubscriptionClientListOptions struct { // placeholder for future optional parameters @@ -96,7 +96,7 @@ type AzureTrafficCollectorsClientUpdateTagsOptions struct { // placeholder for future optional parameters } -// ClientListOperationsOptions contains the optional parameters for the Client.ListOperations method. +// ClientListOperationsOptions contains the optional parameters for the Client.NewListOperationsPager method. type ClientListOperationsOptions struct { // placeholder for future optional parameters } @@ -120,7 +120,7 @@ type CollectorPoliciesClientGetOptions struct { // placeholder for future optional parameters } -// CollectorPoliciesClientListOptions contains the optional parameters for the CollectorPoliciesClient.List method. +// CollectorPoliciesClientListOptions contains the optional parameters for the CollectorPoliciesClient.NewListPager method. type CollectorPoliciesClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/models_serde.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/models_serde.go index 15471c2b6df1..8468d2428ff8 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/models_serde.go +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type AzureTrafficCollector. func (a AzureTrafficCollector) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", a.Etag) populate(objectMap, "id", a.ID) populate(objectMap, "location", a.Location) @@ -73,7 +73,7 @@ func (a *AzureTrafficCollector) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AzureTrafficCollectorListResult. func (a AzureTrafficCollectorListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -104,7 +104,7 @@ func (a *AzureTrafficCollectorListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AzureTrafficCollectorPropertiesFormat. func (a AzureTrafficCollectorPropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "collectorPolicies", a.CollectorPolicies) populate(objectMap, "provisioningState", a.ProvisioningState) populate(objectMap, "virtualHub", a.VirtualHub) @@ -139,7 +139,7 @@ func (a *AzureTrafficCollectorPropertiesFormat) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type CollectorPolicy. func (c CollectorPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", c.Etag) populate(objectMap, "id", c.ID) populate(objectMap, "location", c.Location) @@ -194,7 +194,7 @@ func (c *CollectorPolicy) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CollectorPolicyListResult. func (c CollectorPolicyListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -225,7 +225,7 @@ func (c *CollectorPolicyListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CollectorPolicyPropertiesFormat. func (c CollectorPolicyPropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "emissionPolicies", c.EmissionPolicies) populate(objectMap, "ingestionPolicy", c.IngestionPolicy) populate(objectMap, "provisioningState", c.ProvisioningState) @@ -260,7 +260,7 @@ func (c *CollectorPolicyPropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EmissionPoliciesPropertiesFormat. func (e EmissionPoliciesPropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "emissionDestinations", e.EmissionDestinations) populate(objectMap, "emissionType", e.EmissionType) return json.Marshal(objectMap) @@ -291,7 +291,7 @@ func (e *EmissionPoliciesPropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EmissionPolicyDestination. func (e EmissionPolicyDestination) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "destinationType", e.DestinationType) return json.Marshal(objectMap) } @@ -318,7 +318,7 @@ func (e *EmissionPolicyDestination) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IngestionPolicyPropertiesFormat. func (i IngestionPolicyPropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "ingestionSources", i.IngestionSources) populate(objectMap, "ingestionType", i.IngestionType) return json.Marshal(objectMap) @@ -349,7 +349,7 @@ func (i *IngestionPolicyPropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IngestionSourcesPropertiesFormat. func (i IngestionSourcesPropertiesFormat) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "resourceId", i.ResourceID) populate(objectMap, "sourceType", i.SourceType) return json.Marshal(objectMap) @@ -380,7 +380,7 @@ func (i *IngestionSourcesPropertiesFormat) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "display", o.Display) populate(objectMap, "isDataAction", o.IsDataAction) populate(objectMap, "name", o.Name) @@ -419,7 +419,7 @@ func (o *Operation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -458,7 +458,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationListResult. func (o OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -489,7 +489,7 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ProxyResource. func (p ProxyResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) populate(objectMap, "type", p.Type) @@ -524,7 +524,7 @@ func (p *ProxyResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceReference. func (r ResourceReference) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) return json.Marshal(objectMap) } @@ -551,7 +551,7 @@ func (r *ResourceReference) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -594,7 +594,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TagsObject. func (t TagsObject) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "tags", t.Tags) return json.Marshal(objectMap) } @@ -621,7 +621,7 @@ func (t *TagsObject) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrackedResource. func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "location", t.Location) populate(objectMap, "name", t.Name) @@ -668,7 +668,7 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrackedResourceSystemData. func (t TrackedResourceSystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", t.CreatedAt) populate(objectMap, "createdBy", t.CreatedBy) populate(objectMap, "createdByType", t.CreatedByType) @@ -709,7 +709,7 @@ func (t *TrackedResourceSystemData) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -719,7 +719,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/response_types.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/response_types.go index e2c433f74e8a..2789205c87e7 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/response_types.go +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/response_types.go @@ -9,22 +9,22 @@ package armnetworkfunction -// AzureTrafficCollectorsByResourceGroupClientListResponse contains the response from method AzureTrafficCollectorsByResourceGroupClient.List. +// AzureTrafficCollectorsByResourceGroupClientListResponse contains the response from method AzureTrafficCollectorsByResourceGroupClient.NewListPager. type AzureTrafficCollectorsByResourceGroupClientListResponse struct { AzureTrafficCollectorListResult } -// AzureTrafficCollectorsBySubscriptionClientListResponse contains the response from method AzureTrafficCollectorsBySubscriptionClient.List. +// AzureTrafficCollectorsBySubscriptionClientListResponse contains the response from method AzureTrafficCollectorsBySubscriptionClient.NewListPager. type AzureTrafficCollectorsBySubscriptionClientListResponse struct { AzureTrafficCollectorListResult } -// AzureTrafficCollectorsClientCreateOrUpdateResponse contains the response from method AzureTrafficCollectorsClient.CreateOrUpdate. +// AzureTrafficCollectorsClientCreateOrUpdateResponse contains the response from method AzureTrafficCollectorsClient.BeginCreateOrUpdate. type AzureTrafficCollectorsClientCreateOrUpdateResponse struct { AzureTrafficCollector } -// AzureTrafficCollectorsClientDeleteResponse contains the response from method AzureTrafficCollectorsClient.Delete. +// AzureTrafficCollectorsClientDeleteResponse contains the response from method AzureTrafficCollectorsClient.BeginDelete. type AzureTrafficCollectorsClientDeleteResponse struct { // placeholder for future response values } @@ -39,17 +39,17 @@ type AzureTrafficCollectorsClientUpdateTagsResponse struct { AzureTrafficCollector } -// ClientListOperationsResponse contains the response from method Client.ListOperations. +// ClientListOperationsResponse contains the response from method Client.NewListOperationsPager. type ClientListOperationsResponse struct { OperationListResult } -// CollectorPoliciesClientCreateOrUpdateResponse contains the response from method CollectorPoliciesClient.CreateOrUpdate. +// CollectorPoliciesClientCreateOrUpdateResponse contains the response from method CollectorPoliciesClient.BeginCreateOrUpdate. type CollectorPoliciesClientCreateOrUpdateResponse struct { CollectorPolicy } -// CollectorPoliciesClientDeleteResponse contains the response from method CollectorPoliciesClient.Delete. +// CollectorPoliciesClientDeleteResponse contains the response from method CollectorPoliciesClient.BeginDelete. type CollectorPoliciesClientDeleteResponse struct { // placeholder for future response values } @@ -59,7 +59,7 @@ type CollectorPoliciesClientGetResponse struct { CollectorPolicy } -// CollectorPoliciesClientListResponse contains the response from method CollectorPoliciesClient.List. +// CollectorPoliciesClientListResponse contains the response from method CollectorPoliciesClient.NewListPager. type CollectorPoliciesClientListResponse struct { CollectorPolicyListResult } diff --git a/sdk/resourcemanager/networkfunction/armnetworkfunction/time_rfc3339.go b/sdk/resourcemanager/networkfunction/armnetworkfunction/time_rfc3339.go index 0fcb26f08ba1..e16f0a44c5cd 100644 --- a/sdk/resourcemanager/networkfunction/armnetworkfunction/time_rfc3339.go +++ b/sdk/resourcemanager/networkfunction/armnetworkfunction/time_rfc3339.go @@ -62,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/nginx/armnginx/CHANGELOG.md b/sdk/resourcemanager/nginx/armnginx/CHANGELOG.md index b3ef8366bc82..3bcf9756e688 100644 --- a/sdk/resourcemanager/nginx/armnginx/CHANGELOG.md +++ b/sdk/resourcemanager/nginx/armnginx/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 2.1.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 2.0.0 (2022-10-13) ### Breaking Changes diff --git a/sdk/resourcemanager/nginx/armnginx/README.md b/sdk/resourcemanager/nginx/armnginx/README.md index ce1795850e2e..1803d1f40dda 100644 --- a/sdk/resourcemanager/nginx/armnginx/README.md +++ b/sdk/resourcemanager/nginx/armnginx/README.md @@ -33,23 +33,31 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Nginx modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Nginx module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armnginx.NewConfigurationsClient(, cred, nil) +clientFactory, err := armnginx.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). ```go -options := arm.ClientOptions{ +options := arm.ClientOptions { ClientOptions: azcore.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armnginx.NewConfigurationsClient(, cred, &options) +clientFactory, err := armnginx.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewDeploymentsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/nginx/armnginx/autorest.md b/sdk/resourcemanager/nginx/armnginx/autorest.md index a5c771fe1227..617d3212cee9 100644 --- a/sdk/resourcemanager/nginx/armnginx/autorest.md +++ b/sdk/resourcemanager/nginx/armnginx/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.0.0 +module-version: 2.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/nginx/armnginx/certificates_client.go b/sdk/resourcemanager/nginx/armnginx/certificates_client.go index 0fd4706d044f..80f5ef1194cd 100644 --- a/sdk/resourcemanager/nginx/armnginx/certificates_client.go +++ b/sdk/resourcemanager/nginx/armnginx/certificates_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,66 +24,59 @@ import ( // CertificatesClient contains the methods for the Certificates group. // Don't use this type directly, use NewCertificatesClient() instead. type CertificatesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCertificatesClient creates a new instance of CertificatesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCertificatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CertificatesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CertificatesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CertificatesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create or update the Nginx certificates for given Nginx deployment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// deploymentName - The name of targeted Nginx deployment -// certificateName - The name of certificate -// options - CertificatesClientBeginCreateOrUpdateOptions contains the optional parameters for the CertificatesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted Nginx deployment +// - certificateName - The name of certificate +// - options - CertificatesClientBeginCreateOrUpdateOptions contains the optional parameters for the CertificatesClient.BeginCreateOrUpdate +// method. func (client *CertificatesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, options *CertificatesClientBeginCreateOrUpdateOptions) (*runtime.Poller[CertificatesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, deploymentName, certificateName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CertificatesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CertificatesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CertificatesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CertificatesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or update the Nginx certificates for given Nginx deployment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *CertificatesClient) createOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, options *CertificatesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, deploymentName, certificateName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -114,7 +105,7 @@ func (client *CertificatesClient) createOrUpdateCreateRequest(ctx context.Contex return nil, errors.New("parameter certificateName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{certificateName}", url.PathEscape(certificateName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -130,33 +121,35 @@ func (client *CertificatesClient) createOrUpdateCreateRequest(ctx context.Contex // BeginDelete - Deletes a certificate from the nginx deployment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// deploymentName - The name of targeted Nginx deployment -// certificateName - The name of certificate -// options - CertificatesClientBeginDeleteOptions contains the optional parameters for the CertificatesClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted Nginx deployment +// - certificateName - The name of certificate +// - options - CertificatesClientBeginDeleteOptions contains the optional parameters for the CertificatesClient.BeginDelete +// method. func (client *CertificatesClient) BeginDelete(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, options *CertificatesClientBeginDeleteOptions) (*runtime.Poller[CertificatesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, deploymentName, certificateName, options) if err != nil { return nil, err } - return runtime.NewPoller[CertificatesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[CertificatesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[CertificatesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CertificatesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a certificate from the nginx deployment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *CertificatesClient) deleteOperation(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, options *CertificatesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, deploymentName, certificateName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -185,7 +178,7 @@ func (client *CertificatesClient) deleteCreateRequest(ctx context.Context, resou return nil, errors.New("parameter certificateName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{certificateName}", url.PathEscape(certificateName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,17 +191,18 @@ func (client *CertificatesClient) deleteCreateRequest(ctx context.Context, resou // Get - Get a certificate of given Nginx deployment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// deploymentName - The name of targeted Nginx deployment -// certificateName - The name of certificate -// options - CertificatesClientGetOptions contains the optional parameters for the CertificatesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted Nginx deployment +// - certificateName - The name of certificate +// - options - CertificatesClientGetOptions contains the optional parameters for the CertificatesClient.Get method. func (client *CertificatesClient) Get(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, options *CertificatesClientGetOptions) (CertificatesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, deploymentName, certificateName, options) if err != nil { return CertificatesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CertificatesClientGetResponse{}, err } @@ -237,7 +231,7 @@ func (client *CertificatesClient) getCreateRequest(ctx context.Context, resource return nil, errors.New("parameter certificateName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{certificateName}", url.PathEscape(certificateName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -258,10 +252,11 @@ func (client *CertificatesClient) getHandleResponse(resp *http.Response) (Certif } // NewListPager - List all certificates of given Nginx deployment +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// deploymentName - The name of targeted Nginx deployment -// options - CertificatesClientListOptions contains the optional parameters for the CertificatesClient.List method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted Nginx deployment +// - options - CertificatesClientListOptions contains the optional parameters for the CertificatesClient.NewListPager method. func (client *CertificatesClient) NewListPager(resourceGroupName string, deploymentName string, options *CertificatesClientListOptions) *runtime.Pager[CertificatesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[CertificatesClientListResponse]{ More: func(page CertificatesClientListResponse) bool { @@ -278,7 +273,7 @@ func (client *CertificatesClient) NewListPager(resourceGroupName string, deploym if err != nil { return CertificatesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CertificatesClientListResponse{}, err } @@ -305,7 +300,7 @@ func (client *CertificatesClient) listCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter deploymentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/nginx/armnginx/certificates_client_example_test.go b/sdk/resourcemanager/nginx/armnginx/certificates_client_example_test.go index 5b6b43aaee75..af3bd8bda6c6 100644 --- a/sdk/resourcemanager/nginx/armnginx/certificates_client_example_test.go +++ b/sdk/resourcemanager/nginx/armnginx/certificates_client_example_test.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 armnginx_test @@ -16,37 +17,49 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Certificates_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Certificates_Get.json func ExampleCertificatesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnginx.NewCertificatesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myResourceGroup", "myDeployment", "default", nil) + res, err := clientFactory.NewCertificatesClient().Get(ctx, "myResourceGroup", "myDeployment", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Certificate = armnginx.Certificate{ + // Name: to.Ptr("default"), + // Type: to.Ptr("nginx.nginxplus/nginxdeployments/certificates"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/NGINX.NGINXPLUS/nginxDeployments/myDeployment/certificates/default"), + // Properties: &armnginx.CertificateProperties{ + // CertificateVirtualPath: to.Ptr("/src/cert/somePath.cert"), + // KeyVaultSecretID: to.Ptr("https://someKV.vault.azure.com/someSecretID"), + // KeyVirtualPath: to.Ptr("/src/cert/somekey.key"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Certificates_CreateOrUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Certificates_CreateOrUpdate.json func ExampleCertificatesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnginx.NewCertificatesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "myResourceGroup", "myDeployment", "default", &armnginx.CertificatesClientBeginCreateOrUpdateOptions{Body: nil}) + poller, err := clientFactory.NewCertificatesClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDeployment", "default", &armnginx.CertificatesClientBeginCreateOrUpdateOptions{Body: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -54,22 +67,34 @@ func ExampleCertificatesClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Certificate = armnginx.Certificate{ + // Name: to.Ptr("default"), + // Type: to.Ptr("nginx.nginxplus/nginxdeployments/certificates"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/NGINX.NGINXPLUS/nginxDeployments/myDeployment/certificates/default"), + // Properties: &armnginx.CertificateProperties{ + // CertificateVirtualPath: to.Ptr("/src/cert/somePath.cert"), + // KeyVaultSecretID: to.Ptr("https://someKV.vault.azure.com/someSecretID"), + // KeyVirtualPath: to.Ptr("/src/cert/somekey.key"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Certificates_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Certificates_Delete.json func ExampleCertificatesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnginx.NewCertificatesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "myResourceGroup", "myDeployment", "default", nil) + poller, err := clientFactory.NewCertificatesClient().BeginDelete(ctx, "myResourceGroup", "myDeployment", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -79,26 +104,52 @@ func ExampleCertificatesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Certificates_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Certificates_List.json func ExampleCertificatesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnginx.NewCertificatesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("myResourceGroup", "myDeployment", nil) + pager := clientFactory.NewCertificatesClient().NewListPager("myResourceGroup", "myDeployment", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.CertificateListResponse = armnginx.CertificateListResponse{ + // Value: []*armnginx.Certificate{ + // { + // Name: to.Ptr("cert1"), + // Type: to.Ptr("nginx.nginxplus/nginxdeployments/certificates"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/NGINX.NGINXPLUS/nginxDeployments/myDeployment/certificates/cert1"), + // Properties: &armnginx.CertificateProperties{ + // CertificateVirtualPath: to.Ptr("/src/cert/somePath.cert"), + // KeyVaultSecretID: to.Ptr("https://someKV.vault.azure.com/someSecretID"), + // KeyVirtualPath: to.Ptr("/src/cert/somekey.key"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // }, + // }, + // { + // Name: to.Ptr("cert2"), + // Type: to.Ptr("nginx.nginxplus/nginxdeployments/certificates"), + // ID: to.Ptr("/subscritions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/NGINX.NGINXPLUS/nginxDeployments/myDeployment/certificates/cert2"), + // Properties: &armnginx.CertificateProperties{ + // CertificateVirtualPath: to.Ptr("/src/cert/somePath2.cert"), + // KeyVaultSecretID: to.Ptr("https://someKV.vault.azure.com/someSecretID2"), + // KeyVirtualPath: to.Ptr("/src/cert/somekey2.key"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/nginx/armnginx/client_factory.go b/sdk/resourcemanager/nginx/armnginx/client_factory.go new file mode 100644 index 000000000000..51abb4cd7517 --- /dev/null +++ b/sdk/resourcemanager/nginx/armnginx/client_factory.go @@ -0,0 +1,59 @@ +//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 armnginx + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewCertificatesClient() *CertificatesClient { + subClient, _ := NewCertificatesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewConfigurationsClient() *ConfigurationsClient { + subClient, _ := NewConfigurationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDeploymentsClient() *DeploymentsClient { + subClient, _ := NewDeploymentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/nginx/armnginx/configurations_client.go b/sdk/resourcemanager/nginx/armnginx/configurations_client.go index 66ab10afbbe6..4eaed0acad0e 100644 --- a/sdk/resourcemanager/nginx/armnginx/configurations_client.go +++ b/sdk/resourcemanager/nginx/armnginx/configurations_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,66 +24,59 @@ import ( // ConfigurationsClient contains the methods for the Configurations group. // Don't use this type directly, use NewConfigurationsClient() instead. type ConfigurationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewConfigurationsClient creates a new instance of ConfigurationsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ConfigurationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ConfigurationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ConfigurationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create or update the Nginx configuration for given Nginx deployment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// deploymentName - The name of targeted Nginx deployment -// configurationName - The name of configuration, only 'default' is supported value due to the singleton of Nginx conf -// options - ConfigurationsClientBeginCreateOrUpdateOptions contains the optional parameters for the ConfigurationsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted Nginx deployment +// - configurationName - The name of configuration, only 'default' is supported value due to the singleton of Nginx conf +// - options - ConfigurationsClientBeginCreateOrUpdateOptions contains the optional parameters for the ConfigurationsClient.BeginCreateOrUpdate +// method. func (client *ConfigurationsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, options *ConfigurationsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ConfigurationsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, deploymentName, configurationName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ConfigurationsClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConfigurationsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[ConfigurationsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ConfigurationsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or update the Nginx configuration for given Nginx deployment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *ConfigurationsClient) createOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, options *ConfigurationsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, deploymentName, configurationName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -114,7 +105,7 @@ func (client *ConfigurationsClient) createOrUpdateCreateRequest(ctx context.Cont return nil, errors.New("parameter configurationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(configurationName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -130,33 +121,35 @@ func (client *ConfigurationsClient) createOrUpdateCreateRequest(ctx context.Cont // BeginDelete - Reset the Nginx configuration of given Nginx deployment to default // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// deploymentName - The name of targeted Nginx deployment -// configurationName - The name of configuration, only 'default' is supported value due to the singleton of Nginx conf -// options - ConfigurationsClientBeginDeleteOptions contains the optional parameters for the ConfigurationsClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted Nginx deployment +// - configurationName - The name of configuration, only 'default' is supported value due to the singleton of Nginx conf +// - options - ConfigurationsClientBeginDeleteOptions contains the optional parameters for the ConfigurationsClient.BeginDelete +// method. func (client *ConfigurationsClient) BeginDelete(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, options *ConfigurationsClientBeginDeleteOptions) (*runtime.Poller[ConfigurationsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, deploymentName, configurationName, options) if err != nil { return nil, err } - return runtime.NewPoller[ConfigurationsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[ConfigurationsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ConfigurationsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ConfigurationsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Reset the Nginx configuration of given Nginx deployment to default // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *ConfigurationsClient) deleteOperation(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, options *ConfigurationsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, deploymentName, configurationName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -185,7 +178,7 @@ func (client *ConfigurationsClient) deleteCreateRequest(ctx context.Context, res return nil, errors.New("parameter configurationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(configurationName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,17 +191,18 @@ func (client *ConfigurationsClient) deleteCreateRequest(ctx context.Context, res // Get - Get the Nginx configuration of given Nginx deployment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// deploymentName - The name of targeted Nginx deployment -// configurationName - The name of configuration, only 'default' is supported value due to the singleton of Nginx conf -// options - ConfigurationsClientGetOptions contains the optional parameters for the ConfigurationsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted Nginx deployment +// - configurationName - The name of configuration, only 'default' is supported value due to the singleton of Nginx conf +// - options - ConfigurationsClientGetOptions contains the optional parameters for the ConfigurationsClient.Get method. func (client *ConfigurationsClient) Get(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, options *ConfigurationsClientGetOptions) (ConfigurationsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, deploymentName, configurationName, options) if err != nil { return ConfigurationsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConfigurationsClientGetResponse{}, err } @@ -237,7 +231,7 @@ func (client *ConfigurationsClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter configurationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(configurationName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -258,10 +252,11 @@ func (client *ConfigurationsClient) getHandleResponse(resp *http.Response) (Conf } // NewListPager - List the Nginx configuration of given Nginx deployment. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// deploymentName - The name of targeted Nginx deployment -// options - ConfigurationsClientListOptions contains the optional parameters for the ConfigurationsClient.List method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted Nginx deployment +// - options - ConfigurationsClientListOptions contains the optional parameters for the ConfigurationsClient.NewListPager method. func (client *ConfigurationsClient) NewListPager(resourceGroupName string, deploymentName string, options *ConfigurationsClientListOptions) *runtime.Pager[ConfigurationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ConfigurationsClientListResponse]{ More: func(page ConfigurationsClientListResponse) bool { @@ -278,7 +273,7 @@ func (client *ConfigurationsClient) NewListPager(resourceGroupName string, deplo if err != nil { return ConfigurationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConfigurationsClientListResponse{}, err } @@ -305,7 +300,7 @@ func (client *ConfigurationsClient) listCreateRequest(ctx context.Context, resou return nil, errors.New("parameter deploymentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/nginx/armnginx/configurations_client_example_test.go b/sdk/resourcemanager/nginx/armnginx/configurations_client_example_test.go index 84854b7c5bc0..98ece462c9f2 100644 --- a/sdk/resourcemanager/nginx/armnginx/configurations_client_example_test.go +++ b/sdk/resourcemanager/nginx/armnginx/configurations_client_example_test.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 armnginx_test @@ -16,61 +17,98 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Configurations_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Configurations_List.json func ExampleConfigurationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnginx.NewConfigurationsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("myResourceGroup", "myDeployment", nil) + pager := clientFactory.NewConfigurationsClient().NewListPager("myResourceGroup", "myDeployment", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ConfigurationListResponse = armnginx.ConfigurationListResponse{ + // Value: []*armnginx.Configuration{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("nginx.nginxplus/nginxDeployments/configurations"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/configurations/default"), + // Properties: &armnginx.ConfigurationProperties{ + // Files: []*armnginx.ConfigurationFile{ + // { + // Content: to.Ptr("ABCDEF=="), + // VirtualPath: to.Ptr("/etc/nginx/nginx.conf"), + // }}, + // Package: &armnginx.ConfigurationPackage{ + // }, + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // RootFile: to.Ptr("/etc/nginx/nginx.conf"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Configurations_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Configurations_Get.json func ExampleConfigurationsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnginx.NewConfigurationsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myResourceGroup", "myDeployment", "default", nil) + res, err := clientFactory.NewConfigurationsClient().Get(ctx, "myResourceGroup", "myDeployment", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Configuration = armnginx.Configuration{ + // Name: to.Ptr("default"), + // Type: to.Ptr("nginx.nginxplus/nginxDeployments/configurations"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/configurations/default"), + // Properties: &armnginx.ConfigurationProperties{ + // Files: []*armnginx.ConfigurationFile{ + // { + // Content: to.Ptr("ABCDEF=="), + // VirtualPath: to.Ptr("/etc/nginx/nginx.conf"), + // }}, + // Package: &armnginx.ConfigurationPackage{ + // }, + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // RootFile: to.Ptr("/etc/nginx/nginx.conf"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Configurations_CreateOrUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Configurations_CreateOrUpdate.json func ExampleConfigurationsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnginx.NewConfigurationsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "myResourceGroup", "myDeployment", "default", &armnginx.ConfigurationsClientBeginCreateOrUpdateOptions{Body: nil}) + poller, err := clientFactory.NewConfigurationsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDeployment", "default", &armnginx.ConfigurationsClientBeginCreateOrUpdateOptions{Body: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -78,22 +116,39 @@ func ExampleConfigurationsClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Configuration = armnginx.Configuration{ + // Name: to.Ptr("default"), + // Type: to.Ptr("nginx.nginxplus/nginxDeployments/configurations"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/configurations/default"), + // Properties: &armnginx.ConfigurationProperties{ + // Files: []*armnginx.ConfigurationFile{ + // { + // Content: to.Ptr("ABCDEF=="), + // VirtualPath: to.Ptr("/etc/nginx/nginx.conf"), + // }}, + // Package: &armnginx.ConfigurationPackage{ + // }, + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // RootFile: to.Ptr("/etc/nginx/nginx.conf"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Configurations_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Configurations_Delete.json func ExampleConfigurationsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnginx.NewConfigurationsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "myResourceGroup", "myDeployment", "default", nil) + poller, err := clientFactory.NewConfigurationsClient().BeginDelete(ctx, "myResourceGroup", "myDeployment", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/nginx/armnginx/constants.go b/sdk/resourcemanager/nginx/armnginx/constants.go index 1e598603eafd..1df95c1f3d76 100644 --- a/sdk/resourcemanager/nginx/armnginx/constants.go +++ b/sdk/resourcemanager/nginx/armnginx/constants.go @@ -11,7 +11,7 @@ package armnginx const ( moduleName = "armnginx" - moduleVersion = "v2.0.0" + moduleVersion = "v2.1.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/nginx/armnginx/deployments_client.go b/sdk/resourcemanager/nginx/armnginx/deployments_client.go index eb2f4ad05488..8319b797278d 100644 --- a/sdk/resourcemanager/nginx/armnginx/deployments_client.go +++ b/sdk/resourcemanager/nginx/armnginx/deployments_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,65 +24,58 @@ import ( // DeploymentsClient contains the methods for the Deployments group. // Don't use this type directly, use NewDeploymentsClient() instead. type DeploymentsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDeploymentsClient creates a new instance of DeploymentsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewDeploymentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeploymentsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".DeploymentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DeploymentsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create or update the Nginx deployment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// deploymentName - The name of targeted Nginx deployment -// options - DeploymentsClientBeginCreateOrUpdateOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted Nginx deployment +// - options - DeploymentsClientBeginCreateOrUpdateOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdate +// method. func (client *DeploymentsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginCreateOrUpdateOptions) (*runtime.Poller[DeploymentsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, deploymentName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DeploymentsClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[DeploymentsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DeploymentsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or update the Nginx deployment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *DeploymentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, deploymentName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -109,7 +100,7 @@ func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context return nil, errors.New("parameter deploymentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -125,31 +116,33 @@ func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context // BeginDelete - Delete the Nginx deployment resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// deploymentName - The name of targeted Nginx deployment -// options - DeploymentsClientBeginDeleteOptions contains the optional parameters for the DeploymentsClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted Nginx deployment +// - options - DeploymentsClientBeginDeleteOptions contains the optional parameters for the DeploymentsClient.BeginDelete method. func (client *DeploymentsClient) BeginDelete(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginDeleteOptions) (*runtime.Poller[DeploymentsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, deploymentName, options) if err != nil { return nil, err } - return runtime.NewPoller[DeploymentsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[DeploymentsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DeploymentsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DeploymentsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete the Nginx deployment resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *DeploymentsClient) deleteOperation(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, deploymentName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -174,7 +167,7 @@ func (client *DeploymentsClient) deleteCreateRequest(ctx context.Context, resour return nil, errors.New("parameter deploymentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -187,16 +180,17 @@ func (client *DeploymentsClient) deleteCreateRequest(ctx context.Context, resour // Get - Get the Nginx deployment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// deploymentName - The name of targeted Nginx deployment -// options - DeploymentsClientGetOptions contains the optional parameters for the DeploymentsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted Nginx deployment +// - options - DeploymentsClientGetOptions contains the optional parameters for the DeploymentsClient.Get method. func (client *DeploymentsClient) Get(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientGetOptions) (DeploymentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, deploymentName, options) if err != nil { return DeploymentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DeploymentsClientGetResponse{}, err } @@ -221,7 +215,7 @@ func (client *DeploymentsClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter deploymentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -242,8 +236,9 @@ func (client *DeploymentsClient) getHandleResponse(resp *http.Response) (Deploym } // NewListPager - List the Nginx deployments resources +// // Generated from API version 2022-08-01 -// options - DeploymentsClientListOptions contains the optional parameters for the DeploymentsClient.List method. +// - options - DeploymentsClientListOptions contains the optional parameters for the DeploymentsClient.NewListPager method. func (client *DeploymentsClient) NewListPager(options *DeploymentsClientListOptions) *runtime.Pager[DeploymentsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[DeploymentsClientListResponse]{ More: func(page DeploymentsClientListResponse) bool { @@ -260,7 +255,7 @@ func (client *DeploymentsClient) NewListPager(options *DeploymentsClientListOpti if err != nil { return DeploymentsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DeploymentsClientListResponse{}, err } @@ -279,7 +274,7 @@ func (client *DeploymentsClient) listCreateRequest(ctx context.Context, options return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -300,10 +295,11 @@ func (client *DeploymentsClient) listHandleResponse(resp *http.Response) (Deploy } // NewListByResourceGroupPager - List all Nginx deployments under the specified resource group. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - DeploymentsClientListByResourceGroupOptions contains the optional parameters for the DeploymentsClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - DeploymentsClientListByResourceGroupOptions contains the optional parameters for the DeploymentsClient.NewListByResourceGroupPager +// method. func (client *DeploymentsClient) NewListByResourceGroupPager(resourceGroupName string, options *DeploymentsClientListByResourceGroupOptions) *runtime.Pager[DeploymentsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[DeploymentsClientListByResourceGroupResponse]{ More: func(page DeploymentsClientListByResourceGroupResponse) bool { @@ -320,7 +316,7 @@ func (client *DeploymentsClient) NewListByResourceGroupPager(resourceGroupName s if err != nil { return DeploymentsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DeploymentsClientListByResourceGroupResponse{}, err } @@ -343,7 +339,7 @@ func (client *DeploymentsClient) listByResourceGroupCreateRequest(ctx context.Co return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -365,31 +361,33 @@ func (client *DeploymentsClient) listByResourceGroupHandleResponse(resp *http.Re // BeginUpdate - Update the Nginx deployment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// deploymentName - The name of targeted Nginx deployment -// options - DeploymentsClientBeginUpdateOptions contains the optional parameters for the DeploymentsClient.BeginUpdate method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted Nginx deployment +// - options - DeploymentsClientBeginUpdateOptions contains the optional parameters for the DeploymentsClient.BeginUpdate method. func (client *DeploymentsClient) BeginUpdate(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginUpdateOptions) (*runtime.Poller[DeploymentsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, deploymentName, options) if err != nil { return nil, err } - return runtime.NewPoller[DeploymentsClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[DeploymentsClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DeploymentsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DeploymentsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Update the Nginx deployment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-08-01 func (client *DeploymentsClient) update(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, deploymentName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -414,7 +412,7 @@ func (client *DeploymentsClient) updateCreateRequest(ctx context.Context, resour return nil, errors.New("parameter deploymentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/nginx/armnginx/deployments_client_example_test.go b/sdk/resourcemanager/nginx/armnginx/deployments_client_example_test.go index ae244f057b90..2ad4cacd200e 100644 --- a/sdk/resourcemanager/nginx/armnginx/deployments_client_example_test.go +++ b/sdk/resourcemanager/nginx/armnginx/deployments_client_example_test.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 armnginx_test @@ -16,37 +17,66 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Deployments_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Deployments_Get.json func ExampleDeploymentsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnginx.NewDeploymentsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myResourceGroup", "myDeployment", nil) + res, err := clientFactory.NewDeploymentsClient().Get(ctx, "myResourceGroup", "myDeployment", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Deployment = armnginx.Deployment{ + // Name: to.Ptr("myDeployment"), + // Type: to.Ptr("nginx.nginxplus/deployments"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), + // Location: to.Ptr("westus"), + // Properties: &armnginx.DeploymentProperties{ + // ManagedResourceGroup: to.Ptr("myManagedResourceGroup"), + // NetworkProfile: &armnginx.NetworkProfile{ + // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ + // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ + // { + // PrivateIPAddress: to.Ptr("1.1.1.1"), + // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }}, + // PublicIPAddresses: []*armnginx.PublicIPAddress{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), + // }}, + // }, + // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }, + // }, + // NginxVersion: to.Ptr("nginx-1.19.6"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Deployments_Create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Deployments_Create.json func ExampleDeploymentsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnginx.NewDeploymentsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "myResourceGroup", "myDeployment", &armnginx.DeploymentsClientBeginCreateOrUpdateOptions{Body: nil}) + poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDeployment", &armnginx.DeploymentsClientBeginCreateOrUpdateOptions{Body: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -54,22 +84,55 @@ func ExampleDeploymentsClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Deployment = armnginx.Deployment{ + // Name: to.Ptr("myDeployment"), + // Type: to.Ptr("nginx.nginxplus/deployments"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), + // Location: to.Ptr("westus"), + // Properties: &armnginx.DeploymentProperties{ + // IPAddress: to.Ptr("1.1.1.1"), + // ManagedResourceGroup: to.Ptr("myManagedResourceGroup"), + // NetworkProfile: &armnginx.NetworkProfile{ + // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ + // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ + // { + // PrivateIPAddress: to.Ptr("1.1.1.1"), + // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }}, + // PublicIPAddresses: []*armnginx.PublicIPAddress{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), + // }}, + // }, + // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }, + // }, + // NginxVersion: to.Ptr("nginx-1.19.6"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Deployments_Update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Deployments_Update.json func ExampleDeploymentsClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnginx.NewDeploymentsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "myResourceGroup", "myDeployment", &armnginx.DeploymentsClientBeginUpdateOptions{Body: nil}) + poller, err := clientFactory.NewDeploymentsClient().BeginUpdate(ctx, "myResourceGroup", "myDeployment", &armnginx.DeploymentsClientBeginUpdateOptions{Body: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -77,22 +140,55 @@ func ExampleDeploymentsClient_BeginUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Deployment = armnginx.Deployment{ + // Name: to.Ptr("myDeployment"), + // Type: to.Ptr("nginx.nginxplus/deployments"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), + // Location: to.Ptr("westus"), + // Properties: &armnginx.DeploymentProperties{ + // IPAddress: to.Ptr("1.1.1.1"), + // ManagedResourceGroup: to.Ptr("myManagedResourceGroup"), + // NetworkProfile: &armnginx.NetworkProfile{ + // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ + // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ + // { + // PrivateIPAddress: to.Ptr("1.1.1.1"), + // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }}, + // PublicIPAddresses: []*armnginx.PublicIPAddress{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), + // }}, + // }, + // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }, + // }, + // NginxVersion: to.Ptr("nginx-1.19.6"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Deployments_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Deployments_Delete.json func ExampleDeploymentsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnginx.NewDeploymentsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "myResourceGroup", "myDeployment", nil) + poller, err := clientFactory.NewDeploymentsClient().BeginDelete(ctx, "myResourceGroup", "myDeployment", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -102,50 +198,116 @@ func ExampleDeploymentsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Deployments_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Deployments_List.json func ExampleDeploymentsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnginx.NewDeploymentsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewDeploymentsClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DeploymentListResponse = armnginx.DeploymentListResponse{ + // Value: []*armnginx.Deployment{ + // { + // Name: to.Ptr("myDeployment"), + // Type: to.Ptr("nginx.nginxplus/deployments"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), + // Location: to.Ptr("westus"), + // Properties: &armnginx.DeploymentProperties{ + // IPAddress: to.Ptr("1.1.1.1"), + // ManagedResourceGroup: to.Ptr("myManagedResourceGroup"), + // NetworkProfile: &armnginx.NetworkProfile{ + // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ + // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ + // { + // PrivateIPAddress: to.Ptr("1.1.1.1"), + // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }}, + // PublicIPAddresses: []*armnginx.PublicIPAddress{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), + // }}, + // }, + // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }, + // }, + // NginxVersion: to.Ptr("nginx-1.19.6"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Deployments_ListByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Deployments_ListByResourceGroup.json func ExampleDeploymentsClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armnginx.NewDeploymentsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("myResourceGroup", nil) + pager := clientFactory.NewDeploymentsClient().NewListByResourceGroupPager("myResourceGroup", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DeploymentListResponse = armnginx.DeploymentListResponse{ + // Value: []*armnginx.Deployment{ + // { + // Name: to.Ptr("myDeployment"), + // Type: to.Ptr("nginx.nginxplus/deployments"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), + // Location: to.Ptr("westus"), + // Properties: &armnginx.DeploymentProperties{ + // IPAddress: to.Ptr("1.1.1.1"), + // ManagedResourceGroup: to.Ptr("myManagedResourceGroup"), + // NetworkProfile: &armnginx.NetworkProfile{ + // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ + // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ + // { + // PrivateIPAddress: to.Ptr("1.1.1.1"), + // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }}, + // PublicIPAddresses: []*armnginx.PublicIPAddress{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), + // }}, + // }, + // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }, + // }, + // NginxVersion: to.Ptr("nginx-1.19.6"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/nginx/armnginx/go.mod b/sdk/resourcemanager/nginx/armnginx/go.mod index 86bb42d27fc5..3ba81baeddcf 100644 --- a/sdk/resourcemanager/nginx/armnginx/go.mod +++ b/sdk/resourcemanager/nginx/armnginx/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/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.1.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/nginx/armnginx/go.sum b/sdk/resourcemanager/nginx/armnginx/go.sum index 8828b17b1853..8ba445a8c4da 100644 --- a/sdk/resourcemanager/nginx/armnginx/go.sum +++ b/sdk/resourcemanager/nginx/armnginx/go.sum @@ -1,33 +1,31 @@ -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.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= -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.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= 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/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/nginx/armnginx/models.go b/sdk/resourcemanager/nginx/armnginx/models.go index 3f7c1d67b27b..ca0f3ce20fd4 100644 --- a/sdk/resourcemanager/nginx/armnginx/models.go +++ b/sdk/resourcemanager/nginx/armnginx/models.go @@ -65,7 +65,7 @@ type CertificatesClientGetOptions struct { // placeholder for future optional parameters } -// CertificatesClientListOptions contains the optional parameters for the CertificatesClient.List method. +// CertificatesClientListOptions contains the optional parameters for the CertificatesClient.NewListPager method. type CertificatesClientListOptions struct { // placeholder for future optional parameters } @@ -138,7 +138,7 @@ type ConfigurationsClientGetOptions struct { // placeholder for future optional parameters } -// ConfigurationsClientListOptions contains the optional parameters for the ConfigurationsClient.List method. +// ConfigurationsClientListOptions contains the optional parameters for the ConfigurationsClient.NewListPager method. type ConfigurationsClientListOptions struct { // placeholder for future optional parameters } @@ -229,13 +229,13 @@ type DeploymentsClientGetOptions struct { // placeholder for future optional parameters } -// DeploymentsClientListByResourceGroupOptions contains the optional parameters for the DeploymentsClient.ListByResourceGroup +// DeploymentsClientListByResourceGroupOptions contains the optional parameters for the DeploymentsClient.NewListByResourceGroupPager // method. type DeploymentsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// DeploymentsClientListOptions contains the optional parameters for the DeploymentsClient.List method. +// DeploymentsClientListOptions contains the optional parameters for the DeploymentsClient.NewListPager method. type DeploymentsClientListOptions struct { // placeholder for future optional parameters } @@ -314,7 +314,7 @@ type OperationResult struct { Name *string `json:"name,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/nginx/armnginx/models_serde.go b/sdk/resourcemanager/nginx/armnginx/models_serde.go index 64541e7482ce..77c328d1da98 100644 --- a/sdk/resourcemanager/nginx/armnginx/models_serde.go +++ b/sdk/resourcemanager/nginx/armnginx/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type Certificate. func (c Certificate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "location", c.Location) populate(objectMap, "name", c.Name) @@ -69,7 +69,7 @@ func (c *Certificate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CertificateListResponse. func (c CertificateListResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -100,7 +100,7 @@ func (c *CertificateListResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CertificateProperties. func (c CertificateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "certificateVirtualPath", c.CertificateVirtualPath) populate(objectMap, "keyVaultSecretId", c.KeyVaultSecretID) populate(objectMap, "keyVirtualPath", c.KeyVirtualPath) @@ -139,7 +139,7 @@ func (c *CertificateProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Configuration. func (c Configuration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "location", c.Location) populate(objectMap, "name", c.Name) @@ -190,7 +190,7 @@ func (c *Configuration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConfigurationFile. func (c ConfigurationFile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "content", c.Content) populate(objectMap, "virtualPath", c.VirtualPath) return json.Marshal(objectMap) @@ -221,7 +221,7 @@ func (c *ConfigurationFile) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConfigurationListResponse. func (c ConfigurationListResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -252,7 +252,7 @@ func (c *ConfigurationListResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConfigurationPackage. func (c ConfigurationPackage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "data", c.Data) return json.Marshal(objectMap) } @@ -279,7 +279,7 @@ func (c *ConfigurationPackage) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConfigurationProperties. func (c ConfigurationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "files", c.Files) populate(objectMap, "package", c.Package) populate(objectMap, "protectedFiles", c.ProtectedFiles) @@ -322,7 +322,7 @@ func (c *ConfigurationProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Deployment. func (d Deployment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", d.ID) populate(objectMap, "identity", d.Identity) populate(objectMap, "location", d.Location) @@ -381,7 +381,7 @@ func (d *Deployment) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DeploymentListResponse. func (d DeploymentListResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", d.NextLink) populate(objectMap, "value", d.Value) return json.Marshal(objectMap) @@ -412,7 +412,7 @@ func (d *DeploymentListResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DeploymentProperties. func (d DeploymentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "enableDiagnosticsSupport", d.EnableDiagnosticsSupport) populate(objectMap, "ipAddress", d.IPAddress) populate(objectMap, "logging", d.Logging) @@ -463,7 +463,7 @@ func (d *DeploymentProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DeploymentUpdateParameters. func (d DeploymentUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "identity", d.Identity) populate(objectMap, "location", d.Location) populate(objectMap, "properties", d.Properties) @@ -506,7 +506,7 @@ func (d *DeploymentUpdateParameters) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DeploymentUpdateProperties. func (d DeploymentUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "enableDiagnosticsSupport", d.EnableDiagnosticsSupport) populate(objectMap, "logging", d.Logging) return json.Marshal(objectMap) @@ -537,7 +537,7 @@ func (d *DeploymentUpdateProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorResponseBody. func (e ErrorResponseBody) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "code", e.Code) populate(objectMap, "details", e.Details) populate(objectMap, "message", e.Message) @@ -576,7 +576,7 @@ func (e *ErrorResponseBody) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FrontendIPConfiguration. func (f FrontendIPConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "privateIPAddresses", f.PrivateIPAddresses) populate(objectMap, "publicIPAddresses", f.PublicIPAddresses) return json.Marshal(objectMap) @@ -607,7 +607,7 @@ func (f *FrontendIPConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IdentityProperties. func (i IdentityProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "principalId", i.PrincipalID) populate(objectMap, "tenantId", i.TenantID) populate(objectMap, "type", i.Type) @@ -646,7 +646,7 @@ func (i *IdentityProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Logging. func (l Logging) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "storageAccount", l.StorageAccount) return json.Marshal(objectMap) } @@ -673,7 +673,7 @@ func (l *Logging) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type NetworkInterfaceConfiguration. func (n NetworkInterfaceConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "subnetId", n.SubnetID) return json.Marshal(objectMap) } @@ -700,7 +700,7 @@ func (n *NetworkInterfaceConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type NetworkProfile. func (n NetworkProfile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "frontEndIPConfiguration", n.FrontEndIPConfiguration) populate(objectMap, "networkInterfaceConfiguration", n.NetworkInterfaceConfiguration) return json.Marshal(objectMap) @@ -731,7 +731,7 @@ func (n *NetworkProfile) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -770,7 +770,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationListResult. func (o OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -801,7 +801,7 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationResult. func (o OperationResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "display", o.Display) populate(objectMap, "isDataAction", o.IsDataAction) populate(objectMap, "name", o.Name) @@ -836,7 +836,7 @@ func (o *OperationResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateIPAddress. func (p PrivateIPAddress) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "privateIPAddress", p.PrivateIPAddress) populate(objectMap, "privateIPAllocationMethod", p.PrivateIPAllocationMethod) populate(objectMap, "subnetId", p.SubnetID) @@ -871,7 +871,7 @@ func (p *PrivateIPAddress) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PublicIPAddress. func (p PublicIPAddress) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) return json.Marshal(objectMap) } @@ -898,7 +898,7 @@ func (p *PublicIPAddress) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceProviderDefaultErrorResponse. func (r ResourceProviderDefaultErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "error", r.Error) return json.Marshal(objectMap) } @@ -925,7 +925,7 @@ func (r *ResourceProviderDefaultErrorResponse) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type ResourceSKU. func (r ResourceSKU) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", r.Name) return json.Marshal(objectMap) } @@ -952,7 +952,7 @@ func (r *ResourceSKU) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StorageAccount. func (s StorageAccount) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "accountName", s.AccountName) populate(objectMap, "containerName", s.ContainerName) return json.Marshal(objectMap) @@ -983,7 +983,7 @@ func (s *StorageAccount) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -1030,7 +1030,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UserIdentityProperties. func (u UserIdentityProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "clientId", u.ClientID) populate(objectMap, "principalId", u.PrincipalID) return json.Marshal(objectMap) @@ -1059,7 +1059,7 @@ func (u *UserIdentityProperties) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -1069,7 +1069,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/sdk/resourcemanager/nginx/armnginx/operations_client.go b/sdk/resourcemanager/nginx/armnginx/operations_client.go index affc15cf015f..5785ea9193db 100644 --- a/sdk/resourcemanager/nginx/armnginx/operations_client.go +++ b/sdk/resourcemanager/nginx/armnginx/operations_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,35 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - List all operations provided by Nginx.NginxPlus for the 2022-08-01 api version. +// // Generated from API version 2022-08-01 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -68,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -83,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Nginx.NginxPlus/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/nginx/armnginx/operations_client_example_test.go b/sdk/resourcemanager/nginx/armnginx/operations_client_example_test.go index 3c90cb854517..114d8b6684c4 100644 --- a/sdk/resourcemanager/nginx/armnginx/operations_client_example_test.go +++ b/sdk/resourcemanager/nginx/armnginx/operations_client_example_test.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 armnginx_test @@ -16,26 +17,39 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Operations_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/nginx/resource-manager/NGINX.NGINXPLUS/stable/2022-08-01/examples/Operations_List.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 := armnginx.NewOperationsClient(cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewOperationsClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationListResult = armnginx.OperationListResult{ + // Value: []*armnginx.OperationResult{ + // { + // Name: to.Ptr("Nginx.NginxPlus/nginxDeployments/write"), + // Display: &armnginx.OperationDisplay{ + // Description: to.Ptr("Write deployments resource"), + // Operation: to.Ptr("write"), + // Provider: to.Ptr("Nginx.NginxPlus"), + // Resource: to.Ptr("deployments"), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/nginx/armnginx/response_types.go b/sdk/resourcemanager/nginx/armnginx/response_types.go index 5cb31e8a015e..fdd097dbb5aa 100644 --- a/sdk/resourcemanager/nginx/armnginx/response_types.go +++ b/sdk/resourcemanager/nginx/armnginx/response_types.go @@ -9,12 +9,12 @@ package armnginx -// CertificatesClientCreateOrUpdateResponse contains the response from method CertificatesClient.CreateOrUpdate. +// CertificatesClientCreateOrUpdateResponse contains the response from method CertificatesClient.BeginCreateOrUpdate. type CertificatesClientCreateOrUpdateResponse struct { Certificate } -// CertificatesClientDeleteResponse contains the response from method CertificatesClient.Delete. +// CertificatesClientDeleteResponse contains the response from method CertificatesClient.BeginDelete. type CertificatesClientDeleteResponse struct { // placeholder for future response values } @@ -24,17 +24,17 @@ type CertificatesClientGetResponse struct { Certificate } -// CertificatesClientListResponse contains the response from method CertificatesClient.List. +// CertificatesClientListResponse contains the response from method CertificatesClient.NewListPager. type CertificatesClientListResponse struct { CertificateListResponse } -// ConfigurationsClientCreateOrUpdateResponse contains the response from method ConfigurationsClient.CreateOrUpdate. +// ConfigurationsClientCreateOrUpdateResponse contains the response from method ConfigurationsClient.BeginCreateOrUpdate. type ConfigurationsClientCreateOrUpdateResponse struct { Configuration } -// ConfigurationsClientDeleteResponse contains the response from method ConfigurationsClient.Delete. +// ConfigurationsClientDeleteResponse contains the response from method ConfigurationsClient.BeginDelete. type ConfigurationsClientDeleteResponse struct { // placeholder for future response values } @@ -44,17 +44,17 @@ type ConfigurationsClientGetResponse struct { Configuration } -// ConfigurationsClientListResponse contains the response from method ConfigurationsClient.List. +// ConfigurationsClientListResponse contains the response from method ConfigurationsClient.NewListPager. type ConfigurationsClientListResponse struct { ConfigurationListResponse } -// DeploymentsClientCreateOrUpdateResponse contains the response from method DeploymentsClient.CreateOrUpdate. +// DeploymentsClientCreateOrUpdateResponse contains the response from method DeploymentsClient.BeginCreateOrUpdate. type DeploymentsClientCreateOrUpdateResponse struct { Deployment } -// DeploymentsClientDeleteResponse contains the response from method DeploymentsClient.Delete. +// DeploymentsClientDeleteResponse contains the response from method DeploymentsClient.BeginDelete. type DeploymentsClientDeleteResponse struct { // placeholder for future response values } @@ -64,22 +64,22 @@ type DeploymentsClientGetResponse struct { Deployment } -// DeploymentsClientListByResourceGroupResponse contains the response from method DeploymentsClient.ListByResourceGroup. +// DeploymentsClientListByResourceGroupResponse contains the response from method DeploymentsClient.NewListByResourceGroupPager. type DeploymentsClientListByResourceGroupResponse struct { DeploymentListResponse } -// DeploymentsClientListResponse contains the response from method DeploymentsClient.List. +// DeploymentsClientListResponse contains the response from method DeploymentsClient.NewListPager. type DeploymentsClientListResponse struct { DeploymentListResponse } -// DeploymentsClientUpdateResponse contains the response from method DeploymentsClient.Update. +// DeploymentsClientUpdateResponse contains the response from method DeploymentsClient.BeginUpdate. type DeploymentsClientUpdateResponse struct { Deployment } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult } diff --git a/sdk/resourcemanager/nginx/armnginx/time_rfc3339.go b/sdk/resourcemanager/nginx/armnginx/time_rfc3339.go index dcfe55e4eee0..7faa09bd39a3 100644 --- a/sdk/resourcemanager/nginx/armnginx/time_rfc3339.go +++ b/sdk/resourcemanager/nginx/armnginx/time_rfc3339.go @@ -62,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/CHANGELOG.md b/sdk/resourcemanager/notificationhubs/armnotificationhubs/CHANGELOG.md index 1c3f3dfe7b1c..301453f39011 100644 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/CHANGELOG.md +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-05-17) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/notificationhubs/armnotificationhubs` 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/notificationhubs/armnotificationhubs/README.md b/sdk/resourcemanager/notificationhubs/armnotificationhubs/README.md index e97aee5d9225..0174a0bb3825 100644 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/README.md +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Notification Hubs modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Notification Hubs module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armnotificationhubs.NewNamespacesClient(, cred, nil) +clientFactory, err := armnotificationhubs.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armnotificationhubs.NewNamespacesClient(, cred, &options) +clientFactory, err := armnotificationhubs.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/autorest.md b/sdk/resourcemanager/notificationhubs/armnotificationhubs/autorest.md index 4fcf3d0e6f70..cbce2c1cb8de 100644 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/autorest.md +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/autorest.md @@ -8,5 +8,5 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_client.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/client.go similarity index 86% rename from sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_client.go rename to sdk/resourcemanager/notificationhubs/armnotificationhubs/client.go index 2fc609f63b7b..8878c3d7b4bd 100644 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_client.go +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/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 armnotificationhubs @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,50 +24,42 @@ import ( // Client contains the methods for the NotificationHubs group. // Don't use this type directly, use NewClient() instead. type Client struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewClient creates a new instance of Client with the specified values. -// subscriptionID - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID -// forms part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID +// forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".Client", moduleVersion, credential, options) if err != nil { return nil, err } client := &Client{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CheckNotificationHubAvailability - Checks the availability of the given notificationHub in a namespace. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// parameters - The notificationHub name. -// options - ClientCheckNotificationHubAvailabilityOptions contains the optional parameters for the Client.CheckNotificationHubAvailability -// method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - parameters - The notificationHub name. +// - options - ClientCheckNotificationHubAvailabilityOptions contains the optional parameters for the Client.CheckNotificationHubAvailability +// method. func (client *Client) CheckNotificationHubAvailability(ctx context.Context, resourceGroupName string, namespaceName string, parameters CheckAvailabilityParameters, options *ClientCheckNotificationHubAvailabilityOptions) (ClientCheckNotificationHubAvailabilityResponse, error) { req, err := client.checkNotificationHubAvailabilityCreateRequest(ctx, resourceGroupName, namespaceName, parameters, options) if err != nil { return ClientCheckNotificationHubAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientCheckNotificationHubAvailabilityResponse{}, err } @@ -93,7 +84,7 @@ func (client *Client) checkNotificationHubAvailabilityCreateRequest(ctx context. return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -115,18 +106,19 @@ func (client *Client) checkNotificationHubAvailabilityHandleResponse(resp *http. // CreateOrUpdate - Creates/Update a NotificationHub in a namespace. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// notificationHubName - The notification hub name. -// parameters - Parameters supplied to the create/update a NotificationHub Resource. -// options - ClientCreateOrUpdateOptions contains the optional parameters for the Client.CreateOrUpdate method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - notificationHubName - The notification hub name. +// - parameters - Parameters supplied to the create/update a NotificationHub Resource. +// - options - ClientCreateOrUpdateOptions contains the optional parameters for the Client.CreateOrUpdate method. func (client *Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, parameters NotificationHubCreateOrUpdateParameters, options *ClientCreateOrUpdateOptions) (ClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, parameters, options) if err != nil { return ClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientCreateOrUpdateResponse{}, err } @@ -155,7 +147,7 @@ func (client *Client) createOrUpdateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -177,20 +169,21 @@ func (client *Client) createOrUpdateHandleResponse(resp *http.Response) (ClientC // CreateOrUpdateAuthorizationRule - Creates/Updates an authorization rule for a NotificationHub // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// notificationHubName - The notification hub name. -// authorizationRuleName - Authorization Rule Name. -// parameters - The shared access authorization rule. -// options - ClientCreateOrUpdateAuthorizationRuleOptions contains the optional parameters for the Client.CreateOrUpdateAuthorizationRule -// method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - notificationHubName - The notification hub name. +// - authorizationRuleName - Authorization Rule Name. +// - parameters - The shared access authorization rule. +// - options - ClientCreateOrUpdateAuthorizationRuleOptions contains the optional parameters for the Client.CreateOrUpdateAuthorizationRule +// method. func (client *Client) CreateOrUpdateAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters, options *ClientCreateOrUpdateAuthorizationRuleOptions) (ClientCreateOrUpdateAuthorizationRuleResponse, error) { req, err := client.createOrUpdateAuthorizationRuleCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, parameters, options) if err != nil { return ClientCreateOrUpdateAuthorizationRuleResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientCreateOrUpdateAuthorizationRuleResponse{}, err } @@ -223,7 +216,7 @@ func (client *Client) createOrUpdateAuthorizationRuleCreateRequest(ctx context.C return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -245,17 +238,18 @@ func (client *Client) createOrUpdateAuthorizationRuleHandleResponse(resp *http.R // DebugSend - test send a push notification // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// notificationHubName - The notification hub name. -// options - ClientDebugSendOptions contains the optional parameters for the Client.DebugSend method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - notificationHubName - The notification hub name. +// - options - ClientDebugSendOptions contains the optional parameters for the Client.DebugSend method. func (client *Client) DebugSend(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *ClientDebugSendOptions) (ClientDebugSendResponse, error) { req, err := client.debugSendCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, options) if err != nil { return ClientDebugSendResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientDebugSendResponse{}, err } @@ -284,7 +278,7 @@ func (client *Client) debugSendCreateRequest(ctx context.Context, resourceGroupN return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -309,17 +303,18 @@ func (client *Client) debugSendHandleResponse(resp *http.Response) (ClientDebugS // Delete - Deletes a notification hub associated with a namespace. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// notificationHubName - The notification hub name. -// options - ClientDeleteOptions contains the optional parameters for the Client.Delete method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - notificationHubName - The notification hub name. +// - options - ClientDeleteOptions contains the optional parameters for the Client.Delete method. func (client *Client) Delete(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *ClientDeleteOptions) (ClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, options) if err != nil { return ClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientDeleteResponse{}, err } @@ -348,7 +343,7 @@ func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -360,19 +355,20 @@ func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName // DeleteAuthorizationRule - Deletes a notificationHub authorization rule // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// notificationHubName - The notification hub name. -// authorizationRuleName - Authorization Rule Name. -// options - ClientDeleteAuthorizationRuleOptions contains the optional parameters for the Client.DeleteAuthorizationRule -// method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - notificationHubName - The notification hub name. +// - authorizationRuleName - Authorization Rule Name. +// - options - ClientDeleteAuthorizationRuleOptions contains the optional parameters for the Client.DeleteAuthorizationRule +// method. func (client *Client) DeleteAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, options *ClientDeleteAuthorizationRuleOptions) (ClientDeleteAuthorizationRuleResponse, error) { req, err := client.deleteAuthorizationRuleCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, options) if err != nil { return ClientDeleteAuthorizationRuleResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientDeleteAuthorizationRuleResponse{}, err } @@ -405,7 +401,7 @@ func (client *Client) deleteAuthorizationRuleCreateRequest(ctx context.Context, return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -417,17 +413,18 @@ func (client *Client) deleteAuthorizationRuleCreateRequest(ctx context.Context, // Get - Lists the notification hubs associated with a namespace. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// notificationHubName - The notification hub name. -// options - ClientGetOptions contains the optional parameters for the Client.Get method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - notificationHubName - The notification hub name. +// - options - ClientGetOptions contains the optional parameters for the Client.Get method. func (client *Client) Get(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *ClientGetOptions) (ClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, options) if err != nil { return ClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientGetResponse{}, err } @@ -456,7 +453,7 @@ func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName st return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -478,18 +475,19 @@ func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, // GetAuthorizationRule - Gets an authorization rule for a NotificationHub by name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name -// notificationHubName - The notification hub name. -// authorizationRuleName - authorization rule name. -// options - ClientGetAuthorizationRuleOptions contains the optional parameters for the Client.GetAuthorizationRule method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name +// - notificationHubName - The notification hub name. +// - authorizationRuleName - authorization rule name. +// - options - ClientGetAuthorizationRuleOptions contains the optional parameters for the Client.GetAuthorizationRule method. func (client *Client) GetAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, options *ClientGetAuthorizationRuleOptions) (ClientGetAuthorizationRuleResponse, error) { req, err := client.getAuthorizationRuleCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, options) if err != nil { return ClientGetAuthorizationRuleResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientGetAuthorizationRuleResponse{}, err } @@ -522,7 +520,7 @@ func (client *Client) getAuthorizationRuleCreateRequest(ctx context.Context, res return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -544,17 +542,18 @@ func (client *Client) getAuthorizationRuleHandleResponse(resp *http.Response) (C // GetPnsCredentials - Lists the PNS Credentials associated with a notification hub . // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// notificationHubName - The notification hub name. -// options - ClientGetPnsCredentialsOptions contains the optional parameters for the Client.GetPnsCredentials method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - notificationHubName - The notification hub name. +// - options - ClientGetPnsCredentialsOptions contains the optional parameters for the Client.GetPnsCredentials method. func (client *Client) GetPnsCredentials(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *ClientGetPnsCredentialsOptions) (ClientGetPnsCredentialsResponse, error) { req, err := client.getPnsCredentialsCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, options) if err != nil { return ClientGetPnsCredentialsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientGetPnsCredentialsResponse{}, err } @@ -583,7 +582,7 @@ func (client *Client) getPnsCredentialsCreateRequest(ctx context.Context, resour return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -604,11 +603,11 @@ func (client *Client) getPnsCredentialsHandleResponse(resp *http.Response) (Clie } // NewListPager - Lists the notification hubs associated with a namespace. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// options - ClientListOptions contains the optional parameters for the Client.List method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - options - ClientListOptions contains the optional parameters for the Client.NewListPager method. func (client *Client) NewListPager(resourceGroupName string, namespaceName string, options *ClientListOptions) *runtime.Pager[ClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ClientListResponse]{ More: func(page ClientListResponse) bool { @@ -625,7 +624,7 @@ func (client *Client) NewListPager(resourceGroupName string, namespaceName strin if err != nil { return ClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientListResponse{}, err } @@ -652,7 +651,7 @@ func (client *Client) listCreateRequest(ctx context.Context, resourceGroupName s return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -673,12 +672,13 @@ func (client *Client) listHandleResponse(resp *http.Response) (ClientListRespons } // NewListAuthorizationRulesPager - Gets the authorization rules for a NotificationHub. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name -// notificationHubName - The notification hub name. -// options - ClientListAuthorizationRulesOptions contains the optional parameters for the Client.ListAuthorizationRules method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name +// - notificationHubName - The notification hub name. +// - options - ClientListAuthorizationRulesOptions contains the optional parameters for the Client.NewListAuthorizationRulesPager +// method. func (client *Client) NewListAuthorizationRulesPager(resourceGroupName string, namespaceName string, notificationHubName string, options *ClientListAuthorizationRulesOptions) *runtime.Pager[ClientListAuthorizationRulesResponse] { return runtime.NewPager(runtime.PagingHandler[ClientListAuthorizationRulesResponse]{ More: func(page ClientListAuthorizationRulesResponse) bool { @@ -695,7 +695,7 @@ func (client *Client) NewListAuthorizationRulesPager(resourceGroupName string, n if err != nil { return ClientListAuthorizationRulesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientListAuthorizationRulesResponse{}, err } @@ -726,7 +726,7 @@ func (client *Client) listAuthorizationRulesCreateRequest(ctx context.Context, r return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -748,18 +748,19 @@ func (client *Client) listAuthorizationRulesHandleResponse(resp *http.Response) // ListKeys - Gets the Primary and Secondary ConnectionStrings to the NotificationHub // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// notificationHubName - The notification hub name. -// authorizationRuleName - The connection string of the NotificationHub for the specified authorizationRule. -// options - ClientListKeysOptions contains the optional parameters for the Client.ListKeys method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - notificationHubName - The notification hub name. +// - authorizationRuleName - The connection string of the NotificationHub for the specified authorizationRule. +// - options - ClientListKeysOptions contains the optional parameters for the Client.ListKeys method. func (client *Client) ListKeys(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, options *ClientListKeysOptions) (ClientListKeysResponse, error) { req, err := client.listKeysCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, options) if err != nil { return ClientListKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientListKeysResponse{}, err } @@ -792,7 +793,7 @@ func (client *Client) listKeysCreateRequest(ctx context.Context, resourceGroupNa return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -814,17 +815,18 @@ func (client *Client) listKeysHandleResponse(resp *http.Response) (ClientListKey // Patch - Patch a NotificationHub in a namespace. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// notificationHubName - The notification hub name. -// options - ClientPatchOptions contains the optional parameters for the Client.Patch method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - notificationHubName - The notification hub name. +// - options - ClientPatchOptions contains the optional parameters for the Client.Patch method. func (client *Client) Patch(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *ClientPatchOptions) (ClientPatchResponse, error) { req, err := client.patchCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, options) if err != nil { return ClientPatchResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientPatchResponse{}, err } @@ -853,7 +855,7 @@ func (client *Client) patchCreateRequest(ctx context.Context, resourceGroupName return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -878,19 +880,20 @@ func (client *Client) patchHandleResponse(resp *http.Response) (ClientPatchRespo // RegenerateKeys - Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// notificationHubName - The notification hub name. -// authorizationRuleName - The connection string of the NotificationHub for the specified authorizationRule. -// parameters - Parameters supplied to regenerate the NotificationHub Authorization Rule Key. -// options - ClientRegenerateKeysOptions contains the optional parameters for the Client.RegenerateKeys method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - notificationHubName - The notification hub name. +// - authorizationRuleName - The connection string of the NotificationHub for the specified authorizationRule. +// - parameters - Parameters supplied to regenerate the NotificationHub Authorization Rule Key. +// - options - ClientRegenerateKeysOptions contains the optional parameters for the Client.RegenerateKeys method. func (client *Client) RegenerateKeys(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, parameters PolicykeyResource, options *ClientRegenerateKeysOptions) (ClientRegenerateKeysResponse, error) { req, err := client.regenerateKeysCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, parameters, options) if err != nil { return ClientRegenerateKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientRegenerateKeysResponse{}, err } @@ -923,7 +926,7 @@ func (client *Client) regenerateKeysCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/client_example_test.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/client_example_test.go new file mode 100644 index 000000000000..d4404623f127 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/client_example_test.go @@ -0,0 +1,473 @@ +//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 armnotificationhubs_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/notificationhubs/armnotificationhubs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubCheckNameAvailability.json +func ExampleClient_CheckNotificationHubAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewClient().CheckNotificationHubAvailability(ctx, "5ktrial", "locp-newns", armnotificationhubs.CheckAvailabilityParameters{ + Name: to.Ptr("sdktest"), + Location: to.Ptr("West Europe"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CheckAvailabilityResult = armnotificationhubs.CheckAvailabilityResult{ + // Name: to.Ptr("sdktest"), + // Type: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs/checkNotificationHubAvailability"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourcegroups/5ktrial/providers/Microsoft.NotificationHubs/namespaces/locp-newns/CheckNotificationHubAvailability"), + // Location: to.Ptr("West Europe"), + // IsAvailiable: to.Ptr(true), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubCreate.json +func ExampleClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewClient().CreateOrUpdate(ctx, "5ktrial", "nh-sdk-ns", "nh-sdk-hub", armnotificationhubs.NotificationHubCreateOrUpdateParameters{ + Location: to.Ptr("eastus"), + Properties: &armnotificationhubs.NotificationHubProperties{}, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.NotificationHubResource = armnotificationhubs.NotificationHubResource{ + // Name: to.Ptr("nh-sdk-hub"), + // Type: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/sdkresourceGroup/providers/Microsoft.NotificationHubs/namespaces/nh-sdk-ns/notificationHubs/nh-sdk-hub"), + // Location: to.Ptr("eastus"), + // Properties: &armnotificationhubs.NotificationHubProperties{ + // AuthorizationRules: []*armnotificationhubs.SharedAccessAuthorizationRuleProperties{ + // }, + // RegistrationTTL: to.Ptr("10675199.02:48:05.4775807"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubPatch.json +func ExampleClient_Patch() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewClient().Patch(ctx, "sdkresourceGroup", "nh-sdk-ns", "sdk-notificationHubs-8708", &armnotificationhubs.ClientPatchOptions{Parameters: &armnotificationhubs.NotificationHubPatchParameters{}}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.NotificationHubResource = armnotificationhubs.NotificationHubResource{ + // Name: to.Ptr("nh-sdk-hub"), + // Type: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/sdkresourceGroup/providers/Microsoft.NotificationHubs/namespaces/nh-sdk-ns/notificationHubs/nh-sdk-hub"), + // Location: to.Ptr("South Central US"), + // Properties: &armnotificationhubs.NotificationHubProperties{ + // AuthorizationRules: []*armnotificationhubs.SharedAccessAuthorizationRuleProperties{ + // }, + // RegistrationTTL: to.Ptr("10675199.02:48:05.4775807"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubDelete.json +func ExampleClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewClient().Delete(ctx, "5ktrial", "nh-sdk-ns", "nh-sdk-hub", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubGet.json +func ExampleClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewClient().Get(ctx, "5ktrial", "nh-sdk-ns", "nh-sdk-hub", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.NotificationHubResource = armnotificationhubs.NotificationHubResource{ + // Name: to.Ptr("nh-sdk-hub"), + // Type: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/sdkresourceGroup/providers/Microsoft.NotificationHubs/namespaces/nh-sdk-ns/notificationHubs/nh-sdk-hub"), + // Location: to.Ptr("South Central US"), + // Properties: &armnotificationhubs.NotificationHubProperties{ + // AuthorizationRules: []*armnotificationhubs.SharedAccessAuthorizationRuleProperties{ + // }, + // RegistrationTTL: to.Ptr("10675199.02:48:05.4775807"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubDebugSend.json +func ExampleClient_DebugSend() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewClient().DebugSend(ctx, "5ktrial", "nh-sdk-ns", "nh-sdk-hub", &armnotificationhubs.ClientDebugSendOptions{Parameters: map[string]any{ + "data": map[string]any{ + "message": "Hello", + }, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleCreate.json +func ExampleClient_CreateOrUpdateAuthorizationRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewClient().CreateOrUpdateAuthorizationRule(ctx, "5ktrial", "nh-sdk-ns", "nh-sdk-hub", "DefaultListenSharedAccessSignature", armnotificationhubs.SharedAccessAuthorizationRuleCreateOrUpdateParameters{ + Properties: &armnotificationhubs.SharedAccessAuthorizationRuleProperties{ + Rights: []*armnotificationhubs.AccessRights{ + to.Ptr(armnotificationhubs.AccessRightsListen), + to.Ptr(armnotificationhubs.AccessRightsSend)}, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SharedAccessAuthorizationRuleResource = armnotificationhubs.SharedAccessAuthorizationRuleResource{ + // Name: to.Ptr("DefaultListenSharedAccessSignature"), + // Type: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs/authorizationRules"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/5ktrial/providers/Microsoft.NotificationHubs/namespaces/nh-sdk-ns/NotificationHubs/nh-sdk-hub/AuthorizationRules/DefaultListenSharedAccessSignature"), + // Location: to.Ptr("West Europe"), + // Properties: &armnotificationhubs.SharedAccessAuthorizationRuleProperties{ + // ClaimType: to.Ptr("SharedAccessKey"), + // ClaimValue: to.Ptr("None"), + // CreatedTime: to.Ptr("2018-05-02T00:45:22.0150024Z"), + // KeyName: to.Ptr("DefaultListenSharedAccessSignature"), + // ModifiedTime: to.Ptr("2018-05-02T00:45:22.0150024Z"), + // PrimaryKey: to.Ptr("#################################"), + // Rights: []*armnotificationhubs.AccessRights{ + // to.Ptr(armnotificationhubs.AccessRightsListen)}, + // SecondaryKey: to.Ptr("#################################"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleDelete.json +func ExampleClient_DeleteAuthorizationRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewClient().DeleteAuthorizationRule(ctx, "5ktrial", "nh-sdk-ns", "nh-sdk-hub", "DefaultListenSharedAccessSignature", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleGet.json +func ExampleClient_GetAuthorizationRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewClient().GetAuthorizationRule(ctx, "5ktrial", "nh-sdk-ns", "nh-sdk-hub", "DefaultListenSharedAccessSignature", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SharedAccessAuthorizationRuleResource = armnotificationhubs.SharedAccessAuthorizationRuleResource{ + // Name: to.Ptr("DefaultListenSharedAccessSignature"), + // Type: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs/authorizationRules"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/5ktrial/providers/Microsoft.NotificationHubs/namespaces/nh-sdk-ns/NotificationHubs/nh-sdk-hub/AuthorizationRules/DefaultListenSharedAccessSignature"), + // Location: to.Ptr("West Europe"), + // Properties: &armnotificationhubs.SharedAccessAuthorizationRuleProperties{ + // ClaimType: to.Ptr("SharedAccessKey"), + // ClaimValue: to.Ptr("None"), + // CreatedTime: to.Ptr("2018-05-02T00:45:22.0150024Z"), + // KeyName: to.Ptr("DefaultListenSharedAccessSignature"), + // ModifiedTime: to.Ptr("2018-05-02T00:45:22.0150024Z"), + // PrimaryKey: to.Ptr("#################################"), + // Rights: []*armnotificationhubs.AccessRights{ + // to.Ptr(armnotificationhubs.AccessRightsListen)}, + // SecondaryKey: to.Ptr("#################################"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubListByNameSpace.json +func ExampleClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewClient().NewListPager("5ktrial", "nh-sdk-ns", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.NotificationHubListResult = armnotificationhubs.NotificationHubListResult{ + // Value: []*armnotificationhubs.NotificationHubResource{ + // { + // Name: to.Ptr("nh-sdk-hub"), + // Type: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/5ktrial/providers/Microsoft.NotificationHubs/namespaces/nh-sdk-ns/NotificationHubs/nh-sdk-hub"), + // Location: to.Ptr("South Central US"), + // Properties: &armnotificationhubs.NotificationHubProperties{ + // AuthorizationRules: []*armnotificationhubs.SharedAccessAuthorizationRuleProperties{ + // }, + // RegistrationTTL: to.Ptr("10675199.02:48:05.4775807"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleListAll.json +func ExampleClient_NewListAuthorizationRulesPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewClient().NewListAuthorizationRulesPager("5ktrial", "nh-sdk-ns", "nh-sdk-hub", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SharedAccessAuthorizationRuleListResult = armnotificationhubs.SharedAccessAuthorizationRuleListResult{ + // Value: []*armnotificationhubs.SharedAccessAuthorizationRuleResource{ + // { + // Name: to.Ptr("DefaultListenSharedAccessSignature"), + // Type: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs/authorizationRules"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/5ktrial/providers/Microsoft.NotificationHubs/namespaces/nh-sdk-ns/NotificationHubs/nh-sdk-hub/AuthorizationRules/DefaultListenSharedAccessSignature"), + // Location: to.Ptr("West Europe"), + // Properties: &armnotificationhubs.SharedAccessAuthorizationRuleProperties{ + // ClaimType: to.Ptr("SharedAccessKey"), + // ClaimValue: to.Ptr("None"), + // CreatedTime: to.Ptr("2018-05-02T00:45:22.0150024Z"), + // KeyName: to.Ptr("DefaultListenSharedAccessSignature"), + // ModifiedTime: to.Ptr("2018-05-02T00:45:22.0150024Z"), + // PrimaryKey: to.Ptr("#################################"), + // Rights: []*armnotificationhubs.AccessRights{ + // to.Ptr(armnotificationhubs.AccessRightsListen)}, + // SecondaryKey: to.Ptr("#################################"), + // }, + // }, + // { + // Name: to.Ptr("DefaultFullSharedAccessSignature"), + // Type: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs/authorizationRules"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/5ktrial/providers/Microsoft.NotificationHubs/namespaces/nh-sdk-ns/NotificationHubs/nh-sdk-hub/AuthorizationRules/DefaultFullSharedAccessSignature"), + // Location: to.Ptr("West Europe"), + // Properties: &armnotificationhubs.SharedAccessAuthorizationRuleProperties{ + // ClaimType: to.Ptr("SharedAccessKey"), + // ClaimValue: to.Ptr("None"), + // CreatedTime: to.Ptr("2018-05-02T00:45:22.0150024Z"), + // KeyName: to.Ptr("DefaultFullSharedAccessSignature"), + // ModifiedTime: to.Ptr("2018-05-02T00:45:22.0150024Z"), + // PrimaryKey: to.Ptr("#################################"), + // Rights: []*armnotificationhubs.AccessRights{ + // to.Ptr(armnotificationhubs.AccessRightsListen), + // to.Ptr(armnotificationhubs.AccessRightsManage), + // to.Ptr(armnotificationhubs.AccessRightsSend)}, + // SecondaryKey: to.Ptr("#################################"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleListKey.json +func ExampleClient_ListKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewClient().ListKeys(ctx, "5ktrial", "nh-sdk-ns", "nh-sdk-hub", "sdk-AuthRules-5800", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ResourceListKeys = armnotificationhubs.ResourceListKeys{ + // KeyName: to.Ptr("sdk-AuthRules-5800"), + // PrimaryConnectionString: to.Ptr("Endpoint=sb://sdk-namespace-7982.servicebus.windows-int.net/;SharedAccessKeyName=sdk-AuthRules-5800;SharedAccessKey=############################################;EntityPath=sdk-notificationHubs-2317"), + // PrimaryKey: to.Ptr("############################################"), + // SecondaryConnectionString: to.Ptr("Endpoint=sb://sdk-namespace-7982.servicebus.windows-int.net/;SharedAccessKeyName=sdk-AuthRules-5800;SharedAccessKey=############################################;EntityPath=sdk-notificationHubs-2317"), + // SecondaryKey: to.Ptr("############################################"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleRegenrateKey.json +func ExampleClient_RegenerateKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewClient().RegenerateKeys(ctx, "5ktrial", "nh-sdk-ns", "nh-sdk-hub", "DefaultListenSharedAccessSignature", armnotificationhubs.PolicykeyResource{ + PolicyKey: to.Ptr("PrimaryKey"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ResourceListKeys = armnotificationhubs.ResourceListKeys{ + // KeyName: to.Ptr("DefaultListenSharedAccessSignature"), + // PrimaryConnectionString: to.Ptr("Endpoint=sb://nh-sdk-ns.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=#################################"), + // PrimaryKey: to.Ptr("#################################"), + // SecondaryConnectionString: to.Ptr("Endpoint=sb://nh-sdk-ns.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=#################################"), + // SecondaryKey: to.Ptr("#################################"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubPnsCredentials.json +func ExampleClient_GetPnsCredentials() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewClient().GetPnsCredentials(ctx, "5ktrial", "nh-sdk-ns", "nh-sdk-hub", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PnsCredentialsResource = armnotificationhubs.PnsCredentialsResource{ + // Name: to.Ptr("nh-sdk-hub"), + // Type: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs/pnsCredentials"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/5ktrial/providers/Microsoft.NotificationHubs/namespaces/nh-sdk-ns/notificationHubs/nh-sdk-hub/pnsCredentials"), + // Location: to.Ptr("West Europe"), + // Properties: &armnotificationhubs.PnsCredentialsProperties{ + // MpnsCredential: &armnotificationhubs.MpnsCredential{ + // Properties: &armnotificationhubs.MpnsCredentialProperties{ + // Thumbprint: to.Ptr("#################################"), + // }, + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/client_factory.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/client_factory.go new file mode 100644 index 000000000000..51d2a04d9794 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/client_factory.go @@ -0,0 +1,55 @@ +//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 armnotificationhubs + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID +// forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewNamespacesClient() *NamespacesClient { + subClient, _ := NewNamespacesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewClient() *Client { + subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_constants.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/constants.go similarity index 97% rename from sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_constants.go rename to sdk/resourcemanager/notificationhubs/armnotificationhubs/constants.go index 589e61f25161..c48f90aae498 100644 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_constants.go +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/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 armnotificationhubs const ( moduleName = "armnotificationhubs" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) type AccessRights string diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/go.mod b/sdk/resourcemanager/notificationhubs/armnotificationhubs/go.mod index fe9b6b3953c3..9f8f2f1d85fc 100644 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/go.mod +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/notificationhubs/ar go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) 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/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/go.sum b/sdk/resourcemanager/notificationhubs/armnotificationhubs/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/go.sum +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= 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/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_models.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/models.go similarity index 98% rename from sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_models.go rename to sdk/resourcemanager/notificationhubs/armnotificationhubs/models.go index 5bb6c132a83c..7c9aacbe3e5a 100644 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_models.go +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/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 armnotificationhubs @@ -153,7 +154,7 @@ type ClientCreateOrUpdateOptions struct { // ClientDebugSendOptions contains the optional parameters for the Client.DebugSend method. type ClientDebugSendOptions struct { // Debug send parameters - Parameters interface{} + Parameters any } // ClientDeleteAuthorizationRuleOptions contains the optional parameters for the Client.DeleteAuthorizationRule method. @@ -181,7 +182,7 @@ type ClientGetPnsCredentialsOptions struct { // placeholder for future optional parameters } -// ClientListAuthorizationRulesOptions contains the optional parameters for the Client.ListAuthorizationRules method. +// ClientListAuthorizationRulesOptions contains the optional parameters for the Client.NewListAuthorizationRulesPager method. type ClientListAuthorizationRulesOptions struct { // placeholder for future optional parameters } @@ -191,7 +192,7 @@ type ClientListKeysOptions struct { // placeholder for future optional parameters } -// ClientListOptions contains the optional parameters for the Client.List method. +// ClientListOptions contains the optional parameters for the Client.NewListPager method. type ClientListOptions struct { // placeholder for future optional parameters } @@ -236,7 +237,7 @@ type DebugSendResult struct { Failure *float32 `json:"failure,omitempty"` // actual failure description - Results interface{} `json:"results,omitempty"` + Results any `json:"results,omitempty"` // successful send Success *float32 `json:"success,omitempty"` @@ -437,12 +438,12 @@ type NamespacesClientGetOptions struct { // placeholder for future optional parameters } -// NamespacesClientListAllOptions contains the optional parameters for the NamespacesClient.ListAll method. +// NamespacesClientListAllOptions contains the optional parameters for the NamespacesClient.NewListAllPager method. type NamespacesClientListAllOptions struct { // placeholder for future optional parameters } -// NamespacesClientListAuthorizationRulesOptions contains the optional parameters for the NamespacesClient.ListAuthorizationRules +// NamespacesClientListAuthorizationRulesOptions contains the optional parameters for the NamespacesClient.NewListAuthorizationRulesPager // method. type NamespacesClientListAuthorizationRulesOptions struct { // placeholder for future optional parameters @@ -453,7 +454,7 @@ type NamespacesClientListKeysOptions struct { // placeholder for future optional parameters } -// NamespacesClientListOptions contains the optional parameters for the NamespacesClient.List method. +// NamespacesClientListOptions contains the optional parameters for the NamespacesClient.NewListPager method. type NamespacesClientListOptions struct { // placeholder for future optional parameters } @@ -610,7 +611,7 @@ type OperationListResult struct { Value []*Operation `json:"value,omitempty" azure:"ro"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/models_serde.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/models_serde.go new file mode 100644 index 000000000000..6091d485a006 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/models_serde.go @@ -0,0 +1,1680 @@ +//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 armnotificationhubs + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AdmCredential. +func (a AdmCredential) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AdmCredential. +func (a *AdmCredential) 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 "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AdmCredentialProperties. +func (a AdmCredentialProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authTokenUrl", a.AuthTokenURL) + populate(objectMap, "clientId", a.ClientID) + populate(objectMap, "clientSecret", a.ClientSecret) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AdmCredentialProperties. +func (a *AdmCredentialProperties) 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 "authTokenUrl": + err = unpopulate(val, "AuthTokenURL", &a.AuthTokenURL) + delete(rawMsg, key) + case "clientId": + err = unpopulate(val, "ClientID", &a.ClientID) + delete(rawMsg, key) + case "clientSecret": + err = unpopulate(val, "ClientSecret", &a.ClientSecret) + 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 ApnsCredential. +func (a ApnsCredential) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApnsCredential. +func (a *ApnsCredential) 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 "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ApnsCredentialProperties. +func (a ApnsCredentialProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "apnsCertificate", a.ApnsCertificate) + populate(objectMap, "appId", a.AppID) + populate(objectMap, "appName", a.AppName) + populate(objectMap, "certificateKey", a.CertificateKey) + populate(objectMap, "endpoint", a.Endpoint) + populate(objectMap, "keyId", a.KeyID) + populate(objectMap, "thumbprint", a.Thumbprint) + populate(objectMap, "token", a.Token) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApnsCredentialProperties. +func (a *ApnsCredentialProperties) 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 "apnsCertificate": + err = unpopulate(val, "ApnsCertificate", &a.ApnsCertificate) + delete(rawMsg, key) + case "appId": + err = unpopulate(val, "AppID", &a.AppID) + delete(rawMsg, key) + case "appName": + err = unpopulate(val, "AppName", &a.AppName) + delete(rawMsg, key) + case "certificateKey": + err = unpopulate(val, "CertificateKey", &a.CertificateKey) + delete(rawMsg, key) + case "endpoint": + err = unpopulate(val, "Endpoint", &a.Endpoint) + delete(rawMsg, key) + case "keyId": + err = unpopulate(val, "KeyID", &a.KeyID) + delete(rawMsg, key) + case "thumbprint": + err = unpopulate(val, "Thumbprint", &a.Thumbprint) + delete(rawMsg, key) + case "token": + err = unpopulate(val, "Token", &a.Token) + 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 BaiduCredential. +func (b BaiduCredential) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", b.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BaiduCredential. +func (b *BaiduCredential) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &b.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BaiduCredentialProperties. +func (b BaiduCredentialProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "baiduApiKey", b.BaiduAPIKey) + populate(objectMap, "baiduEndPoint", b.BaiduEndPoint) + populate(objectMap, "baiduSecretKey", b.BaiduSecretKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BaiduCredentialProperties. +func (b *BaiduCredentialProperties) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "baiduApiKey": + err = unpopulate(val, "BaiduAPIKey", &b.BaiduAPIKey) + delete(rawMsg, key) + case "baiduEndPoint": + err = unpopulate(val, "BaiduEndPoint", &b.BaiduEndPoint) + delete(rawMsg, key) + case "baiduSecretKey": + err = unpopulate(val, "BaiduSecretKey", &b.BaiduSecretKey) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CheckAvailabilityParameters. +func (c CheckAvailabilityParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "isAvailiable", c.IsAvailiable) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "sku", c.SKU) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckAvailabilityParameters. +func (c *CheckAvailabilityParameters) 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 "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "isAvailiable": + err = unpopulate(val, "IsAvailiable", &c.IsAvailiable) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &c.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + 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 CheckAvailabilityResult. +func (c CheckAvailabilityResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "isAvailiable", c.IsAvailiable) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "sku", c.SKU) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckAvailabilityResult. +func (c *CheckAvailabilityResult) 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 "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "isAvailiable": + err = unpopulate(val, "IsAvailiable", &c.IsAvailiable) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &c.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + 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 DebugSendResponse. +func (d DebugSendResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "sku", d.SKU) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DebugSendResponse. +func (d *DebugSendResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &d.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DebugSendResult. +func (d DebugSendResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "failure", d.Failure) + populate(objectMap, "results", &d.Results) + populate(objectMap, "success", d.Success) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DebugSendResult. +func (d *DebugSendResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "failure": + err = unpopulate(val, "Failure", &d.Failure) + delete(rawMsg, key) + case "results": + err = unpopulate(val, "Results", &d.Results) + delete(rawMsg, key) + case "success": + err = unpopulate(val, "Success", &d.Success) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", e.Code) + populate(objectMap, "message", e.Message) + 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 "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + 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 GCMCredential. +func (g GCMCredential) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", g.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GCMCredential. +func (g *GCMCredential) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GCMCredentialProperties. +func (g GCMCredentialProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "gcmEndpoint", g.GCMEndpoint) + populate(objectMap, "googleApiKey", g.GoogleAPIKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GCMCredentialProperties. +func (g *GCMCredentialProperties) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "gcmEndpoint": + err = unpopulate(val, "GCMEndpoint", &g.GCMEndpoint) + delete(rawMsg, key) + case "googleApiKey": + err = unpopulate(val, "GoogleAPIKey", &g.GoogleAPIKey) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MpnsCredential. +func (m MpnsCredential) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", m.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MpnsCredential. +func (m *MpnsCredential) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &m.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MpnsCredentialProperties. +func (m MpnsCredentialProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "certificateKey", m.CertificateKey) + populate(objectMap, "mpnsCertificate", m.MpnsCertificate) + populate(objectMap, "thumbprint", m.Thumbprint) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MpnsCredentialProperties. +func (m *MpnsCredentialProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "certificateKey": + err = unpopulate(val, "CertificateKey", &m.CertificateKey) + delete(rawMsg, key) + case "mpnsCertificate": + err = unpopulate(val, "MpnsCertificate", &m.MpnsCertificate) + delete(rawMsg, key) + case "thumbprint": + err = unpopulate(val, "Thumbprint", &m.Thumbprint) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NamespaceCreateOrUpdateParameters. +func (n NamespaceCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", n.ID) + populate(objectMap, "location", n.Location) + populate(objectMap, "name", n.Name) + populate(objectMap, "properties", n.Properties) + populate(objectMap, "sku", n.SKU) + populate(objectMap, "tags", n.Tags) + populate(objectMap, "type", n.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NamespaceCreateOrUpdateParameters. +func (n *NamespaceCreateOrUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &n.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &n.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &n.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &n.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &n.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &n.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NamespaceListResult. +func (n NamespaceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", n.NextLink) + populate(objectMap, "value", n.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NamespaceListResult. +func (n *NamespaceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &n.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &n.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NamespacePatchParameters. +func (n NamespacePatchParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sku", n.SKU) + populate(objectMap, "tags", n.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NamespacePatchParameters. +func (n *NamespacePatchParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "sku": + err = unpopulate(val, "SKU", &n.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &n.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NamespaceProperties. +func (n NamespaceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", n.CreatedAt) + populate(objectMap, "critical", n.Critical) + populate(objectMap, "dataCenter", n.DataCenter) + populate(objectMap, "enabled", n.Enabled) + populate(objectMap, "metricId", n.MetricID) + populate(objectMap, "name", n.Name) + populate(objectMap, "namespaceType", n.NamespaceType) + populate(objectMap, "provisioningState", n.ProvisioningState) + populate(objectMap, "region", n.Region) + populate(objectMap, "scaleUnit", n.ScaleUnit) + populate(objectMap, "serviceBusEndpoint", n.ServiceBusEndpoint) + populate(objectMap, "status", n.Status) + populate(objectMap, "subscriptionId", n.SubscriptionID) + populateTimeRFC3339(objectMap, "updatedAt", n.UpdatedAt) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NamespaceProperties. +func (n *NamespaceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &n.CreatedAt) + delete(rawMsg, key) + case "critical": + err = unpopulate(val, "Critical", &n.Critical) + delete(rawMsg, key) + case "dataCenter": + err = unpopulate(val, "DataCenter", &n.DataCenter) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, "Enabled", &n.Enabled) + delete(rawMsg, key) + case "metricId": + err = unpopulate(val, "MetricID", &n.MetricID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "namespaceType": + err = unpopulate(val, "NamespaceType", &n.NamespaceType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &n.ProvisioningState) + delete(rawMsg, key) + case "region": + err = unpopulate(val, "Region", &n.Region) + delete(rawMsg, key) + case "scaleUnit": + err = unpopulate(val, "ScaleUnit", &n.ScaleUnit) + delete(rawMsg, key) + case "serviceBusEndpoint": + err = unpopulate(val, "ServiceBusEndpoint", &n.ServiceBusEndpoint) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &n.Status) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &n.SubscriptionID) + delete(rawMsg, key) + case "updatedAt": + err = unpopulateTimeRFC3339(val, "UpdatedAt", &n.UpdatedAt) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NamespaceResource. +func (n NamespaceResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", n.ID) + populate(objectMap, "location", n.Location) + populate(objectMap, "name", n.Name) + populate(objectMap, "properties", n.Properties) + populate(objectMap, "sku", n.SKU) + populate(objectMap, "tags", n.Tags) + populate(objectMap, "type", n.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NamespaceResource. +func (n *NamespaceResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &n.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &n.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &n.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &n.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &n.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &n.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NotificationHubCreateOrUpdateParameters. +func (n NotificationHubCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", n.ID) + populate(objectMap, "location", n.Location) + populate(objectMap, "name", n.Name) + populate(objectMap, "properties", n.Properties) + populate(objectMap, "sku", n.SKU) + populate(objectMap, "tags", n.Tags) + populate(objectMap, "type", n.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NotificationHubCreateOrUpdateParameters. +func (n *NotificationHubCreateOrUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &n.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &n.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &n.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &n.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &n.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &n.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NotificationHubListResult. +func (n NotificationHubListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", n.NextLink) + populate(objectMap, "value", n.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NotificationHubListResult. +func (n *NotificationHubListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &n.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &n.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NotificationHubPatchParameters. +func (n NotificationHubPatchParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", n.ID) + populate(objectMap, "location", n.Location) + populate(objectMap, "name", n.Name) + populate(objectMap, "properties", n.Properties) + populate(objectMap, "sku", n.SKU) + populate(objectMap, "tags", n.Tags) + populate(objectMap, "type", n.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NotificationHubPatchParameters. +func (n *NotificationHubPatchParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &n.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &n.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &n.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &n.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &n.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &n.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NotificationHubProperties. +func (n NotificationHubProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "admCredential", n.AdmCredential) + populate(objectMap, "apnsCredential", n.ApnsCredential) + populate(objectMap, "authorizationRules", n.AuthorizationRules) + populate(objectMap, "baiduCredential", n.BaiduCredential) + populate(objectMap, "gcmCredential", n.GCMCredential) + populate(objectMap, "mpnsCredential", n.MpnsCredential) + populate(objectMap, "name", n.Name) + populate(objectMap, "registrationTtl", n.RegistrationTTL) + populate(objectMap, "wnsCredential", n.WnsCredential) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NotificationHubProperties. +func (n *NotificationHubProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "admCredential": + err = unpopulate(val, "AdmCredential", &n.AdmCredential) + delete(rawMsg, key) + case "apnsCredential": + err = unpopulate(val, "ApnsCredential", &n.ApnsCredential) + delete(rawMsg, key) + case "authorizationRules": + err = unpopulate(val, "AuthorizationRules", &n.AuthorizationRules) + delete(rawMsg, key) + case "baiduCredential": + err = unpopulate(val, "BaiduCredential", &n.BaiduCredential) + delete(rawMsg, key) + case "gcmCredential": + err = unpopulate(val, "GCMCredential", &n.GCMCredential) + delete(rawMsg, key) + case "mpnsCredential": + err = unpopulate(val, "MpnsCredential", &n.MpnsCredential) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "registrationTtl": + err = unpopulate(val, "RegistrationTTL", &n.RegistrationTTL) + delete(rawMsg, key) + case "wnsCredential": + err = unpopulate(val, "WnsCredential", &n.WnsCredential) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NotificationHubResource. +func (n NotificationHubResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", n.ID) + populate(objectMap, "location", n.Location) + populate(objectMap, "name", n.Name) + populate(objectMap, "properties", n.Properties) + populate(objectMap, "sku", n.SKU) + populate(objectMap, "tags", n.Tags) + populate(objectMap, "type", n.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NotificationHubResource. +func (n *NotificationHubResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &n.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &n.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &n.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &n.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &n.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &n.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PnsCredentialsProperties. +func (p PnsCredentialsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "admCredential", p.AdmCredential) + populate(objectMap, "apnsCredential", p.ApnsCredential) + populate(objectMap, "baiduCredential", p.BaiduCredential) + populate(objectMap, "gcmCredential", p.GCMCredential) + populate(objectMap, "mpnsCredential", p.MpnsCredential) + populate(objectMap, "wnsCredential", p.WnsCredential) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PnsCredentialsProperties. +func (p *PnsCredentialsProperties) 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 "admCredential": + err = unpopulate(val, "AdmCredential", &p.AdmCredential) + delete(rawMsg, key) + case "apnsCredential": + err = unpopulate(val, "ApnsCredential", &p.ApnsCredential) + delete(rawMsg, key) + case "baiduCredential": + err = unpopulate(val, "BaiduCredential", &p.BaiduCredential) + delete(rawMsg, key) + case "gcmCredential": + err = unpopulate(val, "GCMCredential", &p.GCMCredential) + delete(rawMsg, key) + case "mpnsCredential": + err = unpopulate(val, "MpnsCredential", &p.MpnsCredential) + delete(rawMsg, key) + case "wnsCredential": + err = unpopulate(val, "WnsCredential", &p.WnsCredential) + 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 PnsCredentialsResource. +func (p PnsCredentialsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "sku", p.SKU) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PnsCredentialsResource. +func (p *PnsCredentialsResource) 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 "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &p.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + 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 PolicykeyResource. +func (p PolicykeyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "policyKey", p.PolicyKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicykeyResource. +func (p *PolicykeyResource) 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 "policyKey": + err = unpopulate(val, "PolicyKey", &p.PolicyKey) + 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]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "sku", r.SKU) + populate(objectMap, "tags", r.Tags) + 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 "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &r.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + 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 ResourceListKeys. +func (r ResourceListKeys) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "keyName", r.KeyName) + populate(objectMap, "primaryConnectionString", r.PrimaryConnectionString) + populate(objectMap, "primaryKey", r.PrimaryKey) + populate(objectMap, "secondaryConnectionString", r.SecondaryConnectionString) + populate(objectMap, "secondaryKey", r.SecondaryKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceListKeys. +func (r *ResourceListKeys) 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 "keyName": + err = unpopulate(val, "KeyName", &r.KeyName) + delete(rawMsg, key) + case "primaryConnectionString": + err = unpopulate(val, "PrimaryConnectionString", &r.PrimaryConnectionString) + delete(rawMsg, key) + case "primaryKey": + err = unpopulate(val, "PrimaryKey", &r.PrimaryKey) + delete(rawMsg, key) + case "secondaryConnectionString": + err = unpopulate(val, "SecondaryConnectionString", &r.SecondaryConnectionString) + delete(rawMsg, key) + case "secondaryKey": + err = unpopulate(val, "SecondaryKey", &r.SecondaryKey) + 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 SKU. +func (s SKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacity", s.Capacity) + populate(objectMap, "family", s.Family) + populate(objectMap, "name", s.Name) + populate(objectMap, "size", s.Size) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKU. +func (s *SKU) 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 "capacity": + err = unpopulate(val, "Capacity", &s.Capacity) + delete(rawMsg, key) + case "family": + err = unpopulate(val, "Family", &s.Family) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "size": + err = unpopulate(val, "Size", &s.Size) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &s.Tier) + 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 SharedAccessAuthorizationRuleCreateOrUpdateParameters. +func (s SharedAccessAuthorizationRuleCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SharedAccessAuthorizationRuleCreateOrUpdateParameters. +func (s *SharedAccessAuthorizationRuleCreateOrUpdateParameters) 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 "properties": + err = unpopulate(val, "Properties", &s.Properties) + 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 SharedAccessAuthorizationRuleListResult. +func (s SharedAccessAuthorizationRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SharedAccessAuthorizationRuleListResult. +func (s *SharedAccessAuthorizationRuleListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SharedAccessAuthorizationRuleProperties. +func (s SharedAccessAuthorizationRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "claimType", s.ClaimType) + populate(objectMap, "claimValue", s.ClaimValue) + populate(objectMap, "createdTime", s.CreatedTime) + populate(objectMap, "keyName", s.KeyName) + populate(objectMap, "modifiedTime", s.ModifiedTime) + populate(objectMap, "primaryKey", s.PrimaryKey) + populate(objectMap, "revision", s.Revision) + populate(objectMap, "rights", s.Rights) + populate(objectMap, "secondaryKey", s.SecondaryKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SharedAccessAuthorizationRuleProperties. +func (s *SharedAccessAuthorizationRuleProperties) 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 "claimType": + err = unpopulate(val, "ClaimType", &s.ClaimType) + delete(rawMsg, key) + case "claimValue": + err = unpopulate(val, "ClaimValue", &s.ClaimValue) + delete(rawMsg, key) + case "createdTime": + err = unpopulate(val, "CreatedTime", &s.CreatedTime) + delete(rawMsg, key) + case "keyName": + err = unpopulate(val, "KeyName", &s.KeyName) + delete(rawMsg, key) + case "modifiedTime": + err = unpopulate(val, "ModifiedTime", &s.ModifiedTime) + delete(rawMsg, key) + case "primaryKey": + err = unpopulate(val, "PrimaryKey", &s.PrimaryKey) + delete(rawMsg, key) + case "revision": + err = unpopulate(val, "Revision", &s.Revision) + delete(rawMsg, key) + case "rights": + err = unpopulate(val, "Rights", &s.Rights) + delete(rawMsg, key) + case "secondaryKey": + err = unpopulate(val, "SecondaryKey", &s.SecondaryKey) + 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 SharedAccessAuthorizationRuleResource. +func (s SharedAccessAuthorizationRuleResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "location", s.Location) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SharedAccessAuthorizationRuleResource. +func (s *SharedAccessAuthorizationRuleResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubResource. +func (s SubResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubResource. +func (s *SubResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WnsCredential. +func (w WnsCredential) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", w.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WnsCredential. +func (w *WnsCredential) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &w.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WnsCredentialProperties. +func (w WnsCredentialProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "packageSid", w.PackageSid) + populate(objectMap, "secretKey", w.SecretKey) + populate(objectMap, "windowsLiveEndpoint", w.WindowsLiveEndpoint) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WnsCredentialProperties. +func (w *WnsCredentialProperties) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "packageSid": + err = unpopulate(val, "PackageSid", &w.PackageSid) + delete(rawMsg, key) + case "secretKey": + err = unpopulate(val, "SecretKey", &w.SecretKey) + delete(rawMsg, key) + case "windowsLiveEndpoint": + err = unpopulate(val, "WindowsLiveEndpoint", &w.WindowsLiveEndpoint) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_namespaces_client.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/namespaces_client.go similarity index 86% rename from sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_namespaces_client.go rename to sdk/resourcemanager/notificationhubs/armnotificationhubs/namespaces_client.go index 08c2d8fc6b31..b999ba208c4a 100644 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_namespaces_client.go +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/namespaces_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 armnotificationhubs @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,32 +24,23 @@ import ( // NamespacesClient contains the methods for the Namespaces group. // Don't use this type directly, use NewNamespacesClient() instead. type NamespacesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewNamespacesClient creates a new instance of NamespacesClient with the specified values. -// subscriptionID - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID -// forms part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID +// forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewNamespacesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*NamespacesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".NamespacesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &NamespacesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,16 +48,17 @@ func NewNamespacesClient(subscriptionID string, credential azcore.TokenCredentia // CheckAvailability - Checks the availability of the given service namespace across all Azure subscriptions. This is useful // because the domain name is created based on the service namespace name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// parameters - The namespace name. -// options - NamespacesClientCheckAvailabilityOptions contains the optional parameters for the NamespacesClient.CheckAvailability -// method. +// - parameters - The namespace name. +// - options - NamespacesClientCheckAvailabilityOptions contains the optional parameters for the NamespacesClient.CheckAvailability +// method. func (client *NamespacesClient) CheckAvailability(ctx context.Context, parameters CheckAvailabilityParameters, options *NamespacesClientCheckAvailabilityOptions) (NamespacesClientCheckAvailabilityResponse, error) { req, err := client.checkAvailabilityCreateRequest(ctx, parameters, options) if err != nil { return NamespacesClientCheckAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NamespacesClientCheckAvailabilityResponse{}, err } @@ -84,7 +75,7 @@ func (client *NamespacesClient) checkAvailabilityCreateRequest(ctx context.Conte return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -107,18 +98,19 @@ func (client *NamespacesClient) checkAvailabilityHandleResponse(resp *http.Respo // CreateOrUpdate - Creates/Updates a service namespace. Once created, this namespace's resource manifest is immutable. This // operation is idempotent. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// parameters - Parameters supplied to create a Namespace Resource. -// options - NamespacesClientCreateOrUpdateOptions contains the optional parameters for the NamespacesClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - parameters - Parameters supplied to create a Namespace Resource. +// - options - NamespacesClientCreateOrUpdateOptions contains the optional parameters for the NamespacesClient.CreateOrUpdate +// method. func (client *NamespacesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, namespaceName string, parameters NamespaceCreateOrUpdateParameters, options *NamespacesClientCreateOrUpdateOptions) (NamespacesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, namespaceName, parameters, options) if err != nil { return NamespacesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NamespacesClientCreateOrUpdateResponse{}, err } @@ -143,7 +135,7 @@ func (client *NamespacesClient) createOrUpdateCreateRequest(ctx context.Context, return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -165,19 +157,20 @@ func (client *NamespacesClient) createOrUpdateHandleResponse(resp *http.Response // CreateOrUpdateAuthorizationRule - Creates an authorization rule for a namespace // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// authorizationRuleName - Authorization Rule Name. -// parameters - The shared access authorization rule. -// options - NamespacesClientCreateOrUpdateAuthorizationRuleOptions contains the optional parameters for the NamespacesClient.CreateOrUpdateAuthorizationRule -// method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - authorizationRuleName - Authorization Rule Name. +// - parameters - The shared access authorization rule. +// - options - NamespacesClientCreateOrUpdateAuthorizationRuleOptions contains the optional parameters for the NamespacesClient.CreateOrUpdateAuthorizationRule +// method. func (client *NamespacesClient) CreateOrUpdateAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters, options *NamespacesClientCreateOrUpdateAuthorizationRuleOptions) (NamespacesClientCreateOrUpdateAuthorizationRuleResponse, error) { req, err := client.createOrUpdateAuthorizationRuleCreateRequest(ctx, resourceGroupName, namespaceName, authorizationRuleName, parameters, options) if err != nil { return NamespacesClientCreateOrUpdateAuthorizationRuleResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NamespacesClientCreateOrUpdateAuthorizationRuleResponse{}, err } @@ -206,7 +199,7 @@ func (client *NamespacesClient) createOrUpdateAuthorizationRuleCreateRequest(ctx return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -228,31 +221,33 @@ func (client *NamespacesClient) createOrUpdateAuthorizationRuleHandleResponse(re // BeginDelete - Deletes an existing namespace. This operation also removes all associated notificationHubs under the namespace. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// options - NamespacesClientBeginDeleteOptions contains the optional parameters for the NamespacesClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - options - NamespacesClientBeginDeleteOptions contains the optional parameters for the NamespacesClient.BeginDelete method. func (client *NamespacesClient) BeginDelete(ctx context.Context, resourceGroupName string, namespaceName string, options *NamespacesClientBeginDeleteOptions) (*runtime.Poller[NamespacesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, namespaceName, options) if err != nil { return nil, err } - return runtime.NewPoller[NamespacesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[NamespacesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[NamespacesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[NamespacesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes an existing namespace. This operation also removes all associated notificationHubs under the namespace. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 func (client *NamespacesClient) deleteOperation(ctx context.Context, resourceGroupName string, namespaceName string, options *NamespacesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, namespaceName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -277,7 +272,7 @@ func (client *NamespacesClient) deleteCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -289,18 +284,19 @@ func (client *NamespacesClient) deleteCreateRequest(ctx context.Context, resourc // DeleteAuthorizationRule - Deletes a namespace authorization rule // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// authorizationRuleName - Authorization Rule Name. -// options - NamespacesClientDeleteAuthorizationRuleOptions contains the optional parameters for the NamespacesClient.DeleteAuthorizationRule -// method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - authorizationRuleName - Authorization Rule Name. +// - options - NamespacesClientDeleteAuthorizationRuleOptions contains the optional parameters for the NamespacesClient.DeleteAuthorizationRule +// method. func (client *NamespacesClient) DeleteAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, options *NamespacesClientDeleteAuthorizationRuleOptions) (NamespacesClientDeleteAuthorizationRuleResponse, error) { req, err := client.deleteAuthorizationRuleCreateRequest(ctx, resourceGroupName, namespaceName, authorizationRuleName, options) if err != nil { return NamespacesClientDeleteAuthorizationRuleResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NamespacesClientDeleteAuthorizationRuleResponse{}, err } @@ -329,7 +325,7 @@ func (client *NamespacesClient) deleteAuthorizationRuleCreateRequest(ctx context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -341,16 +337,17 @@ func (client *NamespacesClient) deleteAuthorizationRuleCreateRequest(ctx context // Get - Returns the description for the specified namespace. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// options - NamespacesClientGetOptions contains the optional parameters for the NamespacesClient.Get method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - options - NamespacesClientGetOptions contains the optional parameters for the NamespacesClient.Get method. func (client *NamespacesClient) Get(ctx context.Context, resourceGroupName string, namespaceName string, options *NamespacesClientGetOptions) (NamespacesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, namespaceName, options) if err != nil { return NamespacesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NamespacesClientGetResponse{}, err } @@ -375,7 +372,7 @@ func (client *NamespacesClient) getCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -397,18 +394,19 @@ func (client *NamespacesClient) getHandleResponse(resp *http.Response) (Namespac // GetAuthorizationRule - Gets an authorization rule for a namespace by name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name -// authorizationRuleName - Authorization rule name. -// options - NamespacesClientGetAuthorizationRuleOptions contains the optional parameters for the NamespacesClient.GetAuthorizationRule -// method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name +// - authorizationRuleName - Authorization rule name. +// - options - NamespacesClientGetAuthorizationRuleOptions contains the optional parameters for the NamespacesClient.GetAuthorizationRule +// method. func (client *NamespacesClient) GetAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, options *NamespacesClientGetAuthorizationRuleOptions) (NamespacesClientGetAuthorizationRuleResponse, error) { req, err := client.getAuthorizationRuleCreateRequest(ctx, resourceGroupName, namespaceName, authorizationRuleName, options) if err != nil { return NamespacesClientGetAuthorizationRuleResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NamespacesClientGetAuthorizationRuleResponse{}, err } @@ -437,7 +435,7 @@ func (client *NamespacesClient) getAuthorizationRuleCreateRequest(ctx context.Co return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -458,11 +456,11 @@ func (client *NamespacesClient) getAuthorizationRuleHandleResponse(resp *http.Re } // NewListPager - Lists the available namespaces within a resourceGroup. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. If resourceGroupName value is null the method lists all the namespaces -// within subscription -// options - NamespacesClientListOptions contains the optional parameters for the NamespacesClient.List method. +// - resourceGroupName - The name of the resource group. If resourceGroupName value is null the method lists all the namespaces +// within subscription +// - options - NamespacesClientListOptions contains the optional parameters for the NamespacesClient.NewListPager method. func (client *NamespacesClient) NewListPager(resourceGroupName string, options *NamespacesClientListOptions) *runtime.Pager[NamespacesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[NamespacesClientListResponse]{ More: func(page NamespacesClientListResponse) bool { @@ -479,7 +477,7 @@ func (client *NamespacesClient) NewListPager(resourceGroupName string, options * if err != nil { return NamespacesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NamespacesClientListResponse{}, err } @@ -502,7 +500,7 @@ func (client *NamespacesClient) listCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -523,9 +521,9 @@ func (client *NamespacesClient) listHandleResponse(resp *http.Response) (Namespa } // NewListAllPager - Lists all the available namespaces within the subscription irrespective of the resourceGroups. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// options - NamespacesClientListAllOptions contains the optional parameters for the NamespacesClient.ListAll method. +// - options - NamespacesClientListAllOptions contains the optional parameters for the NamespacesClient.NewListAllPager method. func (client *NamespacesClient) NewListAllPager(options *NamespacesClientListAllOptions) *runtime.Pager[NamespacesClientListAllResponse] { return runtime.NewPager(runtime.PagingHandler[NamespacesClientListAllResponse]{ More: func(page NamespacesClientListAllResponse) bool { @@ -542,7 +540,7 @@ func (client *NamespacesClient) NewListAllPager(options *NamespacesClientListAll if err != nil { return NamespacesClientListAllResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NamespacesClientListAllResponse{}, err } @@ -561,7 +559,7 @@ func (client *NamespacesClient) listAllCreateRequest(ctx context.Context, option return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -582,12 +580,12 @@ func (client *NamespacesClient) listAllHandleResponse(resp *http.Response) (Name } // NewListAuthorizationRulesPager - Gets the authorization rules for a namespace. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name -// options - NamespacesClientListAuthorizationRulesOptions contains the optional parameters for the NamespacesClient.ListAuthorizationRules -// method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name +// - options - NamespacesClientListAuthorizationRulesOptions contains the optional parameters for the NamespacesClient.NewListAuthorizationRulesPager +// method. func (client *NamespacesClient) NewListAuthorizationRulesPager(resourceGroupName string, namespaceName string, options *NamespacesClientListAuthorizationRulesOptions) *runtime.Pager[NamespacesClientListAuthorizationRulesResponse] { return runtime.NewPager(runtime.PagingHandler[NamespacesClientListAuthorizationRulesResponse]{ More: func(page NamespacesClientListAuthorizationRulesResponse) bool { @@ -604,7 +602,7 @@ func (client *NamespacesClient) NewListAuthorizationRulesPager(resourceGroupName if err != nil { return NamespacesClientListAuthorizationRulesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NamespacesClientListAuthorizationRulesResponse{}, err } @@ -631,7 +629,7 @@ func (client *NamespacesClient) listAuthorizationRulesCreateRequest(ctx context. return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -653,17 +651,18 @@ func (client *NamespacesClient) listAuthorizationRulesHandleResponse(resp *http. // ListKeys - Gets the Primary and Secondary ConnectionStrings to the namespace // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// authorizationRuleName - The connection string of the namespace for the specified authorizationRule. -// options - NamespacesClientListKeysOptions contains the optional parameters for the NamespacesClient.ListKeys method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - authorizationRuleName - The connection string of the namespace for the specified authorizationRule. +// - options - NamespacesClientListKeysOptions contains the optional parameters for the NamespacesClient.ListKeys method. func (client *NamespacesClient) ListKeys(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, options *NamespacesClientListKeysOptions) (NamespacesClientListKeysResponse, error) { req, err := client.listKeysCreateRequest(ctx, resourceGroupName, namespaceName, authorizationRuleName, options) if err != nil { return NamespacesClientListKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NamespacesClientListKeysResponse{}, err } @@ -692,7 +691,7 @@ func (client *NamespacesClient) listKeysCreateRequest(ctx context.Context, resou return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -714,17 +713,18 @@ func (client *NamespacesClient) listKeysHandleResponse(resp *http.Response) (Nam // Patch - Patches the existing namespace // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// parameters - Parameters supplied to patch a Namespace Resource. -// options - NamespacesClientPatchOptions contains the optional parameters for the NamespacesClient.Patch method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - parameters - Parameters supplied to patch a Namespace Resource. +// - options - NamespacesClientPatchOptions contains the optional parameters for the NamespacesClient.Patch method. func (client *NamespacesClient) Patch(ctx context.Context, resourceGroupName string, namespaceName string, parameters NamespacePatchParameters, options *NamespacesClientPatchOptions) (NamespacesClientPatchResponse, error) { req, err := client.patchCreateRequest(ctx, resourceGroupName, namespaceName, parameters, options) if err != nil { return NamespacesClientPatchResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NamespacesClientPatchResponse{}, err } @@ -749,7 +749,7 @@ func (client *NamespacesClient) patchCreateRequest(ctx context.Context, resource return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -771,19 +771,20 @@ func (client *NamespacesClient) patchHandleResponse(resp *http.Response) (Namesp // RegenerateKeys - Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// resourceGroupName - The name of the resource group. -// namespaceName - The namespace name. -// authorizationRuleName - The connection string of the namespace for the specified authorizationRule. -// parameters - Parameters supplied to regenerate the Namespace Authorization Rule Key. -// options - NamespacesClientRegenerateKeysOptions contains the optional parameters for the NamespacesClient.RegenerateKeys -// method. +// - resourceGroupName - The name of the resource group. +// - namespaceName - The namespace name. +// - authorizationRuleName - The connection string of the namespace for the specified authorizationRule. +// - parameters - Parameters supplied to regenerate the Namespace Authorization Rule Key. +// - options - NamespacesClientRegenerateKeysOptions contains the optional parameters for the NamespacesClient.RegenerateKeys +// method. func (client *NamespacesClient) RegenerateKeys(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, parameters PolicykeyResource, options *NamespacesClientRegenerateKeysOptions) (NamespacesClientRegenerateKeysResponse, error) { req, err := client.regenerateKeysCreateRequest(ctx, resourceGroupName, namespaceName, authorizationRuleName, parameters, options) if err != nil { return NamespacesClientRegenerateKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NamespacesClientRegenerateKeysResponse{}, err } @@ -812,7 +813,7 @@ func (client *NamespacesClient) regenerateKeysCreateRequest(ctx context.Context, return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/namespaces_client_example_test.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/namespaces_client_example_test.go new file mode 100644 index 000000000000..04dfe07ea7f7 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/namespaces_client_example_test.go @@ -0,0 +1,1283 @@ +//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 armnotificationhubs_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/notificationhubs/armnotificationhubs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceCheckNameAvailability.json +func ExampleNamespacesClient_CheckAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNamespacesClient().CheckAvailability(ctx, armnotificationhubs.CheckAvailabilityParameters{ + Name: to.Ptr("sdk-Namespace-2924"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CheckAvailabilityResult = armnotificationhubs.CheckAvailabilityResult{ + // Name: to.Ptr("mytestnamespace"), + // Type: to.Ptr("Microsoft.NotificationHubs/namespaces/checkNamespaceAvailability"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/providers/Microsoft.NotificationHubs/CheckNamespaceAvailability"), + // Location: to.Ptr("West Europe"), + // IsAvailiable: to.Ptr(false), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceCreate.json +func ExampleNamespacesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNamespacesClient().CreateOrUpdate(ctx, "5ktrial", "nh-sdk-ns", armnotificationhubs.NamespaceCreateOrUpdateParameters{ + Location: to.Ptr("South Central US"), + SKU: &armnotificationhubs.SKU{ + Name: to.Ptr(armnotificationhubs.SKUNameStandard), + Tier: to.Ptr("Standard"), + }, + Tags: map[string]*string{ + "tag1": to.Ptr("value1"), + "tag2": to.Ptr("value2"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.NamespaceResource = armnotificationhubs.NamespaceResource{ + // Name: to.Ptr("sdk-Namespace-2924"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/ArunMonocle/providers/Microsoft.NotificationHubs/namespaces/sdk-Namespace-2924"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-25T22:26:36.76Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:sdk-namespace-2924"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://sdk-Namespace-2924.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-25T22:26:36.76Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceUpdate.json +func ExampleNamespacesClient_Patch() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNamespacesClient().Patch(ctx, "5ktrial", "nh-sdk-ns", armnotificationhubs.NamespacePatchParameters{ + SKU: &armnotificationhubs.SKU{ + Name: to.Ptr(armnotificationhubs.SKUNameStandard), + Tier: to.Ptr("Standard"), + }, + Tags: map[string]*string{ + "tag1": to.Ptr("value1"), + "tag2": to.Ptr("value2"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.NamespaceResource = armnotificationhubs.NamespaceResource{ + // Name: to.Ptr("sdk-Namespace-3285"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/ArunMonocle/providers/Microsoft.NotificationHubs/namespaces/sdk-Namespace-3285"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // "tag3": to.Ptr("value3"), + // "tag4": to.Ptr("value4"), + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-25T23:07:58.17Z"); return t}()), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://sdk-Namespace-3285.servicebus.windows-int.net:443/"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceDelete.json +func ExampleNamespacesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewNamespacesClient().BeginDelete(ctx, "5ktrial", "nh-sdk-ns", 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/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceGet.json +func ExampleNamespacesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNamespacesClient().Get(ctx, "5ktrial", "nh-sdk-ns", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.NamespaceResource = armnotificationhubs.NamespaceResource{ + // Name: to.Ptr("nh-sdk-ns"), + // Type: to.Ptr("Microsoft.NotificationHubs/namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/5ktrial/providers/Microsoft.NotificationHubs/namespaces/nh-sdk-ns"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameBasic), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-02T00:44:56.58Z"); return t}()), + // Critical: to.Ptr(false), + // DataCenter: to.Ptr("SN1"), + // Enabled: to.Ptr(true), + // NamespaceType: to.Ptr(armnotificationhubs.NamespaceTypeNotificationHub), + // ProvisioningState: to.Ptr("Succeeded"), + // ScaleUnit: to.Ptr("SN1-001"), + // ServiceBusEndpoint: to.Ptr("https://nh-sdk-ns.servicebus.windows.net:443/"), + // Status: to.Ptr("Active"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-02T01:02:19.79Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleCreate.json +func ExampleNamespacesClient_CreateOrUpdateAuthorizationRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNamespacesClient().CreateOrUpdateAuthorizationRule(ctx, "5ktrial", "nh-sdk-ns", "sdk-AuthRules-1788", armnotificationhubs.SharedAccessAuthorizationRuleCreateOrUpdateParameters{ + Properties: &armnotificationhubs.SharedAccessAuthorizationRuleProperties{ + Rights: []*armnotificationhubs.AccessRights{ + to.Ptr(armnotificationhubs.AccessRightsListen), + to.Ptr(armnotificationhubs.AccessRightsSend)}, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SharedAccessAuthorizationRuleResource = armnotificationhubs.SharedAccessAuthorizationRuleResource{ + // Name: to.Ptr("sdk-AuthRules-1788"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces/AuthorizationRules"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/ArunMonocle/providers/Microsoft.NotificationHubs/namespaces/sdk-Namespace-6914/AuthorizationRules/sdk-AuthRules-1788"), + // Properties: &armnotificationhubs.SharedAccessAuthorizationRuleProperties{ + // Rights: []*armnotificationhubs.AccessRights{ + // to.Ptr(armnotificationhubs.AccessRightsListen), + // to.Ptr(armnotificationhubs.AccessRightsSend)}, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleDelete.json +func ExampleNamespacesClient_DeleteAuthorizationRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewNamespacesClient().DeleteAuthorizationRule(ctx, "5ktrial", "nh-sdk-ns", "RootManageSharedAccessKey", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleGet.json +func ExampleNamespacesClient_GetAuthorizationRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNamespacesClient().GetAuthorizationRule(ctx, "5ktrial", "nh-sdk-ns", "RootManageSharedAccessKey", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SharedAccessAuthorizationRuleResource = armnotificationhubs.SharedAccessAuthorizationRuleResource{ + // Name: to.Ptr("RootManageSharedAccessKey"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces/AuthorizationRules"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/5ktrial/providers/Microsoft.NotificationHubs/namespaces/nh-sdk-ns/AuthorizationRules/RootManageSharedAccessKey"), + // Location: to.Ptr("South Central US"), + // Properties: &armnotificationhubs.SharedAccessAuthorizationRuleProperties{ + // ClaimType: to.Ptr("SharedAccessKey"), + // ClaimValue: to.Ptr("None"), + // CreatedTime: to.Ptr("2018-05-02T18:24:51.0690674Z"), + // KeyName: to.Ptr("RootManageSharedAccessKey"), + // ModifiedTime: to.Ptr("2018-05-02T18:24:51.0690674Z"), + // PrimaryKey: to.Ptr("############################################"), + // Rights: []*armnotificationhubs.AccessRights{ + // to.Ptr(armnotificationhubs.AccessRightsListen), + // to.Ptr(armnotificationhubs.AccessRightsManage), + // to.Ptr(armnotificationhubs.AccessRightsSend)}, + // SecondaryKey: to.Ptr("############################################"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceListByResourceGroup.json +func ExampleNamespacesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewNamespacesClient().NewListPager("5ktrial", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.NamespaceListResult = armnotificationhubs.NamespaceListResult{ + // Value: []*armnotificationhubs.NamespaceResource{ + // { + // Name: to.Ptr("sdk-Namespace-2924"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/ArunMonocle/providers/Microsoft.NotificationHubs/namespaces/sdk-Namespace-2924"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-25T22:26:36.76Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:sdk-namespace-2924"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://sdk-Namespace-2924.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-25T22:26:59.35Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceList.json +func ExampleNamespacesClient_NewListAllPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewNamespacesClient().NewListAllPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.NamespaceListResult = armnotificationhubs.NamespaceListResult{ + // Value: []*armnotificationhubs.NamespaceResource{ + // { + // Name: to.Ptr("NS-91f08e47-2b04-4943-b0cd-a5fb02b88f20"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-91f08e47-2b04-4943-b0cd-a5fb02b88f20"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-23T02:40:17.27Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-91f08e47-2b04-4943-b0cd-a5fb02b88f20"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-91f08e47-2b04-4943-b0cd-a5fb02b88f20.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T07:15:30.78Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-41dc63f4-0b08-4029-b3ef-535a131bfa65"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-41dc63f4-0b08-4029-b3ef-535a131bfa65"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-23T03:50:38.98Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-41dc63f4-0b08-4029-b3ef-535a131bfa65"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-41dc63f4-0b08-4029-b3ef-535a131bfa65.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T10:42:58.003Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-df52cf51-e831-4bf2-bd92-e9885f68a996"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-df52cf51-e831-4bf2-bd92-e9885f68a996"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-09-16T01:17:54.997Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-df52cf51-e831-4bf2-bd92-e9885f68a996"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-df52cf51-e831-4bf2-bd92-e9885f68a996.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T06:44:39.737Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("rrama-ns2"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/sadfsadfsadf/providers/Microsoft.NotificationHubs/namespaces/rrama-ns2"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-23T04:14:00.013Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:rrama-ns2"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://rrama-ns2.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-03T22:53:32.927Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-20e57600-29d0-4035-ac85-74f4c54dcda1"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-20e57600-29d0-4035-ac85-74f4c54dcda1"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-23T03:30:49.16Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-20e57600-29d0-4035-ac85-74f4c54dcda1"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-20e57600-29d0-4035-ac85-74f4c54dcda1.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T04:17:58.483Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-3e538a1a-58fb-4315-b2ce-76f5c944114c"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-3e538a1a-58fb-4315-b2ce-76f5c944114c"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-09-16T18:07:30.05Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-3e538a1a-58fb-4315-b2ce-76f5c944114c"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-3e538a1a-58fb-4315-b2ce-76f5c944114c.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T10:42:57.747Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-4e1bfdf1-0cff-4e86-ae80-cdcac4873039"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-4e1bfdf1-0cff-4e86-ae80-cdcac4873039"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-09-16T01:01:58.73Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-4e1bfdf1-0cff-4e86-ae80-cdcac4873039"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-4e1bfdf1-0cff-4e86-ae80-cdcac4873039.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T03:02:59.8Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-6b90b7f3-7aa0-48c9-bc30-b299dcb66c03"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-6b90b7f3-7aa0-48c9-bc30-b299dcb66c03"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-23T03:22:45.327Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-6b90b7f3-7aa0-48c9-bc30-b299dcb66c03"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-6b90b7f3-7aa0-48c9-bc30-b299dcb66c03.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T06:08:01.207Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-c05e9df3-7737-44ee-a321-15f6e0545b97"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-c05e9df3-7737-44ee-a321-15f6e0545b97"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-05T03:29:19.75Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-c05e9df3-7737-44ee-a321-15f6e0545b97"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-c05e9df3-7737-44ee-a321-15f6e0545b97.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T08:10:35.527Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-dcb4152c-231b-4c16-a683-07cc6b38fa46"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-dcb4152c-231b-4c16-a683-07cc6b38fa46"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-05T03:34:35.363Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-dcb4152c-231b-4c16-a683-07cc6b38fa46"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-dcb4152c-231b-4c16-a683-07cc6b38fa46.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T05:33:00.957Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-f501f5e6-1f24-439b-8982-9af665156d40"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-f501f5e6-1f24-439b-8982-9af665156d40"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-09-16T01:25:55.707Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-f501f5e6-1f24-439b-8982-9af665156d40"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-f501f5e6-1f24-439b-8982-9af665156d40.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T07:42:59.687Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-fe2ed660-2cd6-46f2-a9c3-7e11551a1f30"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-fe2ed660-2cd6-46f2-a9c3-7e11551a1f30"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-23T02:32:08.227Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-fe2ed660-2cd6-46f2-a9c3-7e11551a1f30"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-fe2ed660-2cd6-46f2-a9c3-7e11551a1f30.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T06:32:57.77Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-8a5e3b4e-4e97-4d85-9083-cd33536c9d71"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-8a5e3b4e-4e97-4d85-9083-cd33536c9d71"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-09-16T00:54:05.103Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-8a5e3b4e-4e97-4d85-9083-cd33536c9d71"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-8a5e3b4e-4e97-4d85-9083-cd33536c9d71.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T10:43:50.313Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-6520cc09-01ac-40a3-bc09-c5c431116e92"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-6520cc09-01ac-40a3-bc09-c5c431116e92"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-09-16T01:49:59.243Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-6520cc09-01ac-40a3-bc09-c5c431116e92"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-6520cc09-01ac-40a3-bc09-c5c431116e92.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T08:15:36.95Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-bfba6d5c-a425-42d9-85db-0f4da770e29a"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-bfba6d5c-a425-42d9-85db-0f4da770e29a"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-05T03:23:32.083Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-bfba6d5c-a425-42d9-85db-0f4da770e29a"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-bfba6d5c-a425-42d9-85db-0f4da770e29a.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T09:02:57.433Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-43b136b4-8716-40b2-97c5-0d77cac0062c"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-43b136b4-8716-40b2-97c5-0d77cac0062c"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-23T03:14:50.577Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-43b136b4-8716-40b2-97c5-0d77cac0062c"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-43b136b4-8716-40b2-97c5-0d77cac0062c.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T09:23:01.067Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-7c0443de-5f88-450c-b574-83f60a097dd1"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-7c0443de-5f88-450c-b574-83f60a097dd1"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-23T04:07:15.397Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-7c0443de-5f88-450c-b574-83f60a097dd1"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-7c0443de-5f88-450c-b574-83f60a097dd1.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T04:03:03.097Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-62dd7753-a5f9-42fd-a354-ca38a4505d69"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-62dd7753-a5f9-42fd-a354-ca38a4505d69"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-09-16T01:33:50.45Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-62dd7753-a5f9-42fd-a354-ca38a4505d69"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-62dd7753-a5f9-42fd-a354-ca38a4505d69.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T05:35:33.053Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-ae18a18c-97ab-4089-965d-8acbf4794091"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-ae18a18c-97ab-4089-965d-8acbf4794091"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-23T02:43:36.517Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-ae18a18c-97ab-4089-965d-8acbf4794091"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-ae18a18c-97ab-4089-965d-8acbf4794091.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T12:40:30.587Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-8e3b56c1-0ee8-4e13-ae88-5cadf6e2ce11"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-8e3b56c1-0ee8-4e13-ae88-5cadf6e2ce11"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-09-16T00:46:03.773Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-8e3b56c1-0ee8-4e13-ae88-5cadf6e2ce11"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-8e3b56c1-0ee8-4e13-ae88-5cadf6e2ce11.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T04:43:54.56Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-7ffca4b4-4728-4fb0-b2d0-1e7c016e3a44"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-7ffca4b4-4728-4fb0-b2d0-1e7c016e3a44"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-23T03:59:12.1Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-7ffca4b4-4728-4fb0-b2d0-1e7c016e3a44"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-7ffca4b4-4728-4fb0-b2d0-1e7c016e3a44.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T06:33:52.23Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-d9337efd-9b27-454c-b2a5-dcfea56920d9"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-d9337efd-9b27-454c-b2a5-dcfea56920d9"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-05T03:45:09.27Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-d9337efd-9b27-454c-b2a5-dcfea56920d9"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-d9337efd-9b27-454c-b2a5-dcfea56920d9.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T06:20:31.863Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-ad5ae732-abea-4e62-9de0-c90de0ddec0a"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-ad5ae732-abea-4e62-9de0-c90de0ddec0a"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-23T02:34:36.447Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-ad5ae732-abea-4e62-9de0-c90de0ddec0a"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-ad5ae732-abea-4e62-9de0-c90de0ddec0a.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T06:15:31.607Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-d447fb03-c7da-40fe-b5eb-14f36888837b"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-d447fb03-c7da-40fe-b5eb-14f36888837b"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-05T00:53:46.697Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-d447fb03-c7da-40fe-b5eb-14f36888837b"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-d447fb03-c7da-40fe-b5eb-14f36888837b.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T11:09:41.26Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("ReproSB"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/RapscallionResources/providers/Microsoft.NotificationHubs/namespaces/ReproSB"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-27T19:29:34.523Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:reprosb"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://ReproSB.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-27T19:29:58.64Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-4c90097f-19a8-42e7-bb3c-4ac088994719"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-4c90097f-19a8-42e7-bb3c-4ac088994719"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-09-16T17:35:32.61Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-4c90097f-19a8-42e7-bb3c-4ac088994719"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-4c90097f-19a8-42e7-bb3c-4ac088994719.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T09:13:52.27Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("rrama-1-23-17"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/rrama-1-23-17"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-23T22:54:40.907Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:rrama-1-23-17"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://rrama-1-23-17.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-04T00:53:28.777Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-5191e541-8e4e-4229-9fdc-b89f6c3e7f12"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-5191e541-8e4e-4229-9fdc-b89f6c3e7f12"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-09-16T17:43:25.71Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-5191e541-8e4e-4229-9fdc-b89f6c3e7f12"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-5191e541-8e4e-4229-9fdc-b89f6c3e7f12.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T11:05:31.89Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-be903820-3533-46e8-90e4-72c132411848"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-be903820-3533-46e8-90e4-72c132411848"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-05T03:24:01.923Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-be903820-3533-46e8-90e4-72c132411848"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-be903820-3533-46e8-90e4-72c132411848.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T10:09:42.513Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("rrama-namespace1"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/rrama-namespace1"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-05T00:47:22.963Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:rrama-namespace1"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://rrama-namespace1.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-05T00:47:27.297Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-a3c38e9b-32a3-4c51-85d7-263150a8dda9"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-a3c38e9b-32a3-4c51-85d7-263150a8dda9"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-09-16T00:38:02.517Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-a3c38e9b-32a3-4c51-85d7-263150a8dda9"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-a3c38e9b-32a3-4c51-85d7-263150a8dda9.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T05:03:55.96Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-70d3fa25-6bbe-4a6b-a381-a52cf0d539e6"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-70d3fa25-6bbe-4a6b-a381-a52cf0d539e6"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-23T03:42:40.01Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-70d3fa25-6bbe-4a6b-a381-a52cf0d539e6"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-70d3fa25-6bbe-4a6b-a381-a52cf0d539e6.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T06:33:02.363Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-e6536f77-0d1b-4a6b-8f42-29cc15b2930a"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-e6536f77-0d1b-4a6b-8f42-29cc15b2930a"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-05T04:28:10.71Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-e6536f77-0d1b-4a6b-8f42-29cc15b2930a"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-e6536f77-0d1b-4a6b-8f42-29cc15b2930a.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T08:43:51.587Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("sdk-Namespace-2924"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/ArunMonocle/providers/Microsoft.NotificationHubs/namespaces/sdk-Namespace-2924"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-25T22:26:36.76Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:sdk-namespace-2924"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://sdk-Namespace-2924.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-25T22:26:59.35Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("rrama-sb1"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/rrama-sb1"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-01T21:47:34.903Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:rrama-sb1"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://rrama-sb1.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-02T02:10:03.083Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("WhackWhack"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/RapscallionResources/providers/Microsoft.NotificationHubs/namespaces/WhackWhack"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-10-10T23:39:01.347Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:whackwhack"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://WhackWhack.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-04T00:56:32.687Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-66ed32d6-611e-4bb0-8e1a-a6d0fc65427c"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-66ed32d6-611e-4bb0-8e1a-a6d0fc65427c"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-09-16T17:51:27.73Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-66ed32d6-611e-4bb0-8e1a-a6d0fc65427c"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-66ed32d6-611e-4bb0-8e1a-a6d0fc65427c.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T08:19:43.383Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("NS-e0cab401-6df8-465d-8d4a-da9a9e55cf0e"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/NS-e0cab401-6df8-465d-8d4a-da9a9e55cf0e"), + // Location: to.Ptr("South Central US"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-05T01:14:25.613Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:ns-e0cab401-6df8-465d-8d4a-da9a9e55cf0e"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://NS-e0cab401-6df8-465d-8d4a-da9a9e55cf0e.servicebus.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-11T12:33:01.727Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("bn3-rrama-foo1"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/bn3-rrama-foo1"), + // Location: to.Ptr("East US 2"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-28T23:54:26.927Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:bn3-rrama-foo1"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://bn3-rrama-foo1.servicebus.int7.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-28T23:54:26.927Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("bn3-rrama-foo3"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/bn3-rrama-foo3"), + // Location: to.Ptr("East US 2"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-29T00:24:09.907Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:bn3-rrama-foo3"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://bn3-rrama-foo3.servicebus.int7.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-29T00:24:33.233Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("bn3-rrama-foo2"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/bn3-rrama-foo2"), + // Location: to.Ptr("East US 2"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-28T23:57:40.82Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:bn3-rrama-foo2"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://bn3-rrama-foo2.servicebus.int7.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-28T23:57:40.82Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("db3-rrama-foo2"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/Default-ServiceBus-SouthCentralUS/providers/Microsoft.NotificationHubs/namespaces/db3-rrama-foo2"), + // Location: to.Ptr("North Europe"), + // SKU: &armnotificationhubs.SKU{ + // Name: to.Ptr(armnotificationhubs.SKUNameStandard), + // Tier: to.Ptr("Standard"), + // }, + // Tags: map[string]*string{ + // }, + // Properties: &armnotificationhubs.NamespaceProperties{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-29T00:10:43.463Z"); return t}()), + // MetricID: to.Ptr("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40:db3-rrama-foo2"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceBusEndpoint: to.Ptr("https://db3-rrama-foo2.servicebus.int7.windows-int.net:443/"), + // UpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-29T00:11:09.133Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleListAll.json +func ExampleNamespacesClient_NewListAuthorizationRulesPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewNamespacesClient().NewListAuthorizationRulesPager("5ktrial", "nh-sdk-ns", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SharedAccessAuthorizationRuleListResult = armnotificationhubs.SharedAccessAuthorizationRuleListResult{ + // Value: []*armnotificationhubs.SharedAccessAuthorizationRuleResource{ + // { + // Name: to.Ptr("RootManageSharedAccessKey"), + // Type: to.Ptr("Microsoft.NotificationHubs/Namespaces/AuthorizationRules"), + // ID: to.Ptr("/subscriptions/29cfa613-cbbc-4512-b1d6-1b3a92c7fa40/resourceGroups/5ktrial/providers/Microsoft.NotificationHubs/namespaces/nh-sdk-ns/AuthorizationRules/RootManageSharedAccessKey"), + // Properties: &armnotificationhubs.SharedAccessAuthorizationRuleProperties{ + // ClaimType: to.Ptr("SharedAccessKey"), + // ClaimValue: to.Ptr("None"), + // CreatedTime: to.Ptr("2018-05-02T18:24:51.0690674Z"), + // KeyName: to.Ptr("RootManageSharedAccessKey"), + // ModifiedTime: to.Ptr("2018-05-02T18:31:28.5201555Z"), + // PrimaryKey: to.Ptr(""), + // Revision: to.Ptr[int32](1), + // Rights: []*armnotificationhubs.AccessRights{ + // to.Ptr(armnotificationhubs.AccessRightsListen), + // to.Ptr(armnotificationhubs.AccessRightsManage), + // to.Ptr(armnotificationhubs.AccessRightsSend)}, + // SecondaryKey: to.Ptr(""), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleListKey.json +func ExampleNamespacesClient_ListKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNamespacesClient().ListKeys(ctx, "5ktrial", "nh-sdk-ns", "RootManageSharedAccessKey", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ResourceListKeys = armnotificationhubs.ResourceListKeys{ + // KeyName: to.Ptr("RootManageSharedAccessKey"), + // PrimaryConnectionString: to.Ptr("Endpoint=sb://nh-sdk-ns.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=############################################"), + // PrimaryKey: to.Ptr("############################################"), + // SecondaryConnectionString: to.Ptr("Endpoint=sb://nh-sdk-ns.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=############################################"), + // SecondaryKey: to.Ptr("############################################"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleRegenrateKey.json +func ExampleNamespacesClient_RegenerateKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNamespacesClient().RegenerateKeys(ctx, "5ktrial", "nh-sdk-ns", "RootManageSharedAccessKey", armnotificationhubs.PolicykeyResource{ + PolicyKey: to.Ptr("PrimaryKey"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ResourceListKeys = armnotificationhubs.ResourceListKeys{ + // KeyName: to.Ptr("RootManageSharedAccessKey"), + // PrimaryConnectionString: to.Ptr("Endpoint=sb://nh-sdk-ns.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=############################################"), + // PrimaryKey: to.Ptr("############################################"), + // SecondaryConnectionString: to.Ptr("Endpoint=sb://nh-sdk-ns.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=############################################"), + // SecondaryKey: to.Ptr("############################################"), + // } +} diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_operations_client.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/operations_client.go similarity index 77% rename from sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_operations_client.go rename to sdk/resourcemanager/notificationhubs/armnotificationhubs/operations_client.go index ff9cea9bb5e9..de9a957f9077 100644 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_operations_client.go +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/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 armnotificationhubs @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,36 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists all of the available NotificationHubs REST API operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-04-01 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -68,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -83,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.NotificationHubs/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/operations_client_example_test.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/operations_client_example_test.go new file mode 100644 index 000000000000..6ae021d27a4e --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/operations_client_example_test.go @@ -0,0 +1,254 @@ +//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 armnotificationhubs_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/notificationhubs/armnotificationhubs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NHOperationsList.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnotificationhubs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationListResult = armnotificationhubs.OperationListResult{ + // Value: []*armnotificationhubs.Operation{ + // { + // Name: to.Ptr("Microsoft.NotificationHubs/register/action"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Registers the NotificationHubs Provider"), + // Provider: to.Ptr("Microsoft Azure Notification Hub"), + // Resource: to.Ptr("Microsoft Azure Notification Hub"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/unregister/action"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Unregisters the NotificationHubs Provider"), + // Provider: to.Ptr("Microsoft Azure Notification Hub"), + // Resource: to.Ptr("Microsoft Azure Notification Hub"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/operationResults/read"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Operation results for Notification Hubs provider"), + // Provider: to.Ptr("Microsoft Azure Notification Hub"), + // Resource: to.Ptr("Microsoft Azure Notification Hub"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/CheckNamespaceAvailability/action"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Get namespace availability."), + // Provider: to.Ptr("Microsoft Azure Notification Hub"), + // Resource: to.Ptr("Microsoft Azure Notification Hub"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/write"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Create Or Update Namespace "), + // Provider: to.Ptr("Microsoft Azure Notification Hub"), + // Resource: to.Ptr("Namespace"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/read"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Get Namespace Resource"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("Namespace"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/Delete"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Delete Namespace"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("Namespace"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/authorizationRules/write"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Create or Update Namespace Authorization Rules"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("AuthorizationRules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/authorizationRules/action"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Get Namespace Authorization Rules"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("AuthorizationRules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/authorizationRules/read"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Get Namespace Authorization Rules"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("AuthorizationRules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/authorizationRules/delete"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Delete Namespace Authorization Rule"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("AuthorizationRules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/authorizationRules/listkeys/action"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Get Namespace Listkeys"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("AuthorizationRules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/authorizationRules/regenerateKeys/action"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Resource Regeneratekeys"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("AuthorizationRules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/Namespaces/CheckNotificationHubAvailability/action"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("CheckNotificationHubAvailability"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("AuthorizationRules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs/write"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Create or Update notification hub"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("NotificationHub"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs/read"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Get notification hub"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("NotificationHub"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs/Delete"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Delete notification hub"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("NotificationHub"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs/authorizationRules/write"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Create or Update NotificationHub Authorization Rule"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("NotificationHub Authorization Rule"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs/authorizationRules/action"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr(" Get NotificationHub Authorization Rules"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("NotificationHub AuthorizationRules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs/authorizationRules/read"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr(" Get NotificationHub Authorization Rules"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("NotificationHub AuthorizationRules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs/authorizationRules/delete"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Delete NotificationHub Authorization Rules"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("NotificationHub AuthorizationRules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs/authorizationRules/listkeys/action"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("List NotificationHub keys"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("NotificationHub AuthorizationRules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/namespaces/notificationHubs/authorizationRules/regenerateKeys/action"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Resource Regeneratekeys"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("NotificationHub AuthorizationRules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/Namespaces/NotificationHubs/pnsCredentials/action"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Resource Get Notification Hub PNS Credentials"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("NotificationHub PnsCredential"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/Namespaces/NotificationHubs/debugSend/action"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Send a test push notification"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("NotificationHub resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.NotificationHubs/Namespaces/NotificationHubs/metricDefinitions/read"), + // Display: &armnotificationhubs.OperationDisplay{ + // Operation: to.Ptr("Get NotificationHub metrics"), + // Provider: to.Ptr("Microsoft Azure NotificationHubs"), + // Resource: to.Ptr("NotificationHub metrics"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_response_types.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/response_types.go similarity index 93% rename from sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_response_types.go rename to sdk/resourcemanager/notificationhubs/armnotificationhubs/response_types.go index d85275cdbffa..9d453d98158d 100644 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_response_types.go +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/response_types.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armnotificationhubs @@ -53,7 +54,7 @@ type ClientGetResponse struct { NotificationHubResource } -// ClientListAuthorizationRulesResponse contains the response from method Client.ListAuthorizationRules. +// ClientListAuthorizationRulesResponse contains the response from method Client.NewListAuthorizationRulesPager. type ClientListAuthorizationRulesResponse struct { SharedAccessAuthorizationRuleListResult } @@ -63,7 +64,7 @@ type ClientListKeysResponse struct { ResourceListKeys } -// ClientListResponse contains the response from method Client.List. +// ClientListResponse contains the response from method Client.NewListPager. type ClientListResponse struct { NotificationHubListResult } @@ -98,7 +99,7 @@ type NamespacesClientDeleteAuthorizationRuleResponse struct { // placeholder for future response values } -// NamespacesClientDeleteResponse contains the response from method NamespacesClient.Delete. +// NamespacesClientDeleteResponse contains the response from method NamespacesClient.BeginDelete. type NamespacesClientDeleteResponse struct { // placeholder for future response values } @@ -113,12 +114,12 @@ type NamespacesClientGetResponse struct { NamespaceResource } -// NamespacesClientListAllResponse contains the response from method NamespacesClient.ListAll. +// NamespacesClientListAllResponse contains the response from method NamespacesClient.NewListAllPager. type NamespacesClientListAllResponse struct { NamespaceListResult } -// NamespacesClientListAuthorizationRulesResponse contains the response from method NamespacesClient.ListAuthorizationRules. +// NamespacesClientListAuthorizationRulesResponse contains the response from method NamespacesClient.NewListAuthorizationRulesPager. type NamespacesClientListAuthorizationRulesResponse struct { SharedAccessAuthorizationRuleListResult } @@ -128,7 +129,7 @@ type NamespacesClientListKeysResponse struct { ResourceListKeys } -// NamespacesClientListResponse contains the response from method NamespacesClient.List. +// NamespacesClientListResponse contains the response from method NamespacesClient.NewListPager. type NamespacesClientListResponse struct { NamespaceListResult } @@ -143,7 +144,7 @@ type NamespacesClientRegenerateKeysResponse struct { ResourceListKeys } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult } diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_time_rfc3339.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/notificationhubs/armnotificationhubs/time_rfc3339.go index e540bebcff7e..948d9350ad05 100644 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/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 armnotificationhubs @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/ze_generated_example_namespaces_client_test.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/ze_generated_example_namespaces_client_test.go deleted file mode 100644 index cc6bcee93367..000000000000 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/ze_generated_example_namespaces_client_test.go +++ /dev/null @@ -1,350 +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 armnotificationhubs_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/notificationhubs/armnotificationhubs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceCheckNameAvailability.json -func ExampleNamespacesClient_CheckAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewNamespacesClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CheckAvailability(ctx, - armnotificationhubs.CheckAvailabilityParameters{ - Name: to.Ptr("sdk-Namespace-2924"), - }, - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceCreate.json -func ExampleNamespacesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewNamespacesClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "5ktrial", - "nh-sdk-ns", - armnotificationhubs.NamespaceCreateOrUpdateParameters{ - Location: to.Ptr("South Central US"), - SKU: &armnotificationhubs.SKU{ - Name: to.Ptr(armnotificationhubs.SKUNameStandard), - Tier: to.Ptr("Standard"), - }, - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - }, - }, - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceUpdate.json -func ExampleNamespacesClient_Patch() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewNamespacesClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Patch(ctx, - "5ktrial", - "nh-sdk-ns", - armnotificationhubs.NamespacePatchParameters{ - SKU: &armnotificationhubs.SKU{ - Name: to.Ptr(armnotificationhubs.SKUNameStandard), - Tier: to.Ptr("Standard"), - }, - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - }, - }, - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceDelete.json -func ExampleNamespacesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewNamespacesClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "5ktrial", - "nh-sdk-ns", - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceGet.json -func ExampleNamespacesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewNamespacesClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "5ktrial", - "nh-sdk-ns", - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleCreate.json -func ExampleNamespacesClient_CreateOrUpdateAuthorizationRule() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewNamespacesClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdateAuthorizationRule(ctx, - "5ktrial", - "nh-sdk-ns", - "sdk-AuthRules-1788", - armnotificationhubs.SharedAccessAuthorizationRuleCreateOrUpdateParameters{ - Properties: &armnotificationhubs.SharedAccessAuthorizationRuleProperties{ - Rights: []*armnotificationhubs.AccessRights{ - to.Ptr(armnotificationhubs.AccessRightsListen), - to.Ptr(armnotificationhubs.AccessRightsSend)}, - }, - }, - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleDelete.json -func ExampleNamespacesClient_DeleteAuthorizationRule() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewNamespacesClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.DeleteAuthorizationRule(ctx, - "5ktrial", - "nh-sdk-ns", - "RootManageSharedAccessKey", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleGet.json -func ExampleNamespacesClient_GetAuthorizationRule() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewNamespacesClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetAuthorizationRule(ctx, - "5ktrial", - "nh-sdk-ns", - "RootManageSharedAccessKey", - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceListByResourceGroup.json -func ExampleNamespacesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewNamespacesClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("5ktrial", - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceList.json -func ExampleNamespacesClient_NewListAllPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewNamespacesClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListAllPager(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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleListAll.json -func ExampleNamespacesClient_NewListAuthorizationRulesPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewNamespacesClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListAuthorizationRulesPager("5ktrial", - "nh-sdk-ns", - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleListKey.json -func ExampleNamespacesClient_ListKeys() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewNamespacesClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListKeys(ctx, - "5ktrial", - "nh-sdk-ns", - "RootManageSharedAccessKey", - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleRegenrateKey.json -func ExampleNamespacesClient_RegenerateKeys() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewNamespacesClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.RegenerateKeys(ctx, - "5ktrial", - "nh-sdk-ns", - "RootManageSharedAccessKey", - armnotificationhubs.PolicykeyResource{ - PolicyKey: to.Ptr("PrimaryKey"), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/ze_generated_example_notificationhubs_client_test.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/ze_generated_example_notificationhubs_client_test.go deleted file mode 100644 index 1cc5c9fba301..000000000000 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/ze_generated_example_notificationhubs_client_test.go +++ /dev/null @@ -1,368 +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 armnotificationhubs_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/notificationhubs/armnotificationhubs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubCheckNameAvailability.json -func ExampleClient_CheckNotificationHubAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CheckNotificationHubAvailability(ctx, - "5ktrial", - "locp-newns", - armnotificationhubs.CheckAvailabilityParameters{ - Name: to.Ptr("sdktest"), - Location: to.Ptr("West Europe"), - }, - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubCreate.json -func ExampleClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "5ktrial", - "nh-sdk-ns", - "nh-sdk-hub", - armnotificationhubs.NotificationHubCreateOrUpdateParameters{ - Location: to.Ptr("eastus"), - Properties: &armnotificationhubs.NotificationHubProperties{}, - }, - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubPatch.json -func ExampleClient_Patch() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Patch(ctx, - "sdkresourceGroup", - "nh-sdk-ns", - "sdk-notificationHubs-8708", - &armnotificationhubs.ClientPatchOptions{Parameters: &armnotificationhubs.NotificationHubPatchParameters{}}) - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubDelete.json -func ExampleClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "5ktrial", - "nh-sdk-ns", - "nh-sdk-hub", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubGet.json -func ExampleClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "5ktrial", - "nh-sdk-ns", - "nh-sdk-hub", - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubDebugSend.json -func ExampleClient_DebugSend() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.DebugSend(ctx, - "5ktrial", - "nh-sdk-ns", - "nh-sdk-hub", - &armnotificationhubs.ClientDebugSendOptions{Parameters: map[string]interface{}{ - "data": map[string]interface{}{ - "message": "Hello", - }, - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleCreate.json -func ExampleClient_CreateOrUpdateAuthorizationRule() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdateAuthorizationRule(ctx, - "5ktrial", - "nh-sdk-ns", - "nh-sdk-hub", - "DefaultListenSharedAccessSignature", - armnotificationhubs.SharedAccessAuthorizationRuleCreateOrUpdateParameters{ - Properties: &armnotificationhubs.SharedAccessAuthorizationRuleProperties{ - Rights: []*armnotificationhubs.AccessRights{ - to.Ptr(armnotificationhubs.AccessRightsListen), - to.Ptr(armnotificationhubs.AccessRightsSend)}, - }, - }, - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleDelete.json -func ExampleClient_DeleteAuthorizationRule() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.DeleteAuthorizationRule(ctx, - "5ktrial", - "nh-sdk-ns", - "nh-sdk-hub", - "DefaultListenSharedAccessSignature", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleGet.json -func ExampleClient_GetAuthorizationRule() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetAuthorizationRule(ctx, - "5ktrial", - "nh-sdk-ns", - "nh-sdk-hub", - "DefaultListenSharedAccessSignature", - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubListByNameSpace.json -func ExampleClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("5ktrial", - "nh-sdk-ns", - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleListAll.json -func ExampleClient_NewListAuthorizationRulesPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListAuthorizationRulesPager("5ktrial", - "nh-sdk-ns", - "nh-sdk-hub", - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleListKey.json -func ExampleClient_ListKeys() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListKeys(ctx, - "5ktrial", - "nh-sdk-ns", - "nh-sdk-hub", - "sdk-AuthRules-5800", - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleRegenrateKey.json -func ExampleClient_RegenerateKeys() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.RegenerateKeys(ctx, - "5ktrial", - "nh-sdk-ns", - "nh-sdk-hub", - "DefaultListenSharedAccessSignature", - armnotificationhubs.PolicykeyResource{ - PolicyKey: to.Ptr("PrimaryKey"), - }, - 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/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubPnsCredentials.json -func ExampleClient_GetPnsCredentials() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armnotificationhubs.NewClient("29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetPnsCredentials(ctx, - "5ktrial", - "nh-sdk-ns", - "nh-sdk-hub", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/ze_generated_example_operations_client_test.go deleted file mode 100644 index ff0827ec21d6..000000000000 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/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 armnotificationhubs_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/notificationhubs/armnotificationhubs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NHOperationsList.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 := armnotificationhubs.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/notificationhubs/armnotificationhubs/zz_generated_models_serde.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_models_serde.go deleted file mode 100644 index 5eb7e4d6b990..000000000000 --- a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_models_serde.go +++ /dev/null @@ -1,295 +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 armnotificationhubs - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type CheckAvailabilityParameters. -func (c CheckAvailabilityParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", c.ID) - populate(objectMap, "isAvailiable", c.IsAvailiable) - populate(objectMap, "location", c.Location) - populate(objectMap, "name", c.Name) - populate(objectMap, "sku", c.SKU) - populate(objectMap, "tags", c.Tags) - populate(objectMap, "type", c.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type CheckAvailabilityResult. -func (c CheckAvailabilityResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", c.ID) - populate(objectMap, "isAvailiable", c.IsAvailiable) - populate(objectMap, "location", c.Location) - populate(objectMap, "name", c.Name) - populate(objectMap, "sku", c.SKU) - populate(objectMap, "tags", c.Tags) - populate(objectMap, "type", c.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type DebugSendResponse. -func (d DebugSendResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", d.ID) - populate(objectMap, "location", d.Location) - populate(objectMap, "name", d.Name) - populate(objectMap, "properties", d.Properties) - populate(objectMap, "sku", d.SKU) - populate(objectMap, "tags", d.Tags) - populate(objectMap, "type", d.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type NamespaceCreateOrUpdateParameters. -func (n NamespaceCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", n.ID) - populate(objectMap, "location", n.Location) - populate(objectMap, "name", n.Name) - populate(objectMap, "properties", n.Properties) - populate(objectMap, "sku", n.SKU) - populate(objectMap, "tags", n.Tags) - populate(objectMap, "type", n.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type NamespacePatchParameters. -func (n NamespacePatchParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "sku", n.SKU) - populate(objectMap, "tags", n.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type NamespaceProperties. -func (n NamespaceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdAt", n.CreatedAt) - populate(objectMap, "critical", n.Critical) - populate(objectMap, "dataCenter", n.DataCenter) - populate(objectMap, "enabled", n.Enabled) - populate(objectMap, "metricId", n.MetricID) - populate(objectMap, "name", n.Name) - populate(objectMap, "namespaceType", n.NamespaceType) - populate(objectMap, "provisioningState", n.ProvisioningState) - populate(objectMap, "region", n.Region) - populate(objectMap, "scaleUnit", n.ScaleUnit) - populate(objectMap, "serviceBusEndpoint", n.ServiceBusEndpoint) - populate(objectMap, "status", n.Status) - populate(objectMap, "subscriptionId", n.SubscriptionID) - populateTimeRFC3339(objectMap, "updatedAt", n.UpdatedAt) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type NamespaceProperties. -func (n *NamespaceProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", n, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &n.CreatedAt) - delete(rawMsg, key) - case "critical": - err = unpopulate(val, "Critical", &n.Critical) - delete(rawMsg, key) - case "dataCenter": - err = unpopulate(val, "DataCenter", &n.DataCenter) - delete(rawMsg, key) - case "enabled": - err = unpopulate(val, "Enabled", &n.Enabled) - delete(rawMsg, key) - case "metricId": - err = unpopulate(val, "MetricID", &n.MetricID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &n.Name) - delete(rawMsg, key) - case "namespaceType": - err = unpopulate(val, "NamespaceType", &n.NamespaceType) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &n.ProvisioningState) - delete(rawMsg, key) - case "region": - err = unpopulate(val, "Region", &n.Region) - delete(rawMsg, key) - case "scaleUnit": - err = unpopulate(val, "ScaleUnit", &n.ScaleUnit) - delete(rawMsg, key) - case "serviceBusEndpoint": - err = unpopulate(val, "ServiceBusEndpoint", &n.ServiceBusEndpoint) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &n.Status) - delete(rawMsg, key) - case "subscriptionId": - err = unpopulate(val, "SubscriptionID", &n.SubscriptionID) - delete(rawMsg, key) - case "updatedAt": - err = unpopulateTimeRFC3339(val, "UpdatedAt", &n.UpdatedAt) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", n, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type NamespaceResource. -func (n NamespaceResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", n.ID) - populate(objectMap, "location", n.Location) - populate(objectMap, "name", n.Name) - populate(objectMap, "properties", n.Properties) - populate(objectMap, "sku", n.SKU) - populate(objectMap, "tags", n.Tags) - populate(objectMap, "type", n.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type NotificationHubCreateOrUpdateParameters. -func (n NotificationHubCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", n.ID) - populate(objectMap, "location", n.Location) - populate(objectMap, "name", n.Name) - populate(objectMap, "properties", n.Properties) - populate(objectMap, "sku", n.SKU) - populate(objectMap, "tags", n.Tags) - populate(objectMap, "type", n.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type NotificationHubPatchParameters. -func (n NotificationHubPatchParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", n.ID) - populate(objectMap, "location", n.Location) - populate(objectMap, "name", n.Name) - populate(objectMap, "properties", n.Properties) - populate(objectMap, "sku", n.SKU) - populate(objectMap, "tags", n.Tags) - populate(objectMap, "type", n.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type NotificationHubProperties. -func (n NotificationHubProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "admCredential", n.AdmCredential) - populate(objectMap, "apnsCredential", n.ApnsCredential) - populate(objectMap, "authorizationRules", n.AuthorizationRules) - populate(objectMap, "baiduCredential", n.BaiduCredential) - populate(objectMap, "gcmCredential", n.GCMCredential) - populate(objectMap, "mpnsCredential", n.MpnsCredential) - populate(objectMap, "name", n.Name) - populate(objectMap, "registrationTtl", n.RegistrationTTL) - populate(objectMap, "wnsCredential", n.WnsCredential) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type NotificationHubResource. -func (n NotificationHubResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", n.ID) - populate(objectMap, "location", n.Location) - populate(objectMap, "name", n.Name) - populate(objectMap, "properties", n.Properties) - populate(objectMap, "sku", n.SKU) - populate(objectMap, "tags", n.Tags) - populate(objectMap, "type", n.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type PnsCredentialsResource. -func (p PnsCredentialsResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", p.ID) - populate(objectMap, "location", p.Location) - populate(objectMap, "name", p.Name) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "sku", p.SKU) - populate(objectMap, "tags", p.Tags) - populate(objectMap, "type", p.Type) - return json.Marshal(objectMap) -} - -// 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, "location", r.Location) - populate(objectMap, "name", r.Name) - populate(objectMap, "sku", r.SKU) - populate(objectMap, "tags", r.Tags) - populate(objectMap, "type", r.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type SharedAccessAuthorizationRuleProperties. -func (s SharedAccessAuthorizationRuleProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "claimType", s.ClaimType) - populate(objectMap, "claimValue", s.ClaimValue) - populate(objectMap, "createdTime", s.CreatedTime) - populate(objectMap, "keyName", s.KeyName) - populate(objectMap, "modifiedTime", s.ModifiedTime) - populate(objectMap, "primaryKey", s.PrimaryKey) - populate(objectMap, "revision", s.Revision) - populate(objectMap, "rights", s.Rights) - populate(objectMap, "secondaryKey", s.SecondaryKey) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type SharedAccessAuthorizationRuleResource. -func (s SharedAccessAuthorizationRuleResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", s.ID) - populate(objectMap, "location", s.Location) - populate(objectMap, "name", s.Name) - populate(objectMap, "properties", s.Properties) - populate(objectMap, "sku", s.SKU) - populate(objectMap, "tags", s.Tags) - populate(objectMap, "type", s.Type) - return json.Marshal(objectMap) -} - -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 -}