diff --git a/sdk/resourcemanager/devhub/armdevhub/CHANGELOG.md b/sdk/resourcemanager/devhub/armdevhub/CHANGELOG.md index ff64ee0624e7..7fb63d820e86 100644 --- a/sdk/resourcemanager/devhub/armdevhub/CHANGELOG.md +++ b/sdk/resourcemanager/devhub/armdevhub/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.3.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.2.0 (2022-10-13) ### Breaking Changes diff --git a/sdk/resourcemanager/devhub/armdevhub/README.md b/sdk/resourcemanager/devhub/armdevhub/README.md index 880c545264a1..0dd45a0dea4b 100644 --- a/sdk/resourcemanager/devhub/armdevhub/README.md +++ b/sdk/resourcemanager/devhub/armdevhub/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 Devhub 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 Devhub 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 := armdevhub.(, cred, nil) +clientFactory, err := armdevhub.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 := armdevhub.(, cred, &options) +clientFactory, err := armdevhub.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.NewWorkflowClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/devhub/armdevhub/autorest.md b/sdk/resourcemanager/devhub/armdevhub/autorest.md index 49d3891b5824..5731c7656506 100644 --- a/sdk/resourcemanager/devhub/armdevhub/autorest.md +++ b/sdk/resourcemanager/devhub/armdevhub/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/a5a115b149512b8807eab9d02bfcbd3ac0db3477/specification/developerhub/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/a5a115b149512b8807eab9d02bfcbd3ac0db3477/specification/developerhub/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.2.0 +module-version: 0.3.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/devhub/armdevhub/client_factory.go b/sdk/resourcemanager/devhub/armdevhub/client_factory.go new file mode 100644 index 000000000000..cefb2a04ea1f --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/client_factory.go @@ -0,0 +1,54 @@ +//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 armdevhub + +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) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDeveloperHubServiceClient() *DeveloperHubServiceClient { + subClient, _ := NewDeveloperHubServiceClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkflowClient() *WorkflowClient { + subClient, _ := NewWorkflowClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/devhub/armdevhub/constants.go b/sdk/resourcemanager/devhub/armdevhub/constants.go index ecb3420fa894..e44e71f571e9 100644 --- a/sdk/resourcemanager/devhub/armdevhub/constants.go +++ b/sdk/resourcemanager/devhub/armdevhub/constants.go @@ -11,7 +11,7 @@ package armdevhub const ( moduleName = "armdevhub" - moduleVersion = "v0.2.0" + moduleVersion = "v0.3.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client.go b/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client.go index f16d96fd4091..4b5cc31fa7ab 100644 --- a/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client.go +++ b/sdk/resourcemanager/devhub/armdevhub/developerhubservice_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 ( // DeveloperHubServiceClient contains the methods for the DeveloperHubServiceClient group. // Don't use this type directly, use NewDeveloperHubServiceClient() instead. type DeveloperHubServiceClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDeveloperHubServiceClient creates a new instance of DeveloperHubServiceClient 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 NewDeveloperHubServiceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeveloperHubServiceClient, 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+".DeveloperHubServiceClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DeveloperHubServiceClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // GitHubOAuth - Gets GitHubOAuth info used to authenticate users with the Developer Hub GitHub App. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-04-01-preview -// location - The name of Azure region. -// options - DeveloperHubServiceClientGitHubOAuthOptions contains the optional parameters for the DeveloperHubServiceClient.GitHubOAuth -// method. +// - location - The name of Azure region. +// - options - DeveloperHubServiceClientGitHubOAuthOptions contains the optional parameters for the DeveloperHubServiceClient.GitHubOAuth +// method. func (client *DeveloperHubServiceClient) GitHubOAuth(ctx context.Context, location string, options *DeveloperHubServiceClientGitHubOAuthOptions) (DeveloperHubServiceClientGitHubOAuthResponse, error) { req, err := client.gitHubOAuthCreateRequest(ctx, location, options) if err != nil { return DeveloperHubServiceClientGitHubOAuthResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DeveloperHubServiceClientGitHubOAuthResponse{}, err } @@ -87,7 +77,7 @@ func (client *DeveloperHubServiceClient) gitHubOAuthCreateRequest(ctx context.Co 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 } @@ -112,18 +102,19 @@ func (client *DeveloperHubServiceClient) gitHubOAuthHandleResponse(resp *http.Re // GitHubOAuthCallback - Callback URL to hit once authenticated with GitHub App to have the service store the OAuth token. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-04-01-preview -// location - The name of Azure region. -// code - The code response from authenticating the GitHub App. -// state - The state response from authenticating the GitHub App. -// options - DeveloperHubServiceClientGitHubOAuthCallbackOptions contains the optional parameters for the DeveloperHubServiceClient.GitHubOAuthCallback -// method. +// - location - The name of Azure region. +// - code - The code response from authenticating the GitHub App. +// - state - The state response from authenticating the GitHub App. +// - options - DeveloperHubServiceClientGitHubOAuthCallbackOptions contains the optional parameters for the DeveloperHubServiceClient.GitHubOAuthCallback +// method. func (client *DeveloperHubServiceClient) GitHubOAuthCallback(ctx context.Context, location string, code string, state string, options *DeveloperHubServiceClientGitHubOAuthCallbackOptions) (DeveloperHubServiceClientGitHubOAuthCallbackResponse, error) { req, err := client.gitHubOAuthCallbackCreateRequest(ctx, location, code, state, options) if err != nil { return DeveloperHubServiceClientGitHubOAuthCallbackResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DeveloperHubServiceClientGitHubOAuthCallbackResponse{}, err } @@ -144,7 +135,7 @@ func (client *DeveloperHubServiceClient) gitHubOAuthCallbackCreateRequest(ctx co return nil, errors.New("parameter location cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) - 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 } @@ -168,16 +159,17 @@ func (client *DeveloperHubServiceClient) gitHubOAuthCallbackHandleResponse(resp // ListGitHubOAuth - Callback URL to hit once authenticated with GitHub App to have the service store the OAuth token. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-04-01-preview -// location - The name of Azure region. -// options - DeveloperHubServiceClientListGitHubOAuthOptions contains the optional parameters for the DeveloperHubServiceClient.ListGitHubOAuth -// method. +// - location - The name of Azure region. +// - options - DeveloperHubServiceClientListGitHubOAuthOptions contains the optional parameters for the DeveloperHubServiceClient.ListGitHubOAuth +// method. func (client *DeveloperHubServiceClient) ListGitHubOAuth(ctx context.Context, location string, options *DeveloperHubServiceClientListGitHubOAuthOptions) (DeveloperHubServiceClientListGitHubOAuthResponse, error) { req, err := client.listGitHubOAuthCreateRequest(ctx, location, options) if err != nil { return DeveloperHubServiceClientListGitHubOAuthResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DeveloperHubServiceClientListGitHubOAuthResponse{}, err } @@ -198,7 +190,7 @@ func (client *DeveloperHubServiceClient) listGitHubOAuthCreateRequest(ctx contex return nil, errors.New("parameter location cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) - 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/devhub/armdevhub/developerhubservice_client_example_test.go b/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client_example_test.go index 369fd0319d38..f146c03df0d8 100644 --- a/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client_example_test.go +++ b/sdk/resourcemanager/devhub/armdevhub/developerhubservice_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 armdevhub_test @@ -17,62 +18,88 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devhub/armdevhub" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/GitHubOAuth.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a5a115b149512b8807eab9d02bfcbd3ac0db3477/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/GitHubOAuth.json func ExampleDeveloperHubServiceClient_GitHubOAuth() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdevhub.NewDeveloperHubServiceClient("subscriptionId1", cred, nil) + clientFactory, err := armdevhub.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GitHubOAuth(ctx, "eastus2euap", &armdevhub.DeveloperHubServiceClientGitHubOAuthOptions{Parameters: &armdevhub.GitHubOAuthCallRequest{ + res, err := clientFactory.NewDeveloperHubServiceClient().GitHubOAuth(ctx, "eastus2euap", &armdevhub.DeveloperHubServiceClientGitHubOAuthOptions{Parameters: &armdevhub.GitHubOAuthCallRequest{ RedirectURL: to.Ptr("https://ms.portal.azure.com/aks"), }, }) 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.GitHubOAuthInfoResponse = armdevhub.GitHubOAuthInfoResponse{ + // AuthURL: to.Ptr("https://github.com/login/oauth/authorize?client_id=11111111&redirect_uri=https://management.azure.com/subscriptions/subscriptionId1/providers/Microsoft.DevHub/locations/eastus2euap/githuboauth&state=2345678-3456-7890-5678-012345678901&scope=repo,user:email,workflow"), + // Token: to.Ptr(""), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/GitHubOAuthCallback.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a5a115b149512b8807eab9d02bfcbd3ac0db3477/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/GitHubOAuthCallback.json func ExampleDeveloperHubServiceClient_GitHubOAuthCallback() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdevhub.NewDeveloperHubServiceClient("subscriptionId1", cred, nil) + clientFactory, err := armdevhub.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GitHubOAuthCallback(ctx, "eastus2euap", "3584d83530557fdd1f46af8289938c8ef79f9dc5", "12345678-3456-7890-5678-012345678901", nil) + res, err := clientFactory.NewDeveloperHubServiceClient().GitHubOAuthCallback(ctx, "eastus2euap", "3584d83530557fdd1f46af8289938c8ef79f9dc5", "12345678-3456-7890-5678-012345678901", 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.GitHubOAuthResponse = armdevhub.GitHubOAuthResponse{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.DevHub/locations/githuboauth"), + // ID: to.Ptr("/subscriptions/subscriptionId1/providers/Microsoft.DevHub/locations/eastus2euap/githuboauth/default"), + // Properties: &armdevhub.GitHubOAuthProperties{ + // Username: to.Ptr("user"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/GitHubOAuth_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a5a115b149512b8807eab9d02bfcbd3ac0db3477/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/GitHubOAuth_List.json func ExampleDeveloperHubServiceClient_ListGitHubOAuth() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdevhub.NewDeveloperHubServiceClient("subscriptionId1", cred, nil) + clientFactory, err := armdevhub.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListGitHubOAuth(ctx, "eastus2euap", nil) + res, err := clientFactory.NewDeveloperHubServiceClient().ListGitHubOAuth(ctx, "eastus2euap", 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.GitHubOAuthListResponse = armdevhub.GitHubOAuthListResponse{ + // Value: []*armdevhub.GitHubOAuthResponse{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.DevHub/locations/githuboauth"), + // ID: to.Ptr("/subscriptions/subscriptionId1/providers/Microsoft.DevHub/locations/eastus2euap/githuboauth/default"), + // Properties: &armdevhub.GitHubOAuthProperties{ + // Username: to.Ptr("user"), + // }, + // }}, + // } } diff --git a/sdk/resourcemanager/devhub/armdevhub/go.mod b/sdk/resourcemanager/devhub/armdevhub/go.mod index 615147405d2d..23fe0659d9de 100644 --- a/sdk/resourcemanager/devhub/armdevhub/go.mod +++ b/sdk/resourcemanager/devhub/armdevhub/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devhub/armdevhub 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/devhub/armdevhub/go.sum b/sdk/resourcemanager/devhub/armdevhub/go.sum index 8828b17b1853..8ba445a8c4da 100644 --- a/sdk/resourcemanager/devhub/armdevhub/go.sum +++ b/sdk/resourcemanager/devhub/armdevhub/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/devhub/armdevhub/models.go b/sdk/resourcemanager/devhub/armdevhub/models.go index 19e1272c49b8..dfc25a0f60f0 100644 --- a/sdk/resourcemanager/devhub/armdevhub/models.go +++ b/sdk/resourcemanager/devhub/armdevhub/models.go @@ -283,13 +283,14 @@ type WorkflowClientGetOptions struct { // placeholder for future optional parameters } -// WorkflowClientListByResourceGroupOptions contains the optional parameters for the WorkflowClient.ListByResourceGroup method. +// WorkflowClientListByResourceGroupOptions contains the optional parameters for the WorkflowClient.NewListByResourceGroupPager +// method. type WorkflowClientListByResourceGroupOptions struct { // The ManagedCluster resource associated with the workflows. ManagedClusterResource *string } -// WorkflowClientListOptions contains the optional parameters for the WorkflowClient.List method. +// WorkflowClientListOptions contains the optional parameters for the WorkflowClient.NewListPager method. type WorkflowClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/devhub/armdevhub/models_serde.go b/sdk/resourcemanager/devhub/armdevhub/models_serde.go index 064c3efa8269..4407e191d680 100644 --- a/sdk/resourcemanager/devhub/armdevhub/models_serde.go +++ b/sdk/resourcemanager/devhub/armdevhub/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type ACR. func (a ACR) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "acrRegistryName", a.AcrRegistryName) populate(objectMap, "acrRepositoryName", a.AcrRepositoryName) populate(objectMap, "acrResourceGroup", a.AcrResourceGroup) @@ -57,7 +57,7 @@ func (a *ACR) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DeleteWorkflowResponse. func (d DeleteWorkflowResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "status", d.Status) return json.Marshal(objectMap) } @@ -84,7 +84,7 @@ func (d *DeleteWorkflowResponse) 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, "helmChartPath", d.HelmChartPath) populate(objectMap, "helmValues", d.HelmValues) populate(objectMap, "kubeManifestLocations", d.KubeManifestLocations) @@ -127,7 +127,7 @@ func (d *DeploymentProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GitHubOAuthCallRequest. func (g GitHubOAuthCallRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "redirectUrl", g.RedirectURL) return json.Marshal(objectMap) } @@ -154,7 +154,7 @@ func (g *GitHubOAuthCallRequest) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GitHubOAuthInfoResponse. func (g GitHubOAuthInfoResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "authURL", g.AuthURL) populate(objectMap, "token", g.Token) return json.Marshal(objectMap) @@ -185,7 +185,7 @@ func (g *GitHubOAuthInfoResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GitHubOAuthListResponse. func (g GitHubOAuthListResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", g.Value) return json.Marshal(objectMap) } @@ -212,7 +212,7 @@ func (g *GitHubOAuthListResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GitHubOAuthProperties. func (g GitHubOAuthProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "username", g.Username) return json.Marshal(objectMap) } @@ -239,7 +239,7 @@ func (g *GitHubOAuthProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GitHubOAuthResponse. func (g GitHubOAuthResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", g.ID) populate(objectMap, "name", g.Name) populate(objectMap, "properties", g.Properties) @@ -282,7 +282,7 @@ func (g *GitHubOAuthResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GitHubWorkflowProfile. func (g GitHubWorkflowProfile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "acr", g.Acr) populate(objectMap, "aksResourceId", g.AksResourceID) populate(objectMap, "authStatus", g.AuthStatus) @@ -365,7 +365,7 @@ func (g *GitHubWorkflowProfile) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GitHubWorkflowProfileOidcCredentials. func (g GitHubWorkflowProfileOidcCredentials) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "azureClientId", g.AzureClientID) populate(objectMap, "azureTenantId", g.AzureTenantID) return json.Marshal(objectMap) @@ -396,7 +396,7 @@ func (g *GitHubWorkflowProfileOidcCredentials) 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) @@ -439,7 +439,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) @@ -478,7 +478,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) @@ -509,7 +509,7 @@ func (o *OperationListResult) 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) @@ -556,7 +556,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) } @@ -583,7 +583,7 @@ func (t *TagsObject) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Workflow. func (w Workflow) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", w.ID) populate(objectMap, "location", w.Location) populate(objectMap, "name", w.Name) @@ -634,7 +634,7 @@ func (w *Workflow) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type WorkflowListResult. func (w WorkflowListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", w.NextLink) populate(objectMap, "value", w.Value) return json.Marshal(objectMap) @@ -665,7 +665,7 @@ func (w *WorkflowListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type WorkflowProperties. func (w WorkflowProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "githubWorkflowProfile", w.GithubWorkflowProfile) return json.Marshal(objectMap) } @@ -692,7 +692,7 @@ func (w *WorkflowProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type WorkflowRun. func (w WorkflowRun) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "lastRunAt", w.LastRunAt) populate(objectMap, "succeeded", w.Succeeded) populate(objectMap, "workflowRunURL", w.WorkflowRunURL) @@ -725,7 +725,7 @@ func (w *WorkflowRun) 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) { @@ -735,7 +735,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/devhub/armdevhub/operations_client.go b/sdk/resourcemanager/devhub/armdevhub/operations_client.go index f4532c4d90ef..53db6dd99b04 100644 --- a/sdk/resourcemanager/devhub/armdevhub/operations_client.go +++ b/sdk/resourcemanager/devhub/armdevhub/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 - Returns list of operations. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-04-01-preview -// 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.DevHub/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/devhub/armdevhub/operations_client_example_test.go b/sdk/resourcemanager/devhub/armdevhub/operations_client_example_test.go index 6ad34d3f2ae4..28edf2b79d7b 100644 --- a/sdk/resourcemanager/devhub/armdevhub/operations_client_example_test.go +++ b/sdk/resourcemanager/devhub/armdevhub/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 armdevhub_test @@ -16,21 +17,34 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devhub/armdevhub" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/Operation_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a5a115b149512b8807eab9d02bfcbd3ac0db3477/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/Operation_List.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 := armdevhub.NewOperationsClient(cred, nil) + clientFactory, err := armdevhub.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.OperationListResult = armdevhub.OperationListResult{ + // Value: []*armdevhub.Operation{ + // { + // Name: to.Ptr("Microsoft.DevHub/workflows/read"), + // Display: &armdevhub.OperationDisplay{ + // Description: to.Ptr("Gets workflow"), + // Operation: to.Ptr("Get workflow"), + // Provider: to.Ptr("Microsoft Developer Hub"), + // Resource: to.Ptr("Workflows"), + // }, + // }}, + // } } diff --git a/sdk/resourcemanager/devhub/armdevhub/response_types.go b/sdk/resourcemanager/devhub/armdevhub/response_types.go index d2abb036052a..db14dd619c28 100644 --- a/sdk/resourcemanager/devhub/armdevhub/response_types.go +++ b/sdk/resourcemanager/devhub/armdevhub/response_types.go @@ -44,12 +44,12 @@ type WorkflowClientGetResponse struct { Workflow } -// WorkflowClientListByResourceGroupResponse contains the response from method WorkflowClient.ListByResourceGroup. +// WorkflowClientListByResourceGroupResponse contains the response from method WorkflowClient.NewListByResourceGroupPager. type WorkflowClientListByResourceGroupResponse struct { WorkflowListResult } -// WorkflowClientListResponse contains the response from method WorkflowClient.List. +// WorkflowClientListResponse contains the response from method WorkflowClient.NewListPager. type WorkflowClientListResponse struct { WorkflowListResult } diff --git a/sdk/resourcemanager/devhub/armdevhub/time_rfc3339.go b/sdk/resourcemanager/devhub/armdevhub/time_rfc3339.go index cc5fb17bbbe2..bf269b23e336 100644 --- a/sdk/resourcemanager/devhub/armdevhub/time_rfc3339.go +++ b/sdk/resourcemanager/devhub/armdevhub/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/devhub/armdevhub/workflow_client.go b/sdk/resourcemanager/devhub/armdevhub/workflow_client.go index 6fab21007b36..cdebabb4bc58 100644 --- a/sdk/resourcemanager/devhub/armdevhub/workflow_client.go +++ b/sdk/resourcemanager/devhub/armdevhub/workflow_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 ( // WorkflowClient contains the methods for the Workflow group. // Don't use this type directly, use NewWorkflowClient() instead. type WorkflowClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewWorkflowClient creates a new instance of WorkflowClient 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 NewWorkflowClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowClient, 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+".WorkflowClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &WorkflowClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Creates or updates a workflow // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-04-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// workflowName - The name of the workflow resource. -// options - WorkflowClientCreateOrUpdateOptions contains the optional parameters for the WorkflowClient.CreateOrUpdate method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workflowName - The name of the workflow resource. +// - options - WorkflowClientCreateOrUpdateOptions contains the optional parameters for the WorkflowClient.CreateOrUpdate method. func (client *WorkflowClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workflowName string, parameters Workflow, options *WorkflowClientCreateOrUpdateOptions) (WorkflowClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, workflowName, parameters, options) if err != nil { return WorkflowClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowClientCreateOrUpdateResponse{}, err } @@ -91,7 +81,7 @@ func (client *WorkflowClient) createOrUpdateCreateRequest(ctx context.Context, r return nil, errors.New("parameter workflowName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workflowName}", url.PathEscape(workflowName)) - 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 } @@ -113,16 +103,17 @@ func (client *WorkflowClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Deletes a workflow // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-04-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// workflowName - The name of the workflow resource. -// options - WorkflowClientDeleteOptions contains the optional parameters for the WorkflowClient.Delete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workflowName - The name of the workflow resource. +// - options - WorkflowClientDeleteOptions contains the optional parameters for the WorkflowClient.Delete method. func (client *WorkflowClient) Delete(ctx context.Context, resourceGroupName string, workflowName string, options *WorkflowClientDeleteOptions) (WorkflowClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, workflowName, options) if err != nil { return WorkflowClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowClientDeleteResponse{}, err } @@ -147,7 +138,7 @@ func (client *WorkflowClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter workflowName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workflowName}", url.PathEscape(workflowName)) - 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 } @@ -169,16 +160,17 @@ func (client *WorkflowClient) deleteHandleResponse(resp *http.Response) (Workflo // Get - Gets a workflow. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-04-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// workflowName - The name of the workflow resource. -// options - WorkflowClientGetOptions contains the optional parameters for the WorkflowClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workflowName - The name of the workflow resource. +// - options - WorkflowClientGetOptions contains the optional parameters for the WorkflowClient.Get method. func (client *WorkflowClient) Get(ctx context.Context, resourceGroupName string, workflowName string, options *WorkflowClientGetOptions) (WorkflowClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, workflowName, options) if err != nil { return WorkflowClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowClientGetResponse{}, err } @@ -203,7 +195,7 @@ func (client *WorkflowClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter workflowName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workflowName}", url.PathEscape(workflowName)) - 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 } @@ -224,8 +216,9 @@ func (client *WorkflowClient) getHandleResponse(resp *http.Response) (WorkflowCl } // NewListPager - Gets a list of workflows associated with the specified subscription. +// // Generated from API version 2022-04-01-preview -// options - WorkflowClientListOptions contains the optional parameters for the WorkflowClient.List method. +// - options - WorkflowClientListOptions contains the optional parameters for the WorkflowClient.NewListPager method. func (client *WorkflowClient) NewListPager(options *WorkflowClientListOptions) *runtime.Pager[WorkflowClientListResponse] { return runtime.NewPager(runtime.PagingHandler[WorkflowClientListResponse]{ More: func(page WorkflowClientListResponse) bool { @@ -242,7 +235,7 @@ func (client *WorkflowClient) NewListPager(options *WorkflowClientListOptions) * if err != nil { return WorkflowClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowClientListResponse{}, err } @@ -261,7 +254,7 @@ func (client *WorkflowClient) listCreateRequest(ctx context.Context, options *Wo 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 } @@ -282,10 +275,11 @@ func (client *WorkflowClient) listHandleResponse(resp *http.Response) (WorkflowC } // NewListByResourceGroupPager - Gets a list of workflows within a resource group. +// // Generated from API version 2022-04-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - WorkflowClientListByResourceGroupOptions contains the optional parameters for the WorkflowClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - WorkflowClientListByResourceGroupOptions contains the optional parameters for the WorkflowClient.NewListByResourceGroupPager +// method. func (client *WorkflowClient) NewListByResourceGroupPager(resourceGroupName string, options *WorkflowClientListByResourceGroupOptions) *runtime.Pager[WorkflowClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[WorkflowClientListByResourceGroupResponse]{ More: func(page WorkflowClientListByResourceGroupResponse) bool { @@ -302,7 +296,7 @@ func (client *WorkflowClient) NewListByResourceGroupPager(resourceGroupName stri if err != nil { return WorkflowClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowClientListByResourceGroupResponse{}, err } @@ -325,7 +319,7 @@ func (client *WorkflowClient) listByResourceGroupCreateRequest(ctx context.Conte 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 } @@ -350,17 +344,18 @@ func (client *WorkflowClient) listByResourceGroupHandleResponse(resp *http.Respo // UpdateTags - Updates tags on a workflow. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-04-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// workflowName - The name of the workflow resource. -// parameters - Parameters supplied to the Update Workflow Tags operation. -// options - WorkflowClientUpdateTagsOptions contains the optional parameters for the WorkflowClient.UpdateTags method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workflowName - The name of the workflow resource. +// - parameters - Parameters supplied to the Update Workflow Tags operation. +// - options - WorkflowClientUpdateTagsOptions contains the optional parameters for the WorkflowClient.UpdateTags method. func (client *WorkflowClient) UpdateTags(ctx context.Context, resourceGroupName string, workflowName string, parameters TagsObject, options *WorkflowClientUpdateTagsOptions) (WorkflowClientUpdateTagsResponse, error) { req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, workflowName, parameters, options) if err != nil { return WorkflowClientUpdateTagsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowClientUpdateTagsResponse{}, err } @@ -385,7 +380,7 @@ func (client *WorkflowClient) updateTagsCreateRequest(ctx context.Context, resou return nil, errors.New("parameter workflowName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workflowName}", url.PathEscape(workflowName)) - 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/devhub/armdevhub/workflow_client_example_test.go b/sdk/resourcemanager/devhub/armdevhub/workflow_client_example_test.go index d1c27c763561..595146e18558 100644 --- a/sdk/resourcemanager/devhub/armdevhub/workflow_client_example_test.go +++ b/sdk/resourcemanager/devhub/armdevhub/workflow_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 armdevhub_test @@ -17,85 +18,245 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devhub/armdevhub" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/Workflow_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a5a115b149512b8807eab9d02bfcbd3ac0db3477/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/Workflow_List.json func ExampleWorkflowClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdevhub.NewWorkflowClient("subscriptionId1", cred, nil) + clientFactory, err := armdevhub.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewWorkflowClient().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.WorkflowListResult = armdevhub.WorkflowListResult{ + // Value: []*armdevhub.Workflow{ + // { + // Name: to.Ptr("workflow1"), + // Type: to.Ptr("Micfosoft.DevHub/Workflow"), + // ID: to.Ptr("/subscription/subscriptionId1/resourceGroups/resourceGroup1/providers/Microsoft.DevHub/workflow/workflow1"), + // SystemData: &armdevhub.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55+00:00"); return t}()), + // CreatedBy: to.Ptr("foo@contoso.com"), + // CreatedByType: to.Ptr(armdevhub.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55+00:00"); return t}()), + // LastModifiedBy: to.Ptr("foo@contoso.com"), + // LastModifiedByType: to.Ptr(armdevhub.CreatedByTypeUser), + // }, + // Location: to.Ptr("location1"), + // Tags: map[string]*string{ + // "appname": to.Ptr("testapp"), + // }, + // Properties: &armdevhub.WorkflowProperties{ + // GithubWorkflowProfile: &armdevhub.GitHubWorkflowProfile{ + // Acr: &armdevhub.ACR{ + // AcrRegistryName: to.Ptr("registry1"), + // AcrRepositoryName: to.Ptr("repo1"), + // AcrResourceGroup: to.Ptr("resourceGroup1"), + // AcrSubscriptionID: to.Ptr("subscriptionId1"), + // }, + // AksResourceID: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1"), + // AuthStatus: to.Ptr(armdevhub.ManifestType("Authorized")), + // BranchName: to.Ptr("branch1"), + // DeploymentProperties: &armdevhub.DeploymentProperties{ + // ManifestType: to.Ptr(armdevhub.ManifestTypeKube), + // Overrides: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // DockerBuildContext: to.Ptr("repo1/src/"), + // Dockerfile: to.Ptr("repo1/images/Dockerfile"), + // OidcCredentials: &armdevhub.GitHubWorkflowProfileOidcCredentials{ + // AzureClientID: to.Ptr("12345678-3456-7890-5678-012345678901"), + // AzureTenantID: to.Ptr("66666666-3456-7890-5678-012345678901"), + // }, + // PrStatus: to.Ptr(armdevhub.PullRequestStatusSubmitted), + // PrURL: to.Ptr("https://github.com/User/repo1/pull/6567"), + // PullNumber: to.Ptr[int32](6567), + // RepositoryName: to.Ptr("repo1"), + // RepositoryOwner: to.Ptr("owner1"), + // }, + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/Workflow_ListByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a5a115b149512b8807eab9d02bfcbd3ac0db3477/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/Workflow_ListByResourceGroup.json func ExampleWorkflowClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdevhub.NewWorkflowClient("subscriptionId1", cred, nil) + clientFactory, err := armdevhub.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("resourceGroup1", &armdevhub.WorkflowClientListByResourceGroupOptions{ManagedClusterResource: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1")}) + pager := clientFactory.NewWorkflowClient().NewListByResourceGroupPager("resourceGroup1", &armdevhub.WorkflowClientListByResourceGroupOptions{ManagedClusterResource: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1")}) 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.WorkflowListResult = armdevhub.WorkflowListResult{ + // Value: []*armdevhub.Workflow{ + // { + // Name: to.Ptr("workflow1"), + // Type: to.Ptr("Micfosoft.DevHub/Workflow"), + // ID: to.Ptr("/subscription/subscriptionId1/resourceGroups/resourceGroup1/providers/Microsoft.DevHub/workflow/workflow1"), + // SystemData: &armdevhub.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55+00:00"); return t}()), + // CreatedBy: to.Ptr("foo@contoso.com"), + // CreatedByType: to.Ptr(armdevhub.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55+00:00"); return t}()), + // LastModifiedBy: to.Ptr("foo@contoso.com"), + // LastModifiedByType: to.Ptr(armdevhub.CreatedByTypeUser), + // }, + // Location: to.Ptr("location1"), + // Tags: map[string]*string{ + // "appname": to.Ptr("testapp"), + // }, + // Properties: &armdevhub.WorkflowProperties{ + // GithubWorkflowProfile: &armdevhub.GitHubWorkflowProfile{ + // Acr: &armdevhub.ACR{ + // AcrRegistryName: to.Ptr("registry1"), + // AcrRepositoryName: to.Ptr("repo1"), + // AcrResourceGroup: to.Ptr("resourceGroup1"), + // AcrSubscriptionID: to.Ptr("subscriptionId1"), + // }, + // AksResourceID: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1"), + // AuthStatus: to.Ptr(armdevhub.ManifestType("Authorized")), + // BranchName: to.Ptr("branch1"), + // DeploymentProperties: &armdevhub.DeploymentProperties{ + // ManifestType: to.Ptr(armdevhub.ManifestTypeKube), + // Overrides: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // DockerBuildContext: to.Ptr("repo1/src/"), + // Dockerfile: to.Ptr("repo1/images/Dockerfile"), + // LastWorkflowRun: &armdevhub.WorkflowRun{ + // LastRunAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-01T12:34:56.000Z"); return t}()), + // Succeeded: to.Ptr(true), + // WorkflowRunURL: to.Ptr("https://github.com/User/repo1/actions/runs/1820640230"), + // }, + // OidcCredentials: &armdevhub.GitHubWorkflowProfileOidcCredentials{ + // AzureClientID: to.Ptr("12345678-3456-7890-5678-012345678901"), + // AzureTenantID: to.Ptr("66666666-3456-7890-5678-012345678901"), + // }, + // PrStatus: to.Ptr(armdevhub.PullRequestStatusMerged), + // PrURL: to.Ptr("https://github.com/User/repo1/pull/6567"), + // PullNumber: to.Ptr[int32](6567), + // RepositoryName: to.Ptr("repo1"), + // RepositoryOwner: to.Ptr("owner1"), + // }, + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/Workflow_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a5a115b149512b8807eab9d02bfcbd3ac0db3477/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/Workflow_Get.json func ExampleWorkflowClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdevhub.NewWorkflowClient("subscriptionId1", cred, nil) + clientFactory, err := armdevhub.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "resourceGroup1", "workflow1", nil) + res, err := clientFactory.NewWorkflowClient().Get(ctx, "resourceGroup1", "workflow1", 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.Workflow = armdevhub.Workflow{ + // Name: to.Ptr("workflow1"), + // Type: to.Ptr("Micfosoft.DevHub/Workflow"), + // ID: to.Ptr("/subscription/subscriptionId1/resourceGroups/resourceGroup1/providers/Microsoft.DevHub/workflow/workflow1"), + // SystemData: &armdevhub.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55+00:00"); return t}()), + // CreatedBy: to.Ptr("foo@contoso.com"), + // CreatedByType: to.Ptr(armdevhub.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55+00:00"); return t}()), + // LastModifiedBy: to.Ptr("foo@contoso.com"), + // LastModifiedByType: to.Ptr(armdevhub.CreatedByTypeUser), + // }, + // Location: to.Ptr("location1"), + // Tags: map[string]*string{ + // "appname": to.Ptr("testapp"), + // }, + // Properties: &armdevhub.WorkflowProperties{ + // GithubWorkflowProfile: &armdevhub.GitHubWorkflowProfile{ + // Acr: &armdevhub.ACR{ + // AcrRegistryName: to.Ptr("registry1"), + // AcrRepositoryName: to.Ptr("repo1"), + // AcrResourceGroup: to.Ptr("resourceGroup1"), + // AcrSubscriptionID: to.Ptr("subscriptionId1"), + // }, + // AksResourceID: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1"), + // AuthStatus: to.Ptr(armdevhub.ManifestType("Authorized")), + // BranchName: to.Ptr("branch1"), + // DeploymentProperties: &armdevhub.DeploymentProperties{ + // ManifestType: to.Ptr(armdevhub.ManifestTypeKube), + // Overrides: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // DockerBuildContext: to.Ptr("repo1/src/"), + // Dockerfile: to.Ptr("repo1/images/Dockerfile"), + // LastWorkflowRun: &armdevhub.WorkflowRun{ + // LastRunAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-01T12:34:56.000Z"); return t}()), + // Succeeded: to.Ptr(true), + // WorkflowRunURL: to.Ptr("https://github.com/User/repo1/actions/runs/1820640230"), + // }, + // OidcCredentials: &armdevhub.GitHubWorkflowProfileOidcCredentials{ + // AzureClientID: to.Ptr("12345678-3456-7890-5678-012345678901"), + // AzureTenantID: to.Ptr("66666666-3456-7890-5678-012345678901"), + // }, + // PrStatus: to.Ptr(armdevhub.PullRequestStatusMerged), + // PrURL: to.Ptr("https://github.com/User/repo1/pull/6567"), + // PullNumber: to.Ptr[int32](6567), + // RepositoryName: to.Ptr("repo1"), + // RepositoryOwner: to.Ptr("owner1"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/Workflow_CreateOrUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a5a115b149512b8807eab9d02bfcbd3ac0db3477/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/Workflow_CreateOrUpdate.json func ExampleWorkflowClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdevhub.NewWorkflowClient("subscriptionId1", cred, nil) + clientFactory, err := armdevhub.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "resourceGroup1", "workflow1", armdevhub.Workflow{ + res, err := clientFactory.NewWorkflowClient().CreateOrUpdate(ctx, "resourceGroup1", "workflow1", armdevhub.Workflow{ Location: to.Ptr("location1"), Tags: map[string]*string{ "appname": to.Ptr("testApp"), @@ -132,41 +293,95 @@ func ExampleWorkflowClient_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.Workflow = armdevhub.Workflow{ + // Name: to.Ptr("workflow1"), + // Type: to.Ptr("Micfosoft.DevHub/Workflow"), + // ID: to.Ptr("/subscription/subscriptionId1/resourceGroups/resourceGroup1/providers/Microsoft.DevHub/workflow/workflow1"), + // SystemData: &armdevhub.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55+00:00"); return t}()), + // CreatedBy: to.Ptr("foo@contoso.com"), + // CreatedByType: to.Ptr(armdevhub.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55+00:00"); return t}()), + // LastModifiedBy: to.Ptr("foo@contoso.com"), + // LastModifiedByType: to.Ptr(armdevhub.CreatedByTypeUser), + // }, + // Location: to.Ptr("location1"), + // Tags: map[string]*string{ + // "appname": to.Ptr("testapp"), + // }, + // Properties: &armdevhub.WorkflowProperties{ + // GithubWorkflowProfile: &armdevhub.GitHubWorkflowProfile{ + // Acr: &armdevhub.ACR{ + // AcrRegistryName: to.Ptr("registry1"), + // AcrRepositoryName: to.Ptr("repo1"), + // AcrResourceGroup: to.Ptr("resourceGroup1"), + // AcrSubscriptionID: to.Ptr("subscriptionId1"), + // }, + // AksResourceID: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1"), + // AuthStatus: to.Ptr(armdevhub.ManifestType("Authorized")), + // BranchName: to.Ptr("branch2"), + // DeploymentProperties: &armdevhub.DeploymentProperties{ + // HelmChartPath: to.Ptr("/src/charts"), + // HelmValues: to.Ptr("/src/chars/values.yaml"), + // ManifestType: to.Ptr(armdevhub.ManifestTypeHelm), + // Overrides: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // DockerBuildContext: to.Ptr("repo2/src/"), + // Dockerfile: to.Ptr("repo2/images/Dockerfile"), + // OidcCredentials: &armdevhub.GitHubWorkflowProfileOidcCredentials{ + // AzureClientID: to.Ptr("12345678-3456-7890-5678-012345678901"), + // AzureTenantID: to.Ptr("66666666-3456-7890-5678-012345678901"), + // }, + // PrStatus: to.Ptr(armdevhub.PullRequestStatusSubmitted), + // PrURL: to.Ptr("https://github.com/User/repo2/pull/6567"), + // PullNumber: to.Ptr[int32](6567), + // RepositoryName: to.Ptr("repo2"), + // RepositoryOwner: to.Ptr("owner1"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/Workflow_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a5a115b149512b8807eab9d02bfcbd3ac0db3477/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/Workflow_Delete.json func ExampleWorkflowClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdevhub.NewWorkflowClient("subscriptionId1", cred, nil) + clientFactory, err := armdevhub.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Delete(ctx, "resourceGroup1", "workflow1", nil) + res, err := clientFactory.NewWorkflowClient().Delete(ctx, "resourceGroup1", "workflow1", 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.DeleteWorkflowResponse = armdevhub.DeleteWorkflowResponse{ + // Status: to.Ptr("workflow deleted successfully"), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/Workflow_UpdateTags.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a5a115b149512b8807eab9d02bfcbd3ac0db3477/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/Workflow_UpdateTags.json func ExampleWorkflowClient_UpdateTags() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdevhub.NewWorkflowClient("subscriptionId1", cred, nil) + clientFactory, err := armdevhub.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.UpdateTags(ctx, "resourceGroup1", "workflow1", armdevhub.TagsObject{ + res, err := clientFactory.NewWorkflowClient().UpdateTags(ctx, "resourceGroup1", "workflow1", armdevhub.TagsObject{ Tags: map[string]*string{ "promote": to.Ptr("false"), "resourceEnv": to.Ptr("testing"), @@ -175,6 +390,61 @@ func ExampleWorkflowClient_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.Workflow = armdevhub.Workflow{ + // Name: to.Ptr("workflow1"), + // Type: to.Ptr("Micfosoft.DevHub/Workflow"), + // ID: to.Ptr("/subscription/subscriptionId1/resourceGroups/resourceGroup1/providers/Microsoft.DevHub/workflow/workflow1"), + // SystemData: &armdevhub.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55+00:00"); return t}()), + // CreatedBy: to.Ptr("foo@contoso.com"), + // CreatedByType: to.Ptr(armdevhub.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55+00:00"); return t}()), + // LastModifiedBy: to.Ptr("foo@contoso.com"), + // LastModifiedByType: to.Ptr(armdevhub.CreatedByTypeUser), + // }, + // Location: to.Ptr("location1"), + // Tags: map[string]*string{ + // "previousValue": to.Ptr("stillExists"), + // "promote": to.Ptr("false"), + // "resourceEnv": to.Ptr("testing"), + // }, + // Properties: &armdevhub.WorkflowProperties{ + // GithubWorkflowProfile: &armdevhub.GitHubWorkflowProfile{ + // Acr: &armdevhub.ACR{ + // AcrRegistryName: to.Ptr("registry1"), + // AcrRepositoryName: to.Ptr("repo1"), + // AcrResourceGroup: to.Ptr("resourceGroup1"), + // AcrSubscriptionID: to.Ptr("subscriptionId1"), + // }, + // AksResourceID: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1"), + // AuthStatus: to.Ptr(armdevhub.ManifestType("Authorized")), + // BranchName: to.Ptr("branch1"), + // DeploymentProperties: &armdevhub.DeploymentProperties{ + // ManifestType: to.Ptr(armdevhub.ManifestTypeKube), + // Overrides: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // DockerBuildContext: to.Ptr("repo1/src/"), + // Dockerfile: to.Ptr("repo1/images/Dockerfile"), + // LastWorkflowRun: &armdevhub.WorkflowRun{ + // LastRunAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-01T12:34:56.000Z"); return t}()), + // Succeeded: to.Ptr(true), + // WorkflowRunURL: to.Ptr("https://github.com/User/repo1/actions/runs/1820640230"), + // }, + // OidcCredentials: &armdevhub.GitHubWorkflowProfileOidcCredentials{ + // AzureClientID: to.Ptr("12345678-3456-7890-5678-012345678901"), + // AzureTenantID: to.Ptr("66666666-3456-7890-5678-012345678901"), + // }, + // PrStatus: to.Ptr(armdevhub.PullRequestStatusMerged), + // PrURL: to.Ptr("https://github.com/owner1/repo1/pull/6567"), + // PullNumber: to.Ptr[int32](6567), + // RepositoryName: to.Ptr("repo1"), + // RepositoryOwner: to.Ptr("owner1"), + // }, + // }, + // } } diff --git a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/CHANGELOG.md b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/CHANGELOG.md index d7cfc54aa6bb..e082fb0ba97d 100644 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/CHANGELOG.md +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-28) +### 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/deviceprovisioningservices/armdeviceprovisioningservices` 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/deviceprovisioningservices/armdeviceprovisioningservices/README.md b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/README.md index da55f7db103a..4e4b643e13c2 100644 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/README.md +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/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 Device Provisioning Service 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 Device Provisioning Service 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 := armdeviceprovisioningservices.NewIotDpsResourceClient(, cred, nil) +clientFactory, err := armdeviceprovisioningservices.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 := armdeviceprovisioningservices.NewIotDpsResourceClient(, cred, &options) +clientFactory, err := armdeviceprovisioningservices.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.NewIotDpsResourceClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/autorest.md b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/autorest.md index 81be3f4008dc..f9903814d006 100644 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/autorest.md +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/autorest.md @@ -8,5 +8,5 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/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/deviceprovisioningservices/armdeviceprovisioningservices/client_factory.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/client_factory.go new file mode 100644 index 000000000000..a6c6e3202ef9 --- /dev/null +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/client_factory.go @@ -0,0 +1,54 @@ +//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 armdeviceprovisioningservices + +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 identifier. +// - 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) NewDpsCertificateClient() *DpsCertificateClient { + subClient, _ := NewDpsCertificateClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewIotDpsResourceClient() *IotDpsResourceClient { + subClient, _ := NewIotDpsResourceClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_constants.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/constants.go similarity index 99% rename from sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_constants.go rename to sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/constants.go index 955c4224b41d..5211a587b94b 100644 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_constants.go +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/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 armdeviceprovisioningservices const ( moduleName = "armdeviceprovisioningservices" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // AccessRightsDescription - Rights that this key has. diff --git a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_dpscertificate_client.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/dpscertificate_client.go similarity index 86% rename from sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_dpscertificate_client.go rename to sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/dpscertificate_client.go index 8d635985850d..6f824eec86e4 100644 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_dpscertificate_client.go +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/dpscertificate_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 armdeviceprovisioningservices @@ -14,8 +15,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" @@ -28,50 +27,42 @@ import ( // DpsCertificateClient contains the methods for the DpsCertificate group. // Don't use this type directly, use NewDpsCertificateClient() instead. type DpsCertificateClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDpsCertificateClient creates a new instance of DpsCertificateClient with the specified values. -// subscriptionID - The subscription identifier. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription identifier. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewDpsCertificateClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DpsCertificateClient, 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+".DpsCertificateClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DpsCertificateClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Add new certificate or update an existing certificate. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// resourceGroupName - Resource group identifier. -// provisioningServiceName - The name of the provisioning service. -// certificateName - The name of the certificate create or update. -// certificateDescription - The certificate body. -// options - DpsCertificateClientCreateOrUpdateOptions contains the optional parameters for the DpsCertificateClient.CreateOrUpdate -// method. +// - resourceGroupName - Resource group identifier. +// - provisioningServiceName - The name of the provisioning service. +// - certificateName - The name of the certificate create or update. +// - certificateDescription - The certificate body. +// - options - DpsCertificateClientCreateOrUpdateOptions contains the optional parameters for the DpsCertificateClient.CreateOrUpdate +// method. func (client *DpsCertificateClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, certificateName string, certificateDescription CertificateResponse, options *DpsCertificateClientCreateOrUpdateOptions) (DpsCertificateClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, provisioningServiceName, certificateName, certificateDescription, options) if err != nil { return DpsCertificateClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DpsCertificateClientCreateOrUpdateResponse{}, err } @@ -100,7 +91,7 @@ func (client *DpsCertificateClient) createOrUpdateCreateRequest(ctx context.Cont 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 } @@ -125,19 +116,20 @@ func (client *DpsCertificateClient) createOrUpdateHandleResponse(resp *http.Resp // Delete - Deletes the specified certificate associated with the Provisioning Service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// resourceGroupName - Resource group identifier. -// ifMatch - ETag of the certificate -// provisioningServiceName - The name of the provisioning service. -// certificateName - This is a mandatory field, and is the logical name of the certificate that the provisioning service will -// access by. -// options - DpsCertificateClientDeleteOptions contains the optional parameters for the DpsCertificateClient.Delete method. +// - resourceGroupName - Resource group identifier. +// - ifMatch - ETag of the certificate +// - provisioningServiceName - The name of the provisioning service. +// - certificateName - This is a mandatory field, and is the logical name of the certificate that the provisioning service will +// access by. +// - options - DpsCertificateClientDeleteOptions contains the optional parameters for the DpsCertificateClient.Delete method. func (client *DpsCertificateClient) Delete(ctx context.Context, resourceGroupName string, ifMatch string, provisioningServiceName string, certificateName string, options *DpsCertificateClientDeleteOptions) (DpsCertificateClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, ifMatch, provisioningServiceName, certificateName, options) if err != nil { return DpsCertificateClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DpsCertificateClientDeleteResponse{}, err } @@ -166,7 +158,7 @@ func (client *DpsCertificateClient) deleteCreateRequest(ctx context.Context, res 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 } @@ -204,20 +196,21 @@ func (client *DpsCertificateClient) deleteCreateRequest(ctx context.Context, res // GenerateVerificationCode - Generate verification code for Proof of Possession. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// certificateName - The mandatory logical name of the certificate, that the provisioning service uses to access. -// ifMatch - ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand -// new certificate. -// resourceGroupName - name of resource group. -// provisioningServiceName - Name of provisioning service. -// options - DpsCertificateClientGenerateVerificationCodeOptions contains the optional parameters for the DpsCertificateClient.GenerateVerificationCode -// method. +// - certificateName - The mandatory logical name of the certificate, that the provisioning service uses to access. +// - ifMatch - ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand +// new certificate. +// - resourceGroupName - name of resource group. +// - provisioningServiceName - Name of provisioning service. +// - options - DpsCertificateClientGenerateVerificationCodeOptions contains the optional parameters for the DpsCertificateClient.GenerateVerificationCode +// method. func (client *DpsCertificateClient) GenerateVerificationCode(ctx context.Context, certificateName string, ifMatch string, resourceGroupName string, provisioningServiceName string, options *DpsCertificateClientGenerateVerificationCodeOptions) (DpsCertificateClientGenerateVerificationCodeResponse, error) { req, err := client.generateVerificationCodeCreateRequest(ctx, certificateName, ifMatch, resourceGroupName, provisioningServiceName, options) if err != nil { return DpsCertificateClientGenerateVerificationCodeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DpsCertificateClientGenerateVerificationCodeResponse{}, err } @@ -246,7 +239,7 @@ func (client *DpsCertificateClient) generateVerificationCodeCreateRequest(ctx co return nil, errors.New("parameter provisioningServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{provisioningServiceName}", url.PathEscape(provisioningServiceName)) - 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 } @@ -293,17 +286,18 @@ func (client *DpsCertificateClient) generateVerificationCodeHandleResponse(resp // Get - Get the certificate from the provisioning service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// certificateName - Name of the certificate to retrieve. -// resourceGroupName - Resource group identifier. -// provisioningServiceName - Name of the provisioning service the certificate is associated with. -// options - DpsCertificateClientGetOptions contains the optional parameters for the DpsCertificateClient.Get method. +// - certificateName - Name of the certificate to retrieve. +// - resourceGroupName - Resource group identifier. +// - provisioningServiceName - Name of the provisioning service the certificate is associated with. +// - options - DpsCertificateClientGetOptions contains the optional parameters for the DpsCertificateClient.Get method. func (client *DpsCertificateClient) Get(ctx context.Context, certificateName string, resourceGroupName string, provisioningServiceName string, options *DpsCertificateClientGetOptions) (DpsCertificateClientGetResponse, error) { req, err := client.getCreateRequest(ctx, certificateName, resourceGroupName, provisioningServiceName, options) if err != nil { return DpsCertificateClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DpsCertificateClientGetResponse{}, err } @@ -332,7 +326,7 @@ func (client *DpsCertificateClient) getCreateRequest(ctx context.Context, certif return nil, errors.New("parameter provisioningServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{provisioningServiceName}", url.PathEscape(provisioningServiceName)) - 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,16 +351,17 @@ func (client *DpsCertificateClient) getHandleResponse(resp *http.Response) (DpsC // List - Get all the certificates tied to the provisioning service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// resourceGroupName - Name of resource group. -// provisioningServiceName - Name of provisioning service to retrieve certificates for. -// options - DpsCertificateClientListOptions contains the optional parameters for the DpsCertificateClient.List method. +// - resourceGroupName - Name of resource group. +// - provisioningServiceName - Name of provisioning service to retrieve certificates for. +// - options - DpsCertificateClientListOptions contains the optional parameters for the DpsCertificateClient.List method. func (client *DpsCertificateClient) List(ctx context.Context, resourceGroupName string, provisioningServiceName string, options *DpsCertificateClientListOptions) (DpsCertificateClientListResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, provisioningServiceName, options) if err != nil { return DpsCertificateClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DpsCertificateClientListResponse{}, err } @@ -391,7 +386,7 @@ func (client *DpsCertificateClient) listCreateRequest(ctx context.Context, resou return nil, errors.New("parameter provisioningServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{provisioningServiceName}", url.PathEscape(provisioningServiceName)) - 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 } @@ -414,20 +409,21 @@ func (client *DpsCertificateClient) listHandleResponse(resp *http.Response) (Dps // VerifyCertificate - Verifies the certificate's private key possession by providing the leaf cert issued by the verifying // pre uploaded certificate. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// certificateName - The mandatory logical name of the certificate, that the provisioning service uses to access. -// ifMatch - ETag of the certificate. -// resourceGroupName - Resource group name. -// provisioningServiceName - Provisioning service name. -// request - The name of the certificate -// options - DpsCertificateClientVerifyCertificateOptions contains the optional parameters for the DpsCertificateClient.VerifyCertificate -// method. +// - certificateName - The mandatory logical name of the certificate, that the provisioning service uses to access. +// - ifMatch - ETag of the certificate. +// - resourceGroupName - Resource group name. +// - provisioningServiceName - Provisioning service name. +// - request - The name of the certificate +// - options - DpsCertificateClientVerifyCertificateOptions contains the optional parameters for the DpsCertificateClient.VerifyCertificate +// method. func (client *DpsCertificateClient) VerifyCertificate(ctx context.Context, certificateName string, ifMatch string, resourceGroupName string, provisioningServiceName string, request VerificationCodeRequest, options *DpsCertificateClientVerifyCertificateOptions) (DpsCertificateClientVerifyCertificateResponse, error) { req, err := client.verifyCertificateCreateRequest(ctx, certificateName, ifMatch, resourceGroupName, provisioningServiceName, request, options) if err != nil { return DpsCertificateClientVerifyCertificateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DpsCertificateClientVerifyCertificateResponse{}, err } @@ -456,7 +452,7 @@ func (client *DpsCertificateClient) verifyCertificateCreateRequest(ctx context.C return nil, errors.New("parameter provisioningServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{provisioningServiceName}", url.PathEscape(provisioningServiceName)) - 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/deviceprovisioningservices/armdeviceprovisioningservices/dpscertificate_client_example_test.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/dpscertificate_client_example_test.go new file mode 100644 index 000000000000..97a4acd4c026 --- /dev/null +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/dpscertificate_client_example_test.go @@ -0,0 +1,239 @@ +//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 armdeviceprovisioningservices_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/deviceprovisioningservices/armdeviceprovisioningservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetCertificate.json +func ExampleDpsCertificateClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDpsCertificateClient().Get(ctx, "cert", "myResourceGroup", "myFirstProvisioningService", &armdeviceprovisioningservices.DpsCertificateClientGetOptions{IfMatch: 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.CertificateResponse = armdeviceprovisioningservices.CertificateResponse{ + // Name: to.Ptr("cert"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices/Certificates"), + // Etag: to.Ptr("AAAAAAExpNs="), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/IotHubs/andbuc-hub/certificates/cert"), + // Properties: &armdeviceprovisioningservices.CertificateProperties{ + // Certificate: []byte("######################################"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:23:50 GMT"); return t}()), + // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Sat, 31 Dec 2039 23:59:59 GMT"); return t}()), + // IsVerified: to.Ptr(false), + // Subject: to.Ptr("CN=testdevice1"), + // Thumbprint: to.Ptr("97388663832D0393C9246CAB4FBA2C8677185A25"), + // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:23:50 GMT"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCertificateCreateOrUpdate.json +func ExampleDpsCertificateClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDpsCertificateClient().CreateOrUpdate(ctx, "myResourceGroup", "myFirstProvisioningService", "cert", armdeviceprovisioningservices.CertificateResponse{ + Properties: &armdeviceprovisioningservices.CertificateProperties{ + Certificate: []byte("############################################"), + }, + }, &armdeviceprovisioningservices.DpsCertificateClientCreateOrUpdateOptions{IfMatch: 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.CertificateResponse = armdeviceprovisioningservices.CertificateResponse{ + // Name: to.Ptr("cert"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices/Certificates"), + // Etag: to.Ptr("AAAAAAExpNs="), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServives/myFirstProvisioningService/certificates/cert"), + // Properties: &armdeviceprovisioningservices.CertificateProperties{ + // Certificate: []byte("############################################"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:23:50 GMT"); return t}()), + // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Sat, 31 Dec 2039 23:59:59 GMT"); return t}()), + // IsVerified: to.Ptr(false), + // Subject: to.Ptr("CN=testdevice1"), + // Thumbprint: to.Ptr("97388663832D0393C9246CAB4FBA2C8677185A25"), + // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:23:50 GMT"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSDeleteCertificate.json +func ExampleDpsCertificateClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewDpsCertificateClient().Delete(ctx, "myResourceGroup", "AAAAAAAADGk=", "myFirstProvisioningService", "cert", &armdeviceprovisioningservices.DpsCertificateClientDeleteOptions{CertificateName1: nil, + CertificateIsVerified: nil, + CertificatePurpose: nil, + CertificateCreated: nil, + CertificateLastUpdated: nil, + CertificateHasPrivateKey: nil, + CertificateNonce: 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetCertificates.json +func ExampleDpsCertificateClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDpsCertificateClient().List(ctx, "myResourceGroup", "myFirstProvisioningService", 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.CertificateListDescription = armdeviceprovisioningservices.CertificateListDescription{ + // Value: []*armdeviceprovisioningservices.CertificateResponse{ + // { + // Name: to.Ptr("cert"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices/Certificates"), + // Etag: to.Ptr("AAAAAAExpNs="), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/IotHubs/andbuc-hub/certificates/cert"), + // Properties: &armdeviceprovisioningservices.CertificateProperties{ + // Certificate: []byte("############################################"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:23:50 GMT"); return t}()), + // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Sat, 31 Dec 2039 23:59:59 GMT"); return t}()), + // IsVerified: to.Ptr(false), + // Subject: to.Ptr("CN=testdevice1"), + // Thumbprint: to.Ptr("97388663832D0393C9246CAB4FBA2C8677185A25"), + // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:23:50 GMT"); return t}()), + // }, + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGenerateVerificationCode.json +func ExampleDpsCertificateClient_GenerateVerificationCode() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDpsCertificateClient().GenerateVerificationCode(ctx, "cert", "AAAAAAAADGk=", "myResourceGroup", "myFirstProvisioningService", &armdeviceprovisioningservices.DpsCertificateClientGenerateVerificationCodeOptions{CertificateName1: nil, + CertificateIsVerified: nil, + CertificatePurpose: nil, + CertificateCreated: nil, + CertificateLastUpdated: nil, + CertificateHasPrivateKey: nil, + CertificateNonce: 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.VerificationCodeResponse = armdeviceprovisioningservices.VerificationCodeResponse{ + // Name: to.Ptr("cert"), + // Properties: &armdeviceprovisioningservices.VerificationCodeResponseProperties{ + // Certificate: []byte("###########################"), + // Created: to.Ptr("Thu, 12 Oct 2017 19:23:50 GMT"), + // Expiry: to.Ptr("Sat, 31 Dec 2039 23:59:59 GMT"), + // IsVerified: to.Ptr(false), + // Subject: to.Ptr("CN=andbucdevice1"), + // Thumbprint: to.Ptr("##############################"), + // Updated: to.Ptr("Thu, 12 Oct 2017 19:26:56 GMT"), + // VerificationCode: to.Ptr("##################################"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSVerifyCertificate.json +func ExampleDpsCertificateClient_VerifyCertificate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDpsCertificateClient().VerifyCertificate(ctx, "cert", "AAAAAAAADGk=", "myResourceGroup", "myFirstProvisioningService", armdeviceprovisioningservices.VerificationCodeRequest{ + Certificate: to.Ptr("#####################################"), + }, &armdeviceprovisioningservices.DpsCertificateClientVerifyCertificateOptions{CertificateName1: nil, + CertificateIsVerified: nil, + CertificatePurpose: nil, + CertificateCreated: nil, + CertificateLastUpdated: nil, + CertificateHasPrivateKey: nil, + CertificateNonce: 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.CertificateResponse = armdeviceprovisioningservices.CertificateResponse{ + // Name: to.Ptr("cert"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices/Certificates"), + // Etag: to.Ptr("AAAAAAExpTQ="), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServices/myFirstProvisioningService/certificates/cert"), + // Properties: &armdeviceprovisioningservices.CertificateProperties{ + // Certificate: []byte("#####################################"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:23:50 GMT"); return t}()), + // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Sat, 31 Dec 2039 23:59:59 GMT"); return t}()), + // IsVerified: to.Ptr(true), + // Subject: to.Ptr("CN=andbucdevice1"), + // Thumbprint: to.Ptr("97388663832D0393C9246CAB4FBA2C8677185A25"), + // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:26:56 GMT"); return t}()), + // }, + // } +} diff --git a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/go.mod b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/go.mod index 7691e13d240b..8dfccac728a4 100644 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/go.mod +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceprovisionings 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/deviceprovisioningservices/armdeviceprovisioningservices/go.sum b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/go.sum +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/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/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_iotdpsresource_client.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/iotdpsresource_client.go similarity index 86% rename from sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_iotdpsresource_client.go rename to sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/iotdpsresource_client.go index 4c9ca912e7f4..ab14ca731fde 100644 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_iotdpsresource_client.go +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/iotdpsresource_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 armdeviceprovisioningservices @@ -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 ( // IotDpsResourceClient contains the methods for the IotDpsResource group. // Don't use this type directly, use NewIotDpsResourceClient() instead. type IotDpsResourceClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIotDpsResourceClient creates a new instance of IotDpsResourceClient with the specified values. -// subscriptionID - The subscription identifier. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription identifier. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewIotDpsResourceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IotDpsResourceClient, 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+".IotDpsResourceClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IotDpsResourceClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -57,16 +47,17 @@ func NewIotDpsResourceClient(subscriptionID string, credential azcore.TokenCrede // CheckProvisioningServiceNameAvailability - Check if a provisioning service name is available. This will validate if the // name is syntactically valid and if the name is usable // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// arguments - Set the name parameter in the OperationInputs structure to the name of the provisioning service to check. -// options - IotDpsResourceClientCheckProvisioningServiceNameAvailabilityOptions contains the optional parameters for the -// IotDpsResourceClient.CheckProvisioningServiceNameAvailability method. +// - arguments - Set the name parameter in the OperationInputs structure to the name of the provisioning service to check. +// - options - IotDpsResourceClientCheckProvisioningServiceNameAvailabilityOptions contains the optional parameters for the +// IotDpsResourceClient.CheckProvisioningServiceNameAvailability method. func (client *IotDpsResourceClient) CheckProvisioningServiceNameAvailability(ctx context.Context, arguments OperationInputs, options *IotDpsResourceClientCheckProvisioningServiceNameAvailabilityOptions) (IotDpsResourceClientCheckProvisioningServiceNameAvailabilityResponse, error) { req, err := client.checkProvisioningServiceNameAvailabilityCreateRequest(ctx, arguments, options) if err != nil { return IotDpsResourceClientCheckProvisioningServiceNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotDpsResourceClientCheckProvisioningServiceNameAvailabilityResponse{}, err } @@ -83,7 +74,7 @@ func (client *IotDpsResourceClient) checkProvisioningServiceNameAvailabilityCrea 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,21 +98,22 @@ func (client *IotDpsResourceClient) checkProvisioningServiceNameAvailabilityHand // is to retrieve the provisioning service metadata and security metadata, and then combine them with the // modified values in a new body to update the provisioning service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// resourceGroupName - Resource group identifier. -// provisioningServiceName - Name of provisioning service to create or update. -// iotDpsDescription - Description of the provisioning service to create or update. -// options - IotDpsResourceClientBeginCreateOrUpdateOptions contains the optional parameters for the IotDpsResourceClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - Resource group identifier. +// - provisioningServiceName - Name of provisioning service to create or update. +// - iotDpsDescription - Description of the provisioning service to create or update. +// - options - IotDpsResourceClientBeginCreateOrUpdateOptions contains the optional parameters for the IotDpsResourceClient.BeginCreateOrUpdate +// method. func (client *IotDpsResourceClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, iotDpsDescription ProvisioningServiceDescription, options *IotDpsResourceClientBeginCreateOrUpdateOptions) (*runtime.Poller[IotDpsResourceClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, provisioningServiceName, iotDpsDescription, options) if err != nil { return nil, err } - return runtime.NewPoller[IotDpsResourceClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[IotDpsResourceClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[IotDpsResourceClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[IotDpsResourceClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -129,13 +121,14 @@ func (client *IotDpsResourceClient) BeginCreateOrUpdate(ctx context.Context, res // retrieve the provisioning service metadata and security metadata, and then combine them with the // modified values in a new body to update the provisioning service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 func (client *IotDpsResourceClient) createOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, iotDpsDescription ProvisioningServiceDescription, options *IotDpsResourceClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, provisioningServiceName, iotDpsDescription, 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 } @@ -160,7 +153,7 @@ func (client *IotDpsResourceClient) createOrUpdateCreateRequest(ctx context.Cont return nil, errors.New("parameter provisioningServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{provisioningServiceName}", url.PathEscape(provisioningServiceName)) - 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 } @@ -174,35 +167,37 @@ func (client *IotDpsResourceClient) createOrUpdateCreateRequest(ctx context.Cont // BeginCreateOrUpdatePrivateEndpointConnection - Create or update the status of a private endpoint connection with the specified // name // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// resourceGroupName - The name of the resource group that contains the provisioning service. -// resourceName - The name of the provisioning service. -// privateEndpointConnectionName - The name of the private endpoint connection -// privateEndpointConnection - The private endpoint connection with updated properties -// options - IotDpsResourceClientBeginCreateOrUpdatePrivateEndpointConnectionOptions contains the optional parameters for -// the IotDpsResourceClient.BeginCreateOrUpdatePrivateEndpointConnection method. +// - resourceGroupName - The name of the resource group that contains the provisioning service. +// - resourceName - The name of the provisioning service. +// - privateEndpointConnectionName - The name of the private endpoint connection +// - privateEndpointConnection - The private endpoint connection with updated properties +// - options - IotDpsResourceClientBeginCreateOrUpdatePrivateEndpointConnectionOptions contains the optional parameters for +// the IotDpsResourceClient.BeginCreateOrUpdatePrivateEndpointConnection method. func (client *IotDpsResourceClient) BeginCreateOrUpdatePrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, options *IotDpsResourceClientBeginCreateOrUpdatePrivateEndpointConnectionOptions) (*runtime.Poller[IotDpsResourceClientCreateOrUpdatePrivateEndpointConnectionResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdatePrivateEndpointConnection(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection, options) if err != nil { return nil, err } - return runtime.NewPoller[IotDpsResourceClientCreateOrUpdatePrivateEndpointConnectionResponse](resp, client.pl, nil) + return runtime.NewPoller[IotDpsResourceClientCreateOrUpdatePrivateEndpointConnectionResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[IotDpsResourceClientCreateOrUpdatePrivateEndpointConnectionResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[IotDpsResourceClientCreateOrUpdatePrivateEndpointConnectionResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdatePrivateEndpointConnection - Create or update the status of a private endpoint connection with the specified // name // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 func (client *IotDpsResourceClient) createOrUpdatePrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, options *IotDpsResourceClientBeginCreateOrUpdatePrivateEndpointConnectionOptions) (*http.Response, error) { req, err := client.createOrUpdatePrivateEndpointConnectionCreateRequest(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection, 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 } @@ -231,7 +226,7 @@ func (client *IotDpsResourceClient) createOrUpdatePrivateEndpointConnectionCreat 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 } @@ -244,32 +239,34 @@ func (client *IotDpsResourceClient) createOrUpdatePrivateEndpointConnectionCreat // BeginDelete - Deletes the Provisioning Service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// provisioningServiceName - Name of provisioning service to delete. -// resourceGroupName - Resource group identifier. -// options - IotDpsResourceClientBeginDeleteOptions contains the optional parameters for the IotDpsResourceClient.BeginDelete -// method. +// - provisioningServiceName - Name of provisioning service to delete. +// - resourceGroupName - Resource group identifier. +// - options - IotDpsResourceClientBeginDeleteOptions contains the optional parameters for the IotDpsResourceClient.BeginDelete +// method. func (client *IotDpsResourceClient) BeginDelete(ctx context.Context, provisioningServiceName string, resourceGroupName string, options *IotDpsResourceClientBeginDeleteOptions) (*runtime.Poller[IotDpsResourceClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, provisioningServiceName, resourceGroupName, options) if err != nil { return nil, err } - return runtime.NewPoller[IotDpsResourceClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[IotDpsResourceClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[IotDpsResourceClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[IotDpsResourceClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the Provisioning Service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 func (client *IotDpsResourceClient) deleteOperation(ctx context.Context, provisioningServiceName string, resourceGroupName string, options *IotDpsResourceClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, provisioningServiceName, 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 } @@ -294,7 +291,7 @@ func (client *IotDpsResourceClient) deleteCreateRequest(ctx context.Context, pro 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 } @@ -307,33 +304,35 @@ func (client *IotDpsResourceClient) deleteCreateRequest(ctx context.Context, pro // BeginDeletePrivateEndpointConnection - Delete private endpoint connection with the specified name // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// resourceGroupName - The name of the resource group that contains the provisioning service. -// resourceName - The name of the provisioning service. -// privateEndpointConnectionName - The name of the private endpoint connection -// options - IotDpsResourceClientBeginDeletePrivateEndpointConnectionOptions contains the optional parameters for the IotDpsResourceClient.BeginDeletePrivateEndpointConnection -// method. +// - resourceGroupName - The name of the resource group that contains the provisioning service. +// - resourceName - The name of the provisioning service. +// - privateEndpointConnectionName - The name of the private endpoint connection +// - options - IotDpsResourceClientBeginDeletePrivateEndpointConnectionOptions contains the optional parameters for the IotDpsResourceClient.BeginDeletePrivateEndpointConnection +// method. func (client *IotDpsResourceClient) BeginDeletePrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *IotDpsResourceClientBeginDeletePrivateEndpointConnectionOptions) (*runtime.Poller[IotDpsResourceClientDeletePrivateEndpointConnectionResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deletePrivateEndpointConnection(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, options) if err != nil { return nil, err } - return runtime.NewPoller[IotDpsResourceClientDeletePrivateEndpointConnectionResponse](resp, client.pl, nil) + return runtime.NewPoller[IotDpsResourceClientDeletePrivateEndpointConnectionResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[IotDpsResourceClientDeletePrivateEndpointConnectionResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[IotDpsResourceClientDeletePrivateEndpointConnectionResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // DeletePrivateEndpointConnection - Delete private endpoint connection with the specified name // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 func (client *IotDpsResourceClient) deletePrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *IotDpsResourceClientBeginDeletePrivateEndpointConnectionOptions) (*http.Response, error) { req, err := client.deletePrivateEndpointConnectionCreateRequest(ctx, resourceGroupName, resourceName, 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 } @@ -362,7 +361,7 @@ func (client *IotDpsResourceClient) deletePrivateEndpointConnectionCreateRequest 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 } @@ -375,16 +374,17 @@ func (client *IotDpsResourceClient) deletePrivateEndpointConnectionCreateRequest // Get - Get the metadata of the provisioning service without SAS keys. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// provisioningServiceName - Name of the provisioning service to retrieve. -// resourceGroupName - Resource group name. -// options - IotDpsResourceClientGetOptions contains the optional parameters for the IotDpsResourceClient.Get method. +// - provisioningServiceName - Name of the provisioning service to retrieve. +// - resourceGroupName - Resource group name. +// - options - IotDpsResourceClientGetOptions contains the optional parameters for the IotDpsResourceClient.Get method. func (client *IotDpsResourceClient) Get(ctx context.Context, provisioningServiceName string, resourceGroupName string, options *IotDpsResourceClientGetOptions) (IotDpsResourceClientGetResponse, error) { req, err := client.getCreateRequest(ctx, provisioningServiceName, resourceGroupName, options) if err != nil { return IotDpsResourceClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotDpsResourceClientGetResponse{}, err } @@ -409,7 +409,7 @@ func (client *IotDpsResourceClient) getCreateRequest(ctx context.Context, provis 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,19 +431,20 @@ func (client *IotDpsResourceClient) getHandleResponse(resp *http.Response) (IotD // GetOperationResult - Gets the status of a long running operation, such as create, update or delete a provisioning service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// operationID - Operation id corresponding to long running operation. Use this to poll for the status. -// resourceGroupName - Resource group identifier. -// provisioningServiceName - Name of provisioning service that the operation is running on. -// asyncinfo - Async header used to poll on the status of the operation, obtained while creating the long running operation. -// options - IotDpsResourceClientGetOperationResultOptions contains the optional parameters for the IotDpsResourceClient.GetOperationResult -// method. +// - operationID - Operation id corresponding to long running operation. Use this to poll for the status. +// - resourceGroupName - Resource group identifier. +// - provisioningServiceName - Name of provisioning service that the operation is running on. +// - asyncinfo - Async header used to poll on the status of the operation, obtained while creating the long running operation. +// - options - IotDpsResourceClientGetOperationResultOptions contains the optional parameters for the IotDpsResourceClient.GetOperationResult +// method. func (client *IotDpsResourceClient) GetOperationResult(ctx context.Context, operationID string, resourceGroupName string, provisioningServiceName string, asyncinfo string, options *IotDpsResourceClientGetOperationResultOptions) (IotDpsResourceClientGetOperationResultResponse, error) { req, err := client.getOperationResultCreateRequest(ctx, operationID, resourceGroupName, provisioningServiceName, asyncinfo, options) if err != nil { return IotDpsResourceClientGetOperationResultResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotDpsResourceClientGetOperationResultResponse{}, err } @@ -472,7 +473,7 @@ func (client *IotDpsResourceClient) getOperationResultCreateRequest(ctx context. return nil, errors.New("parameter provisioningServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{provisioningServiceName}", url.PathEscape(provisioningServiceName)) - 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,18 +496,19 @@ func (client *IotDpsResourceClient) getOperationResultHandleResponse(resp *http. // GetPrivateEndpointConnection - Get private endpoint connection properties // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// resourceGroupName - The name of the resource group that contains the provisioning service. -// resourceName - The name of the provisioning service. -// privateEndpointConnectionName - The name of the private endpoint connection -// options - IotDpsResourceClientGetPrivateEndpointConnectionOptions contains the optional parameters for the IotDpsResourceClient.GetPrivateEndpointConnection -// method. +// - resourceGroupName - The name of the resource group that contains the provisioning service. +// - resourceName - The name of the provisioning service. +// - privateEndpointConnectionName - The name of the private endpoint connection +// - options - IotDpsResourceClientGetPrivateEndpointConnectionOptions contains the optional parameters for the IotDpsResourceClient.GetPrivateEndpointConnection +// method. func (client *IotDpsResourceClient) GetPrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *IotDpsResourceClientGetPrivateEndpointConnectionOptions) (IotDpsResourceClientGetPrivateEndpointConnectionResponse, error) { req, err := client.getPrivateEndpointConnectionCreateRequest(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, options) if err != nil { return IotDpsResourceClientGetPrivateEndpointConnectionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotDpsResourceClientGetPrivateEndpointConnectionResponse{}, err } @@ -535,7 +537,7 @@ func (client *IotDpsResourceClient) getPrivateEndpointConnectionCreateRequest(ct 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 } @@ -557,18 +559,19 @@ func (client *IotDpsResourceClient) getPrivateEndpointConnectionHandleResponse(r // GetPrivateLinkResources - Get the specified private link resource for the given provisioning service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// resourceGroupName - The name of the resource group that contains the provisioning service. -// resourceName - The name of the provisioning service. -// groupID - The name of the private link resource -// options - IotDpsResourceClientGetPrivateLinkResourcesOptions contains the optional parameters for the IotDpsResourceClient.GetPrivateLinkResources -// method. +// - resourceGroupName - The name of the resource group that contains the provisioning service. +// - resourceName - The name of the provisioning service. +// - groupID - The name of the private link resource +// - options - IotDpsResourceClientGetPrivateLinkResourcesOptions contains the optional parameters for the IotDpsResourceClient.GetPrivateLinkResources +// method. func (client *IotDpsResourceClient) GetPrivateLinkResources(ctx context.Context, resourceGroupName string, resourceName string, groupID string, options *IotDpsResourceClientGetPrivateLinkResourcesOptions) (IotDpsResourceClientGetPrivateLinkResourcesResponse, error) { req, err := client.getPrivateLinkResourcesCreateRequest(ctx, resourceGroupName, resourceName, groupID, options) if err != nil { return IotDpsResourceClientGetPrivateLinkResourcesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotDpsResourceClientGetPrivateLinkResourcesResponse{}, err } @@ -597,7 +600,7 @@ func (client *IotDpsResourceClient) getPrivateLinkResourcesCreateRequest(ctx con return nil, errors.New("parameter groupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) - 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 } @@ -618,11 +621,11 @@ func (client *IotDpsResourceClient) getPrivateLinkResourcesHandleResponse(resp * } // NewListByResourceGroupPager - Get a list of all provisioning services in the given resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// resourceGroupName - Resource group identifier. -// options - IotDpsResourceClientListByResourceGroupOptions contains the optional parameters for the IotDpsResourceClient.ListByResourceGroup -// method. +// - resourceGroupName - Resource group identifier. +// - options - IotDpsResourceClientListByResourceGroupOptions contains the optional parameters for the IotDpsResourceClient.NewListByResourceGroupPager +// method. func (client *IotDpsResourceClient) NewListByResourceGroupPager(resourceGroupName string, options *IotDpsResourceClientListByResourceGroupOptions) *runtime.Pager[IotDpsResourceClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[IotDpsResourceClientListByResourceGroupResponse]{ More: func(page IotDpsResourceClientListByResourceGroupResponse) bool { @@ -639,7 +642,7 @@ func (client *IotDpsResourceClient) NewListByResourceGroupPager(resourceGroupNam if err != nil { return IotDpsResourceClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotDpsResourceClientListByResourceGroupResponse{}, err } @@ -662,7 +665,7 @@ func (client *IotDpsResourceClient) 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 } @@ -683,10 +686,10 @@ func (client *IotDpsResourceClient) listByResourceGroupHandleResponse(resp *http } // NewListBySubscriptionPager - List all the provisioning services for a given subscription id. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// options - IotDpsResourceClientListBySubscriptionOptions contains the optional parameters for the IotDpsResourceClient.ListBySubscription -// method. +// - options - IotDpsResourceClientListBySubscriptionOptions contains the optional parameters for the IotDpsResourceClient.NewListBySubscriptionPager +// method. func (client *IotDpsResourceClient) NewListBySubscriptionPager(options *IotDpsResourceClientListBySubscriptionOptions) *runtime.Pager[IotDpsResourceClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[IotDpsResourceClientListBySubscriptionResponse]{ More: func(page IotDpsResourceClientListBySubscriptionResponse) bool { @@ -703,7 +706,7 @@ func (client *IotDpsResourceClient) NewListBySubscriptionPager(options *IotDpsRe if err != nil { return IotDpsResourceClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotDpsResourceClientListBySubscriptionResponse{}, err } @@ -722,7 +725,7 @@ func (client *IotDpsResourceClient) 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 } @@ -743,11 +746,12 @@ func (client *IotDpsResourceClient) listBySubscriptionHandleResponse(resp *http. } // NewListKeysPager - List the primary and secondary keys for a provisioning service. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// provisioningServiceName - The provisioning service name to get the shared access keys for. -// resourceGroupName - resource group name -// options - IotDpsResourceClientListKeysOptions contains the optional parameters for the IotDpsResourceClient.ListKeys method. +// - provisioningServiceName - The provisioning service name to get the shared access keys for. +// - resourceGroupName - resource group name +// - options - IotDpsResourceClientListKeysOptions contains the optional parameters for the IotDpsResourceClient.NewListKeysPager +// method. func (client *IotDpsResourceClient) NewListKeysPager(provisioningServiceName string, resourceGroupName string, options *IotDpsResourceClientListKeysOptions) *runtime.Pager[IotDpsResourceClientListKeysResponse] { return runtime.NewPager(runtime.PagingHandler[IotDpsResourceClientListKeysResponse]{ More: func(page IotDpsResourceClientListKeysResponse) bool { @@ -764,7 +768,7 @@ func (client *IotDpsResourceClient) NewListKeysPager(provisioningServiceName str if err != nil { return IotDpsResourceClientListKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotDpsResourceClientListKeysResponse{}, err } @@ -791,7 +795,7 @@ func (client *IotDpsResourceClient) listKeysCreateRequest(ctx context.Context, p return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - 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 } @@ -813,18 +817,19 @@ func (client *IotDpsResourceClient) listKeysHandleResponse(resp *http.Response) // ListKeysForKeyName - List primary and secondary keys for a specific key name // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// provisioningServiceName - Name of the provisioning service. -// keyName - Logical key name to get key-values for. -// resourceGroupName - The name of the resource group that contains the provisioning service. -// options - IotDpsResourceClientListKeysForKeyNameOptions contains the optional parameters for the IotDpsResourceClient.ListKeysForKeyName -// method. +// - provisioningServiceName - Name of the provisioning service. +// - keyName - Logical key name to get key-values for. +// - resourceGroupName - The name of the resource group that contains the provisioning service. +// - options - IotDpsResourceClientListKeysForKeyNameOptions contains the optional parameters for the IotDpsResourceClient.ListKeysForKeyName +// method. func (client *IotDpsResourceClient) ListKeysForKeyName(ctx context.Context, provisioningServiceName string, keyName string, resourceGroupName string, options *IotDpsResourceClientListKeysForKeyNameOptions) (IotDpsResourceClientListKeysForKeyNameResponse, error) { req, err := client.listKeysForKeyNameCreateRequest(ctx, provisioningServiceName, keyName, resourceGroupName, options) if err != nil { return IotDpsResourceClientListKeysForKeyNameResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotDpsResourceClientListKeysForKeyNameResponse{}, err } @@ -853,7 +858,7 @@ func (client *IotDpsResourceClient) listKeysForKeyNameCreateRequest(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.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 } @@ -875,17 +880,18 @@ func (client *IotDpsResourceClient) listKeysForKeyNameHandleResponse(resp *http. // ListPrivateEndpointConnections - List private endpoint connection properties // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// resourceGroupName - The name of the resource group that contains the provisioning service. -// resourceName - The name of the provisioning service. -// options - IotDpsResourceClientListPrivateEndpointConnectionsOptions contains the optional parameters for the IotDpsResourceClient.ListPrivateEndpointConnections -// method. +// - resourceGroupName - The name of the resource group that contains the provisioning service. +// - resourceName - The name of the provisioning service. +// - options - IotDpsResourceClientListPrivateEndpointConnectionsOptions contains the optional parameters for the IotDpsResourceClient.ListPrivateEndpointConnections +// method. func (client *IotDpsResourceClient) ListPrivateEndpointConnections(ctx context.Context, resourceGroupName string, resourceName string, options *IotDpsResourceClientListPrivateEndpointConnectionsOptions) (IotDpsResourceClientListPrivateEndpointConnectionsResponse, error) { req, err := client.listPrivateEndpointConnectionsCreateRequest(ctx, resourceGroupName, resourceName, options) if err != nil { return IotDpsResourceClientListPrivateEndpointConnectionsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotDpsResourceClientListPrivateEndpointConnectionsResponse{}, err } @@ -910,7 +916,7 @@ func (client *IotDpsResourceClient) listPrivateEndpointConnectionsCreateRequest( 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 } @@ -932,17 +938,18 @@ func (client *IotDpsResourceClient) listPrivateEndpointConnectionsHandleResponse // ListPrivateLinkResources - List private link resources for the given provisioning service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// resourceGroupName - The name of the resource group that contains the provisioning service. -// resourceName - The name of the provisioning service. -// options - IotDpsResourceClientListPrivateLinkResourcesOptions contains the optional parameters for the IotDpsResourceClient.ListPrivateLinkResources -// method. +// - resourceGroupName - The name of the resource group that contains the provisioning service. +// - resourceName - The name of the provisioning service. +// - options - IotDpsResourceClientListPrivateLinkResourcesOptions contains the optional parameters for the IotDpsResourceClient.ListPrivateLinkResources +// method. func (client *IotDpsResourceClient) ListPrivateLinkResources(ctx context.Context, resourceGroupName string, resourceName string, options *IotDpsResourceClientListPrivateLinkResourcesOptions) (IotDpsResourceClientListPrivateLinkResourcesResponse, error) { req, err := client.listPrivateLinkResourcesCreateRequest(ctx, resourceGroupName, resourceName, options) if err != nil { return IotDpsResourceClientListPrivateLinkResourcesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotDpsResourceClientListPrivateLinkResourcesResponse{}, err } @@ -967,7 +974,7 @@ func (client *IotDpsResourceClient) listPrivateLinkResourcesCreateRequest(ctx co 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 } @@ -988,12 +995,12 @@ func (client *IotDpsResourceClient) listPrivateLinkResourcesHandleResponse(resp } // NewListValidSKUsPager - Gets the list of valid SKUs and tiers for a provisioning service. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// provisioningServiceName - Name of provisioning service. -// resourceGroupName - Name of resource group. -// options - IotDpsResourceClientListValidSKUsOptions contains the optional parameters for the IotDpsResourceClient.ListValidSKUs -// method. +// - provisioningServiceName - Name of provisioning service. +// - resourceGroupName - Name of resource group. +// - options - IotDpsResourceClientListValidSKUsOptions contains the optional parameters for the IotDpsResourceClient.NewListValidSKUsPager +// method. func (client *IotDpsResourceClient) NewListValidSKUsPager(provisioningServiceName string, resourceGroupName string, options *IotDpsResourceClientListValidSKUsOptions) *runtime.Pager[IotDpsResourceClientListValidSKUsResponse] { return runtime.NewPager(runtime.PagingHandler[IotDpsResourceClientListValidSKUsResponse]{ More: func(page IotDpsResourceClientListValidSKUsResponse) bool { @@ -1010,7 +1017,7 @@ func (client *IotDpsResourceClient) NewListValidSKUsPager(provisioningServiceNam if err != nil { return IotDpsResourceClientListValidSKUsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotDpsResourceClientListValidSKUsResponse{}, err } @@ -1037,7 +1044,7 @@ func (client *IotDpsResourceClient) listValidSKUsCreateRequest(ctx context.Conte 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 } @@ -1059,33 +1066,35 @@ func (client *IotDpsResourceClient) listValidSKUsHandleResponse(resp *http.Respo // BeginUpdate - Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// resourceGroupName - Resource group identifier. -// provisioningServiceName - Name of provisioning service to create or update. -// provisioningServiceTags - Updated tag information to set into the provisioning service instance. -// options - IotDpsResourceClientBeginUpdateOptions contains the optional parameters for the IotDpsResourceClient.BeginUpdate -// method. +// - resourceGroupName - Resource group identifier. +// - provisioningServiceName - Name of provisioning service to create or update. +// - provisioningServiceTags - Updated tag information to set into the provisioning service instance. +// - options - IotDpsResourceClientBeginUpdateOptions contains the optional parameters for the IotDpsResourceClient.BeginUpdate +// method. func (client *IotDpsResourceClient) BeginUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, provisioningServiceTags TagsResource, options *IotDpsResourceClientBeginUpdateOptions) (*runtime.Poller[IotDpsResourceClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, provisioningServiceName, provisioningServiceTags, options) if err != nil { return nil, err } - return runtime.NewPoller[IotDpsResourceClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[IotDpsResourceClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[IotDpsResourceClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[IotDpsResourceClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 func (client *IotDpsResourceClient) update(ctx context.Context, resourceGroupName string, provisioningServiceName string, provisioningServiceTags TagsResource, options *IotDpsResourceClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, provisioningServiceName, provisioningServiceTags, 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 } @@ -1110,7 +1119,7 @@ func (client *IotDpsResourceClient) updateCreateRequest(ctx context.Context, res return nil, errors.New("parameter provisioningServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{provisioningServiceName}", url.PathEscape(provisioningServiceName)) - 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/deviceprovisioningservices/armdeviceprovisioningservices/iotdpsresource_client_example_test.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/iotdpsresource_client_example_test.go new file mode 100644 index 000000000000..2675eaa72924 --- /dev/null +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/iotdpsresource_client_example_test.go @@ -0,0 +1,701 @@ +//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 armdeviceprovisioningservices_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/deviceprovisioningservices/armdeviceprovisioningservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGet.json +func ExampleIotDpsResourceClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewIotDpsResourceClient().Get(ctx, "myFirstProvisioningService", "myResourceGroup", 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.ProvisioningServiceDescription = armdeviceprovisioningservices.ProvisioningServiceDescription{ + // Name: to.Ptr("myFirstProvisioningService"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices"), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServices/myFirstProvisioningService"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Etag: to.Ptr("AAAAAAAADGk="), + // Properties: &armdeviceprovisioningservices.IotDpsPropertiesDescription{ + // AllocationPolicy: to.Ptr(armdeviceprovisioningservices.AllocationPolicyHashed), + // AuthorizationPolicies: []*armdeviceprovisioningservices.SharedAccessSignatureAuthorizationRuleAccessRightsDescription{ + // }, + // DeviceProvisioningHostName: to.Ptr("global.azure-devices-provisioning.net"), + // IDScope: to.Ptr("0ne00000012"), + // ServiceOperationsHostName: to.Ptr("myFirstProvisioningService.azure-devices-provisioning.net"), + // State: to.Ptr(armdeviceprovisioningservices.StateActive), + // }, + // SKU: &armdeviceprovisioningservices.IotDpsSKUInfo{ + // Name: to.Ptr(armdeviceprovisioningservices.IotDpsSKUS1), + // Capacity: to.Ptr[int64](1), + // Tier: to.Ptr("Standard"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCreate.json +func ExampleIotDpsResourceClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewIotDpsResourceClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myFirstProvisioningService", armdeviceprovisioningservices.ProvisioningServiceDescription{ + Location: to.Ptr("East US"), + Tags: map[string]*string{}, + Properties: &armdeviceprovisioningservices.IotDpsPropertiesDescription{ + EnableDataResidency: to.Ptr(false), + }, + SKU: &armdeviceprovisioningservices.IotDpsSKUInfo{ + Name: to.Ptr(armdeviceprovisioningservices.IotDpsSKUS1), + Capacity: to.Ptr[int64](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.ProvisioningServiceDescription = armdeviceprovisioningservices.ProvisioningServiceDescription{ + // Name: to.Ptr("myFirstProvisioningService"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices"), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups//providers/Microsoft.Devices/ProvisioningServices/myFirstProvisioningService"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Etag: to.Ptr("AAAAAAAADGk="), + // Properties: &armdeviceprovisioningservices.IotDpsPropertiesDescription{ + // AllocationPolicy: to.Ptr(armdeviceprovisioningservices.AllocationPolicyHashed), + // AuthorizationPolicies: []*armdeviceprovisioningservices.SharedAccessSignatureAuthorizationRuleAccessRightsDescription{ + // }, + // DeviceProvisioningHostName: to.Ptr("global.azure-devices-provisioning.net"), + // EnableDataResidency: to.Ptr(false), + // IDScope: to.Ptr("0ne00000012"), + // ServiceOperationsHostName: to.Ptr("myFirstProvisioningService.azure-devices-provisioning.net"), + // State: to.Ptr(armdeviceprovisioningservices.StateActive), + // }, + // SKU: &armdeviceprovisioningservices.IotDpsSKUInfo{ + // Name: to.Ptr(armdeviceprovisioningservices.IotDpsSKUS1), + // Capacity: to.Ptr[int64](1), + // Tier: to.Ptr("Standard"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSPatch.json +func ExampleIotDpsResourceClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewIotDpsResourceClient().BeginUpdate(ctx, "myResourceGroup", "myFirstProvisioningService", armdeviceprovisioningservices.TagsResource{ + Tags: map[string]*string{ + "foo": to.Ptr("bar"), + }, + }, 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.ProvisioningServiceDescription = armdeviceprovisioningservices.ProvisioningServiceDescription{ + // Name: to.Ptr("myFirstProvisioningService"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices"), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServices/myFirstProvisioningService"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "foo": to.Ptr("bar"), + // }, + // Etag: to.Ptr("AAAAAAAADGk="), + // Properties: &armdeviceprovisioningservices.IotDpsPropertiesDescription{ + // AllocationPolicy: to.Ptr(armdeviceprovisioningservices.AllocationPolicyHashed), + // DeviceProvisioningHostName: to.Ptr("global.azure-devices-provisioning.net"), + // IDScope: to.Ptr("0ne00000012"), + // ServiceOperationsHostName: to.Ptr("myFirstProvisioningService.azure-devices-provisioning.net"), + // State: to.Ptr(armdeviceprovisioningservices.StateActive), + // }, + // SKU: &armdeviceprovisioningservices.IotDpsSKUInfo{ + // Name: to.Ptr(armdeviceprovisioningservices.IotDpsSKUS1), + // Capacity: to.Ptr[int64](1), + // Tier: to.Ptr("Standard"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSDelete.json +func ExampleIotDpsResourceClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewIotDpsResourceClient().BeginDelete(ctx, "myFirstProvisioningService", "myResourceGroup", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListBySubscription.json +func ExampleIotDpsResourceClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewIotDpsResourceClient().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.ProvisioningServiceDescriptionListResult = armdeviceprovisioningservices.ProvisioningServiceDescriptionListResult{ + // Value: []*armdeviceprovisioningservices.ProvisioningServiceDescription{ + // { + // Name: to.Ptr("myFirstProvisioningService"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices"), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServices/myFirstProvisioningService"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Etag: to.Ptr("AAAAAAAADGk="), + // Properties: &armdeviceprovisioningservices.IotDpsPropertiesDescription{ + // AllocationPolicy: to.Ptr(armdeviceprovisioningservices.AllocationPolicyHashed), + // DeviceProvisioningHostName: to.Ptr("global.azure-devices-provisioning.net"), + // IDScope: to.Ptr("0ne00000012"), + // ServiceOperationsHostName: to.Ptr("myFirstProvisioningService.azure-devices-provisioning.net"), + // State: to.Ptr(armdeviceprovisioningservices.StateActive), + // }, + // SKU: &armdeviceprovisioningservices.IotDpsSKUInfo{ + // Name: to.Ptr(armdeviceprovisioningservices.IotDpsSKUS1), + // Capacity: to.Ptr[int64](1), + // Tier: to.Ptr("Standard"), + // }, + // }, + // { + // Name: to.Ptr("mySecondProvisioningService"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices"), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServices/mySecondProvisioningService"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Etag: to.Ptr("AAAAAAAADGk="), + // Properties: &armdeviceprovisioningservices.IotDpsPropertiesDescription{ + // AllocationPolicy: to.Ptr(armdeviceprovisioningservices.AllocationPolicyHashed), + // DeviceProvisioningHostName: to.Ptr("global.azure-devices-provisioning.net"), + // IDScope: to.Ptr("0ne00000012"), + // ServiceOperationsHostName: to.Ptr("myFirstProvisioningService.azure-devices-provisioning.net"), + // State: to.Ptr(armdeviceprovisioningservices.StateActive), + // }, + // SKU: &armdeviceprovisioningservices.IotDpsSKUInfo{ + // Name: to.Ptr(armdeviceprovisioningservices.IotDpsSKUS1), + // Capacity: to.Ptr[int64](1), + // Tier: to.Ptr("Standard"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListByResourceGroup.json +func ExampleIotDpsResourceClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewIotDpsResourceClient().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.ProvisioningServiceDescriptionListResult = armdeviceprovisioningservices.ProvisioningServiceDescriptionListResult{ + // Value: []*armdeviceprovisioningservices.ProvisioningServiceDescription{ + // { + // Name: to.Ptr("myFirstProvisioningService"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices"), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServices/myFirstProvisioningService"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Etag: to.Ptr("AAAAAAAADGk="), + // Properties: &armdeviceprovisioningservices.IotDpsPropertiesDescription{ + // AllocationPolicy: to.Ptr(armdeviceprovisioningservices.AllocationPolicyHashed), + // DeviceProvisioningHostName: to.Ptr("global.azure-devices-provisioning.net"), + // IDScope: to.Ptr("0ne00000012"), + // ServiceOperationsHostName: to.Ptr("myFirstProvisioningService.azure-devices-provisioning.net"), + // State: to.Ptr(armdeviceprovisioningservices.StateActive), + // }, + // SKU: &armdeviceprovisioningservices.IotDpsSKUInfo{ + // Name: to.Ptr(armdeviceprovisioningservices.IotDpsSKUS1), + // Capacity: to.Ptr[int64](1), + // Tier: to.Ptr("Standard"), + // }, + // }, + // { + // Name: to.Ptr("mySecondProvisioningService"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices"), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServices/mySecondProvisioningService"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Etag: to.Ptr("AAAAAAAADGk="), + // Properties: &armdeviceprovisioningservices.IotDpsPropertiesDescription{ + // AllocationPolicy: to.Ptr(armdeviceprovisioningservices.AllocationPolicyHashed), + // DeviceProvisioningHostName: to.Ptr("global.azure-devices-provisioning.net"), + // IDScope: to.Ptr("0ne00000012"), + // ServiceOperationsHostName: to.Ptr("mySecondProvisioningService.azure-devices-provisioning.net"), + // State: to.Ptr(armdeviceprovisioningservices.StateActive), + // }, + // SKU: &armdeviceprovisioningservices.IotDpsSKUInfo{ + // Name: to.Ptr(armdeviceprovisioningservices.IotDpsSKUS1), + // Capacity: to.Ptr[int64](1), + // Tier: to.Ptr("Standard"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetOperationResult.json +func ExampleIotDpsResourceClient_GetOperationResult() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewIotDpsResourceClient().GetOperationResult(ctx, "MTY5OTNmZDctODI5Yy00N2E2LTkxNDQtMDU1NGIyYzY1ZjRl", "myResourceGroup", "myFirstProvisioningService", "1508265712453", 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.AsyncOperationResult = armdeviceprovisioningservices.AsyncOperationResult{ + // Status: to.Ptr("Succeeded"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetValidSku.json +func ExampleIotDpsResourceClient_NewListValidSKUsPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewIotDpsResourceClient().NewListValidSKUsPager("myFirstProvisioningService", "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.IotDpsSKUDefinitionListResult = armdeviceprovisioningservices.IotDpsSKUDefinitionListResult{ + // Value: []*armdeviceprovisioningservices.IotDpsSKUDefinition{ + // { + // Name: to.Ptr(armdeviceprovisioningservices.IotDpsSKUS1), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCheckNameAvailability.json +func ExampleIotDpsResourceClient_CheckProvisioningServiceNameAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewIotDpsResourceClient().CheckProvisioningServiceNameAvailability(ctx, armdeviceprovisioningservices.OperationInputs{ + Name: to.Ptr("test213123"), + }, 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.NameAvailabilityInfo = armdeviceprovisioningservices.NameAvailabilityInfo{ + // Message: to.Ptr("name is valid"), + // NameAvailable: to.Ptr(true), + // Reason: to.Ptr(armdeviceprovisioningservices.NameUnavailabilityReasonInvalid), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListKeys.json +func ExampleIotDpsResourceClient_NewListKeysPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewIotDpsResourceClient().NewListKeysPager("myFirstProvisioningService", "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.SharedAccessSignatureAuthorizationRuleListResult = armdeviceprovisioningservices.SharedAccessSignatureAuthorizationRuleListResult{ + // Value: []*armdeviceprovisioningservices.SharedAccessSignatureAuthorizationRuleAccessRightsDescription{ + // { + // KeyName: to.Ptr("key1"), + // PrimaryKey: to.Ptr("#####################################"), + // Rights: to.Ptr(armdeviceprovisioningservices.AccessRightsDescriptionServiceConfig), + // SecondaryKey: to.Ptr("###################################"), + // }, + // { + // KeyName: to.Ptr("key2"), + // PrimaryKey: to.Ptr("#######################################"), + // Rights: to.Ptr(armdeviceprovisioningservices.AccessRightsDescriptionServiceConfig), + // SecondaryKey: to.Ptr("####################################="), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetKey.json +func ExampleIotDpsResourceClient_ListKeysForKeyName() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewIotDpsResourceClient().ListKeysForKeyName(ctx, "myFirstProvisioningService", "testKey", "myResourceGroup", 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.SharedAccessSignatureAuthorizationRuleAccessRightsDescription = armdeviceprovisioningservices.SharedAccessSignatureAuthorizationRuleAccessRightsDescription{ + // KeyName: to.Ptr("testKey"), + // PrimaryKey: to.Ptr("##################################"), + // Rights: to.Ptr(armdeviceprovisioningservices.AccessRightsDescriptionRegistrationStatusWrite), + // SecondaryKey: to.Ptr("################################"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListPrivateLinkResources.json +func ExampleIotDpsResourceClient_ListPrivateLinkResources() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewIotDpsResourceClient().ListPrivateLinkResources(ctx, "myResourceGroup", "myFirstProvisioningService", 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.PrivateLinkResources = armdeviceprovisioningservices.PrivateLinkResources{ + // Value: []*armdeviceprovisioningservices.GroupIDInformation{ + // { + // Name: to.Ptr("iotDps"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices/PrivateLinkResources"), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServices/myFirstProvisioningService/PrivateLinkResources/iotDps"), + // Properties: &armdeviceprovisioningservices.GroupIDInformationProperties{ + // GroupID: to.Ptr("iotDps"), + // RequiredMembers: []*string{ + // to.Ptr("iotDps")}, + // RequiredZoneNames: []*string{ + // to.Ptr("privatelink.azure-devices-provisioning.net")}, + // }, + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetPrivateLinkResources.json +func ExampleIotDpsResourceClient_GetPrivateLinkResources() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewIotDpsResourceClient().GetPrivateLinkResources(ctx, "myResourceGroup", "myFirstProvisioningService", "iotDps", 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.GroupIDInformation = armdeviceprovisioningservices.GroupIDInformation{ + // Name: to.Ptr("iotDps"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices/PrivateLinkResources"), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServices/myFirstProvisioningService/PrivateLinkResources/iotDps"), + // Properties: &armdeviceprovisioningservices.GroupIDInformationProperties{ + // GroupID: to.Ptr("iotDps"), + // RequiredMembers: []*string{ + // to.Ptr("iotDps")}, + // RequiredZoneNames: []*string{ + // to.Ptr("privatelink.azure-devices-provisioning.net")}, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListPrivateEndpointConnections.json +func ExampleIotDpsResourceClient_ListPrivateEndpointConnections() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewIotDpsResourceClient().ListPrivateEndpointConnections(ctx, "myResourceGroup", "myFirstProvisioningService", 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.PrivateEndpointConnectionArray = []*armdeviceprovisioningservices.PrivateEndpointConnection{ + // { + // Name: to.Ptr("myPrivateEndpointConnection"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices/PrivateEndpointConnections"), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServices/myFirstProvisioningService/PrivateEndpointConnections/myPrivateEndpointConnection"), + // Properties: &armdeviceprovisioningservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armdeviceprovisioningservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/a9eba280-4734-4d49-878f-b5549d1d0453/resourceGroups/networkResourceGroup/providers/Microsoft.Network/privateEndpoints/myPrivateEndpoint"), + // }, + // PrivateLinkServiceConnectionState: &armdeviceprovisioningservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Please approve my request!"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armdeviceprovisioningservices.PrivateLinkServiceConnectionStatusPending), + // }, + // }, + // }} +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetPrivateEndpointConnection.json +func ExampleIotDpsResourceClient_GetPrivateEndpointConnection() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewIotDpsResourceClient().GetPrivateEndpointConnection(ctx, "myResourceGroup", "myFirstProvisioningService", "myPrivateEndpointConnection", 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 = armdeviceprovisioningservices.PrivateEndpointConnection{ + // Name: to.Ptr("myPrivateEndpointConnection"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices/PrivateEndpointConnections"), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServices/myFirstProvisioningService/PrivateEndpointConnections/myPrivateEndpointConnection"), + // Properties: &armdeviceprovisioningservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armdeviceprovisioningservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/a9eba280-4734-4d49-878f-b5549d1d0453/resourceGroups/networkResourceGroup/providers/Microsoft.Network/privateEndpoints/myPrivateEndpoint"), + // }, + // PrivateLinkServiceConnectionState: &armdeviceprovisioningservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Please approve my request!"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armdeviceprovisioningservices.PrivateLinkServiceConnectionStatusPending), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCreateOrUpdatePrivateEndpointConnection.json +func ExampleIotDpsResourceClient_BeginCreateOrUpdatePrivateEndpointConnection() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewIotDpsResourceClient().BeginCreateOrUpdatePrivateEndpointConnection(ctx, "myResourceGroup", "myFirstProvisioningService", "myPrivateEndpointConnection", armdeviceprovisioningservices.PrivateEndpointConnection{ + Properties: &armdeviceprovisioningservices.PrivateEndpointConnectionProperties{ + PrivateLinkServiceConnectionState: &armdeviceprovisioningservices.PrivateLinkServiceConnectionState{ + Description: to.Ptr("Approved by johndoe@contoso.com"), + Status: to.Ptr(armdeviceprovisioningservices.PrivateLinkServiceConnectionStatusApproved), + }, + }, + }, 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 = armdeviceprovisioningservices.PrivateEndpointConnection{ + // Name: to.Ptr("myPrivateEndpointConnection"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices/PrivateEndpointConnections"), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServices/myFirstProvisioningService/PrivateEndpointConnections/myPrivateEndpointConnection"), + // Properties: &armdeviceprovisioningservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armdeviceprovisioningservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/a9eba280-4734-4d49-878f-b5549d1d0453/resourceGroups/networkResourceGroup/providers/Microsoft.Network/privateEndpoints/myPrivateEndpoint"), + // }, + // PrivateLinkServiceConnectionState: &armdeviceprovisioningservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Approved by johndoe@contoso.com"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armdeviceprovisioningservices.PrivateLinkServiceConnectionStatusApproved), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSDeletePrivateEndpointConnection.json +func ExampleIotDpsResourceClient_BeginDeletePrivateEndpointConnection() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdeviceprovisioningservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewIotDpsResourceClient().BeginDeletePrivateEndpointConnection(ctx, "myResourceGroup", "myFirstProvisioningService", "myPrivateEndpointConnection", 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 = armdeviceprovisioningservices.PrivateEndpointConnection{ + // Name: to.Ptr("myPrivateEndpointConnection"), + // Type: to.Ptr("Microsoft.Devices/ProvisioningServices/PrivateEndpointConnections"), + // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServices/myFirstProvisioningService/PrivateEndpointConnections/myPrivateEndpointConnection"), + // Properties: &armdeviceprovisioningservices.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armdeviceprovisioningservices.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/a9eba280-4734-4d49-878f-b5549d1d0453/resourceGroups/networkResourceGroup/providers/Microsoft.Network/privateEndpoints/myPrivateEndpoint"), + // }, + // PrivateLinkServiceConnectionState: &armdeviceprovisioningservices.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Deleted"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armdeviceprovisioningservices.PrivateLinkServiceConnectionStatusDisconnected), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_models.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/models.go similarity index 98% rename from sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_models.go rename to sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/models.go index c7b19d04f9b6..b6f505849ee3 100644 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_models.go +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/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 armdeviceprovisioningservices @@ -330,13 +331,13 @@ type IotDpsResourceClientGetPrivateLinkResourcesOptions struct { // placeholder for future optional parameters } -// IotDpsResourceClientListByResourceGroupOptions contains the optional parameters for the IotDpsResourceClient.ListByResourceGroup +// IotDpsResourceClientListByResourceGroupOptions contains the optional parameters for the IotDpsResourceClient.NewListByResourceGroupPager // method. type IotDpsResourceClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// IotDpsResourceClientListBySubscriptionOptions contains the optional parameters for the IotDpsResourceClient.ListBySubscription +// IotDpsResourceClientListBySubscriptionOptions contains the optional parameters for the IotDpsResourceClient.NewListBySubscriptionPager // method. type IotDpsResourceClientListBySubscriptionOptions struct { // placeholder for future optional parameters @@ -348,7 +349,7 @@ type IotDpsResourceClientListKeysForKeyNameOptions struct { // placeholder for future optional parameters } -// IotDpsResourceClientListKeysOptions contains the optional parameters for the IotDpsResourceClient.ListKeys method. +// IotDpsResourceClientListKeysOptions contains the optional parameters for the IotDpsResourceClient.NewListKeysPager method. type IotDpsResourceClientListKeysOptions struct { // placeholder for future optional parameters } @@ -365,7 +366,8 @@ type IotDpsResourceClientListPrivateLinkResourcesOptions struct { // placeholder for future optional parameters } -// IotDpsResourceClientListValidSKUsOptions contains the optional parameters for the IotDpsResourceClient.ListValidSKUs method. +// IotDpsResourceClientListValidSKUsOptions contains the optional parameters for the IotDpsResourceClient.NewListValidSKUsPager +// method. type IotDpsResourceClientListValidSKUsOptions struct { // placeholder for future optional parameters } @@ -464,7 +466,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/deviceprovisioningservices/armdeviceprovisioningservices/models_serde.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/models_serde.go new file mode 100644 index 000000000000..2e762ba9dee9 --- /dev/null +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/models_serde.go @@ -0,0 +1,1353 @@ +//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 armdeviceprovisioningservices + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AsyncOperationResult. +func (a AsyncOperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", a.Error) + populate(objectMap, "status", a.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AsyncOperationResult. +func (a *AsyncOperationResult) UnmarshalJSON(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 "error": + err = unpopulate(val, "Error", &a.Error) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + 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 CertificateBodyDescription. +func (c CertificateBodyDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "certificate", c.Certificate) + populate(objectMap, "isVerified", c.IsVerified) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CertificateBodyDescription. +func (c *CertificateBodyDescription) UnmarshalJSON(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 "certificate": + err = unpopulate(val, "Certificate", &c.Certificate) + delete(rawMsg, key) + case "isVerified": + err = unpopulate(val, "IsVerified", &c.IsVerified) + 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 CertificateListDescription. +func (c CertificateListDescription) 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 CertificateListDescription. +func (c *CertificateListDescription) UnmarshalJSON(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 CertificateProperties. +func (c CertificateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateByteArray(objectMap, "certificate", c.Certificate, runtime.Base64StdFormat) + populateTimeRFC1123(objectMap, "created", c.Created) + populateTimeRFC1123(objectMap, "expiry", c.Expiry) + populate(objectMap, "isVerified", c.IsVerified) + populate(objectMap, "subject", c.Subject) + populate(objectMap, "thumbprint", c.Thumbprint) + populateTimeRFC1123(objectMap, "updated", c.Updated) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CertificateProperties. +func (c *CertificateProperties) UnmarshalJSON(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 "certificate": + err = runtime.DecodeByteArray(string(val), &c.Certificate, runtime.Base64StdFormat) + delete(rawMsg, key) + case "created": + err = unpopulateTimeRFC1123(val, "Created", &c.Created) + delete(rawMsg, key) + case "expiry": + err = unpopulateTimeRFC1123(val, "Expiry", &c.Expiry) + delete(rawMsg, key) + case "isVerified": + err = unpopulate(val, "IsVerified", &c.IsVerified) + delete(rawMsg, key) + case "subject": + err = unpopulate(val, "Subject", &c.Subject) + delete(rawMsg, key) + case "thumbprint": + err = unpopulate(val, "Thumbprint", &c.Thumbprint) + delete(rawMsg, key) + case "updated": + err = unpopulateTimeRFC1123(val, "Updated", &c.Updated) + 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 CertificateResponse. +func (c CertificateResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", c.Etag) + 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 CertificateResponse. +func (c *CertificateResponse) UnmarshalJSON(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 "etag": + err = unpopulate(val, "Etag", &c.Etag) + delete(rawMsg, 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 ErrorDetails. +func (e ErrorDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "httpStatusCode", e.HTTPStatusCode) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetails. +func (e *ErrorDetails) UnmarshalJSON(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 "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "httpStatusCode": + err = unpopulate(val, "HTTPStatusCode", &e.HTTPStatusCode) + 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 ErrorMessage. +func (e ErrorMessage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorMessage. +func (e *ErrorMessage) UnmarshalJSON(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 "details": + err = unpopulate(val, "Details", &e.Details) + 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 GroupIDInformation. +func (g GroupIDInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 GroupIDInformation. +func (g *GroupIDInformation) UnmarshalJSON(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 "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 GroupIDInformationProperties. +func (g GroupIDInformationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "groupId", g.GroupID) + populate(objectMap, "requiredMembers", g.RequiredMembers) + populate(objectMap, "requiredZoneNames", g.RequiredZoneNames) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GroupIDInformationProperties. +func (g *GroupIDInformationProperties) UnmarshalJSON(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 "groupId": + err = unpopulate(val, "GroupID", &g.GroupID) + delete(rawMsg, key) + case "requiredMembers": + err = unpopulate(val, "RequiredMembers", &g.RequiredMembers) + delete(rawMsg, key) + case "requiredZoneNames": + err = unpopulate(val, "RequiredZoneNames", &g.RequiredZoneNames) + 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 IPFilterRule. +func (i IPFilterRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", i.Action) + populate(objectMap, "filterName", i.FilterName) + populate(objectMap, "ipMask", i.IPMask) + populate(objectMap, "target", i.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IPFilterRule. +func (i *IPFilterRule) UnmarshalJSON(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 "action": + err = unpopulate(val, "Action", &i.Action) + delete(rawMsg, key) + case "filterName": + err = unpopulate(val, "FilterName", &i.FilterName) + delete(rawMsg, key) + case "ipMask": + err = unpopulate(val, "IPMask", &i.IPMask) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &i.Target) + 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 IotDpsPropertiesDescription. +func (i IotDpsPropertiesDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allocationPolicy", i.AllocationPolicy) + populate(objectMap, "authorizationPolicies", i.AuthorizationPolicies) + populate(objectMap, "deviceProvisioningHostName", i.DeviceProvisioningHostName) + populate(objectMap, "enableDataResidency", i.EnableDataResidency) + populate(objectMap, "idScope", i.IDScope) + populate(objectMap, "ipFilterRules", i.IPFilterRules) + populate(objectMap, "iotHubs", i.IotHubs) + populate(objectMap, "privateEndpointConnections", i.PrivateEndpointConnections) + populate(objectMap, "provisioningState", i.ProvisioningState) + populate(objectMap, "publicNetworkAccess", i.PublicNetworkAccess) + populate(objectMap, "serviceOperationsHostName", i.ServiceOperationsHostName) + populate(objectMap, "state", i.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IotDpsPropertiesDescription. +func (i *IotDpsPropertiesDescription) UnmarshalJSON(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 "allocationPolicy": + err = unpopulate(val, "AllocationPolicy", &i.AllocationPolicy) + delete(rawMsg, key) + case "authorizationPolicies": + err = unpopulate(val, "AuthorizationPolicies", &i.AuthorizationPolicies) + delete(rawMsg, key) + case "deviceProvisioningHostName": + err = unpopulate(val, "DeviceProvisioningHostName", &i.DeviceProvisioningHostName) + delete(rawMsg, key) + case "enableDataResidency": + err = unpopulate(val, "EnableDataResidency", &i.EnableDataResidency) + delete(rawMsg, key) + case "idScope": + err = unpopulate(val, "IDScope", &i.IDScope) + delete(rawMsg, key) + case "ipFilterRules": + err = unpopulate(val, "IPFilterRules", &i.IPFilterRules) + delete(rawMsg, key) + case "iotHubs": + err = unpopulate(val, "IotHubs", &i.IotHubs) + delete(rawMsg, key) + case "privateEndpointConnections": + err = unpopulate(val, "PrivateEndpointConnections", &i.PrivateEndpointConnections) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &i.PublicNetworkAccess) + delete(rawMsg, key) + case "serviceOperationsHostName": + err = unpopulate(val, "ServiceOperationsHostName", &i.ServiceOperationsHostName) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &i.State) + 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 IotDpsSKUDefinition. +func (i IotDpsSKUDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", i.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IotDpsSKUDefinition. +func (i *IotDpsSKUDefinition) UnmarshalJSON(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 "name": + err = unpopulate(val, "Name", &i.Name) + 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 IotDpsSKUDefinitionListResult. +func (i IotDpsSKUDefinitionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IotDpsSKUDefinitionListResult. +func (i *IotDpsSKUDefinitionListResult) UnmarshalJSON(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 "nextLink": + err = unpopulate(val, "NextLink", &i.NextLink) + delete(rawMsg, 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 IotDpsSKUInfo. +func (i IotDpsSKUInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacity", i.Capacity) + populate(objectMap, "name", i.Name) + populate(objectMap, "tier", i.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IotDpsSKUInfo. +func (i *IotDpsSKUInfo) UnmarshalJSON(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 "capacity": + err = unpopulate(val, "Capacity", &i.Capacity) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &i.Name) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &i.Tier) + 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 IotHubDefinitionDescription. +func (i IotHubDefinitionDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allocationWeight", i.AllocationWeight) + populate(objectMap, "applyAllocationPolicy", i.ApplyAllocationPolicy) + populate(objectMap, "connectionString", i.ConnectionString) + populate(objectMap, "location", i.Location) + populate(objectMap, "name", i.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IotHubDefinitionDescription. +func (i *IotHubDefinitionDescription) UnmarshalJSON(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 "allocationWeight": + err = unpopulate(val, "AllocationWeight", &i.AllocationWeight) + delete(rawMsg, key) + case "applyAllocationPolicy": + err = unpopulate(val, "ApplyAllocationPolicy", &i.ApplyAllocationPolicy) + delete(rawMsg, key) + case "connectionString": + err = unpopulate(val, "ConnectionString", &i.ConnectionString) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &i.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &i.Name) + 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 NameAvailabilityInfo. +func (n NameAvailabilityInfo) 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 NameAvailabilityInfo. +func (n *NameAvailabilityInfo) UnmarshalJSON(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 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 OperationInputs. +func (o OperationInputs) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", o.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationInputs. +func (o *OperationInputs) UnmarshalJSON(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 "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 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 PrivateEndpoint. +func (p PrivateEndpoint) 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 PrivateEndpoint. +func (p *PrivateEndpoint) UnmarshalJSON(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 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, "systemData", p.SystemData) + 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 "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + 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 PrivateEndpointConnectionProperties. +func (p PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "privateEndpoint", p.PrivateEndpoint) + populate(objectMap, "privateLinkServiceConnectionState", p.PrivateLinkServiceConnectionState) + 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) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResources. +func (p PrivateLinkResources) 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 PrivateLinkResources. +func (p *PrivateLinkResources) UnmarshalJSON(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 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 ProvisioningServiceDescription. +func (p ProvisioningServiceDescription) 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, "sku", p.SKU) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisioningServiceDescription. +func (p *ProvisioningServiceDescription) UnmarshalJSON(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 "sku": + err = unpopulate(val, "SKU", &p.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + 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 ProvisioningServiceDescriptionListResult. +func (p ProvisioningServiceDescriptionListResult) 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 ProvisioningServiceDescriptionListResult. +func (p *ProvisioningServiceDescriptionListResult) UnmarshalJSON(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 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, "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 "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 SharedAccessSignatureAuthorizationRuleAccessRightsDescription. +func (s SharedAccessSignatureAuthorizationRuleAccessRightsDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "keyName", s.KeyName) + populate(objectMap, "primaryKey", s.PrimaryKey) + populate(objectMap, "rights", s.Rights) + populate(objectMap, "secondaryKey", s.SecondaryKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SharedAccessSignatureAuthorizationRuleAccessRightsDescription. +func (s *SharedAccessSignatureAuthorizationRuleAccessRightsDescription) UnmarshalJSON(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 "keyName": + err = unpopulate(val, "KeyName", &s.KeyName) + delete(rawMsg, key) + case "primaryKey": + err = unpopulate(val, "PrimaryKey", &s.PrimaryKey) + 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 SharedAccessSignatureAuthorizationRuleListResult. +func (s SharedAccessSignatureAuthorizationRuleListResult) 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 SharedAccessSignatureAuthorizationRuleListResult. +func (s *SharedAccessSignatureAuthorizationRuleListResult) UnmarshalJSON(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 TagsResource. +func (t TagsResource) 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 TagsResource. +func (t *TagsResource) UnmarshalJSON(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 VerificationCodeRequest. +func (v VerificationCodeRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "certificate", v.Certificate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VerificationCodeRequest. +func (v *VerificationCodeRequest) UnmarshalJSON(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 "certificate": + err = unpopulate(val, "Certificate", &v.Certificate) + 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 VerificationCodeResponse. +func (v VerificationCodeResponse) 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 VerificationCodeResponse. +func (v *VerificationCodeResponse) UnmarshalJSON(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 VerificationCodeResponseProperties. +func (v VerificationCodeResponseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateByteArray(objectMap, "certificate", v.Certificate, runtime.Base64StdFormat) + populate(objectMap, "created", v.Created) + populate(objectMap, "expiry", v.Expiry) + populate(objectMap, "isVerified", v.IsVerified) + populate(objectMap, "subject", v.Subject) + populate(objectMap, "thumbprint", v.Thumbprint) + populate(objectMap, "updated", v.Updated) + populate(objectMap, "verificationCode", v.VerificationCode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VerificationCodeResponseProperties. +func (v *VerificationCodeResponseProperties) UnmarshalJSON(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 "certificate": + err = runtime.DecodeByteArray(string(val), &v.Certificate, runtime.Base64StdFormat) + delete(rawMsg, key) + case "created": + err = unpopulate(val, "Created", &v.Created) + delete(rawMsg, key) + case "expiry": + err = unpopulate(val, "Expiry", &v.Expiry) + delete(rawMsg, key) + case "isVerified": + err = unpopulate(val, "IsVerified", &v.IsVerified) + delete(rawMsg, key) + case "subject": + err = unpopulate(val, "Subject", &v.Subject) + delete(rawMsg, key) + case "thumbprint": + err = unpopulate(val, "Thumbprint", &v.Thumbprint) + delete(rawMsg, key) + case "updated": + err = unpopulate(val, "Updated", &v.Updated) + delete(rawMsg, key) + case "verificationCode": + err = unpopulate(val, "VerificationCode", &v.VerificationCode) + 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 populateByteArray(m map[string]any, k string, b []byte, f runtime.Base64Encoding) { + if azcore.IsNullValue(b) { + m[k] = nil + } else if len(b) == 0 { + return + } else { + m[k] = runtime.EncodeByteArray(b, f) + } +} + +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/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_operations_client.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/operations_client.go similarity index 77% rename from sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_operations_client.go rename to sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/operations_client.go index c351aa833a7c..b01c10a3e0a0 100644 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_operations_client.go +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/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 armdeviceprovisioningservices @@ -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.Devices REST API operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-05 -// 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.Devices/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/deviceprovisioningservices/armdeviceprovisioningservices/operations_client_example_test.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/operations_client_example_test.go new file mode 100644 index 000000000000..8c4875aa00d4 --- /dev/null +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/operations_client_example_test.go @@ -0,0 +1,326 @@ +//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 armdeviceprovisioningservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSOperations.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 := armdeviceprovisioningservices.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 = armdeviceprovisioningservices.OperationListResult{ + // Value: []*armdeviceprovisioningservices.Operation{ + // { + // Name: to.Ptr("Microsoft.Devices/register/action"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Register Resource Provider"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/IotHubs/diagnosticSettings/read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Get Diagnostic Setting"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/IotHubs/diagnosticSettings/write"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Set Diagnostic Setting"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/IotHubs/metricDefinitions/read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Read IotHub service metric definitions"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/IotHubs/logDefinitions/read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Read IotHub service log definitions"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/operations/Read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Get All ResourceProvider Operations"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/checkNameAvailability/Action"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Check If IotHub name is available"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/usages/Read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Get Subscription Usages"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/Read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Get IotHub(s)"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/Write"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Create or update IotHub Resource"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/Delete"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Delete IotHub Resource"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/iotHubStats/Read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Get IotHub Statistics"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/skus/Read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Get valid IotHub Skus"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/listkeys/Action"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Get all IotHub Keys"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/iotHubKeys/listkeys/Action"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Get IotHub Key for the given name"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/eventHubEndpoints/consumerGroups/Write"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Create EventHub Consumer Group"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/eventHubEndpoints/consumerGroups/Read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Get EventHub Consumer Group(s)"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/eventHubEndpoints/consumerGroups/Delete"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Delete EventHub Consumer Group"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/exportDevices/Action"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Export Devices"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/importDevices/Action"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Import Devices"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/jobs/Read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Get the Job(s) on IotHub"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/quotaMetrics/Read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Get Quota Metrics"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/routing/routes/$testall/Action"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Routing Rule Test All"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/routing/routes/$testnew/Action"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Routing Rule Test Route"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/iotHubs/routingEndpointsHealth/Read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Get Endpoint Health"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/ProvisioningServices/diagnosticSettings/read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Get Diagnostic Setting"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/ProvisioningServices/diagnosticSettings/write"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Set Diagnostic Setting"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/ProvisioningServices/metricDefinitions/read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Read DPS service metric definitions"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/ProvisioningServices/logDefinitions/read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Read DPS service log definitions"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("IotHubs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/checkProvisioningServiceNameAvailability/Action"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Check If Provisioning Service name is available"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("ProvisioningServives"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/provisioningServices/Read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Get Provisioning Service resource"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("ProvisioningServices"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/provisioningServices/Write"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Create Provisioning Service resource"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("ProvisioningServices"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/provisioningServices/Delete"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Delete Provisioning Service resource"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("ProvisioningServices"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/provisioningServices/skus/Read"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("Delete Provisioning Service resource"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("ProvisioningServices"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Devices/provisioningServices/listkeys/Action"), + // Display: &armdeviceprovisioningservices.OperationDisplay{ + // Operation: to.Ptr("get security related metadata"), + // Provider: to.Ptr("Microsoft Devices"), + // Resource: to.Ptr("ProvisioningServices"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_response_types.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/response_types.go similarity index 88% rename from sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_response_types.go rename to sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/response_types.go index d21478f2db81..8d8fbe4b4239 100644 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_response_types.go +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/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 armdeviceprovisioningservices @@ -43,22 +44,22 @@ type IotDpsResourceClientCheckProvisioningServiceNameAvailabilityResponse struct NameAvailabilityInfo } -// IotDpsResourceClientCreateOrUpdatePrivateEndpointConnectionResponse contains the response from method IotDpsResourceClient.CreateOrUpdatePrivateEndpointConnection. +// IotDpsResourceClientCreateOrUpdatePrivateEndpointConnectionResponse contains the response from method IotDpsResourceClient.BeginCreateOrUpdatePrivateEndpointConnection. type IotDpsResourceClientCreateOrUpdatePrivateEndpointConnectionResponse struct { PrivateEndpointConnection } -// IotDpsResourceClientCreateOrUpdateResponse contains the response from method IotDpsResourceClient.CreateOrUpdate. +// IotDpsResourceClientCreateOrUpdateResponse contains the response from method IotDpsResourceClient.BeginCreateOrUpdate. type IotDpsResourceClientCreateOrUpdateResponse struct { ProvisioningServiceDescription } -// IotDpsResourceClientDeletePrivateEndpointConnectionResponse contains the response from method IotDpsResourceClient.DeletePrivateEndpointConnection. +// IotDpsResourceClientDeletePrivateEndpointConnectionResponse contains the response from method IotDpsResourceClient.BeginDeletePrivateEndpointConnection. type IotDpsResourceClientDeletePrivateEndpointConnectionResponse struct { PrivateEndpointConnection } -// IotDpsResourceClientDeleteResponse contains the response from method IotDpsResourceClient.Delete. +// IotDpsResourceClientDeleteResponse contains the response from method IotDpsResourceClient.BeginDelete. type IotDpsResourceClientDeleteResponse struct { // placeholder for future response values } @@ -83,12 +84,12 @@ type IotDpsResourceClientGetResponse struct { ProvisioningServiceDescription } -// IotDpsResourceClientListByResourceGroupResponse contains the response from method IotDpsResourceClient.ListByResourceGroup. +// IotDpsResourceClientListByResourceGroupResponse contains the response from method IotDpsResourceClient.NewListByResourceGroupPager. type IotDpsResourceClientListByResourceGroupResponse struct { ProvisioningServiceDescriptionListResult } -// IotDpsResourceClientListBySubscriptionResponse contains the response from method IotDpsResourceClient.ListBySubscription. +// IotDpsResourceClientListBySubscriptionResponse contains the response from method IotDpsResourceClient.NewListBySubscriptionPager. type IotDpsResourceClientListBySubscriptionResponse struct { ProvisioningServiceDescriptionListResult } @@ -98,7 +99,7 @@ type IotDpsResourceClientListKeysForKeyNameResponse struct { SharedAccessSignatureAuthorizationRuleAccessRightsDescription } -// IotDpsResourceClientListKeysResponse contains the response from method IotDpsResourceClient.ListKeys. +// IotDpsResourceClientListKeysResponse contains the response from method IotDpsResourceClient.NewListKeysPager. type IotDpsResourceClientListKeysResponse struct { SharedAccessSignatureAuthorizationRuleListResult } @@ -114,17 +115,17 @@ type IotDpsResourceClientListPrivateLinkResourcesResponse struct { PrivateLinkResources } -// IotDpsResourceClientListValidSKUsResponse contains the response from method IotDpsResourceClient.ListValidSKUs. +// IotDpsResourceClientListValidSKUsResponse contains the response from method IotDpsResourceClient.NewListValidSKUsPager. type IotDpsResourceClientListValidSKUsResponse struct { IotDpsSKUDefinitionListResult } -// IotDpsResourceClientUpdateResponse contains the response from method IotDpsResourceClient.Update. +// IotDpsResourceClientUpdateResponse contains the response from method IotDpsResourceClient.BeginUpdate. type IotDpsResourceClientUpdateResponse struct { ProvisioningServiceDescription } -// 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/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_time_rfc1123.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/time_rfc1123.go similarity index 94% rename from sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_time_rfc1123.go rename to sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/time_rfc1123.go index 47a263eb7da8..f16e0b173c08 100644 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_time_rfc1123.go +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/time_rfc1123.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 armdeviceprovisioningservices @@ -45,7 +46,7 @@ func (t *timeRFC1123) UnmarshalText(data []byte) error { return err } -func populateTimeRFC1123(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC1123(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_time_rfc3339.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/time_rfc3339.go index a16c7713c2bb..3d0da901282e 100644 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/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 armdeviceprovisioningservices @@ -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/deviceprovisioningservices/armdeviceprovisioningservices/ze_generated_example_dpscertificate_client_test.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/ze_generated_example_dpscertificate_client_test.go deleted file mode 100644 index ffb241f73d0f..000000000000 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/ze_generated_example_dpscertificate_client_test.go +++ /dev/null @@ -1,185 +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 armdeviceprovisioningservices_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/deviceprovisioningservices/armdeviceprovisioningservices" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetCertificate.json -func ExampleDpsCertificateClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewDpsCertificateClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "cert", - "myResourceGroup", - "myFirstProvisioningService", - &armdeviceprovisioningservices.DpsCertificateClientGetOptions{IfMatch: 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCertificateCreateOrUpdate.json -func ExampleDpsCertificateClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewDpsCertificateClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "myResourceGroup", - "myFirstProvisioningService", - "cert", - armdeviceprovisioningservices.CertificateResponse{ - Properties: &armdeviceprovisioningservices.CertificateProperties{ - Certificate: []byte("############################################"), - }, - }, - &armdeviceprovisioningservices.DpsCertificateClientCreateOrUpdateOptions{IfMatch: 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSDeleteCertificate.json -func ExampleDpsCertificateClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewDpsCertificateClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "myResourceGroup", - "AAAAAAAADGk=", - "myFirstProvisioningService", - "cert", - &armdeviceprovisioningservices.DpsCertificateClientDeleteOptions{CertificateName1: nil, - CertificateIsVerified: nil, - CertificatePurpose: nil, - CertificateCreated: nil, - CertificateLastUpdated: nil, - CertificateHasPrivateKey: nil, - CertificateNonce: 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetCertificates.json -func ExampleDpsCertificateClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewDpsCertificateClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, - "myResourceGroup", - "myFirstProvisioningService", - 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGenerateVerificationCode.json -func ExampleDpsCertificateClient_GenerateVerificationCode() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewDpsCertificateClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GenerateVerificationCode(ctx, - "cert", - "AAAAAAAADGk=", - "myResourceGroup", - "myFirstProvisioningService", - &armdeviceprovisioningservices.DpsCertificateClientGenerateVerificationCodeOptions{CertificateName1: nil, - CertificateIsVerified: nil, - CertificatePurpose: nil, - CertificateCreated: nil, - CertificateLastUpdated: nil, - CertificateHasPrivateKey: nil, - CertificateNonce: 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSVerifyCertificate.json -func ExampleDpsCertificateClient_VerifyCertificate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewDpsCertificateClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.VerifyCertificate(ctx, - "cert", - "AAAAAAAADGk=", - "myResourceGroup", - "myFirstProvisioningService", - armdeviceprovisioningservices.VerificationCodeRequest{ - Certificate: to.Ptr("#####################################"), - }, - &armdeviceprovisioningservices.DpsCertificateClientVerifyCertificateOptions{CertificateName1: nil, - CertificateIsVerified: nil, - CertificatePurpose: nil, - CertificateCreated: nil, - CertificateLastUpdated: nil, - CertificateHasPrivateKey: nil, - CertificateNonce: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/ze_generated_example_iotdpsresource_client_test.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/ze_generated_example_iotdpsresource_client_test.go deleted file mode 100644 index 2a982e5d9463..000000000000 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/ze_generated_example_iotdpsresource_client_test.go +++ /dev/null @@ -1,429 +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 armdeviceprovisioningservices_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/deviceprovisioningservices/armdeviceprovisioningservices" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGet.json -func ExampleIotDpsResourceClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myFirstProvisioningService", - "myResourceGroup", - 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCreate.json -func ExampleIotDpsResourceClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "myResourceGroup", - "myFirstProvisioningService", - armdeviceprovisioningservices.ProvisioningServiceDescription{ - Location: to.Ptr("East US"), - Tags: map[string]*string{}, - Properties: &armdeviceprovisioningservices.IotDpsPropertiesDescription{ - EnableDataResidency: to.Ptr(false), - }, - SKU: &armdeviceprovisioningservices.IotDpsSKUInfo{ - Name: to.Ptr(armdeviceprovisioningservices.IotDpsSKUS1), - Capacity: to.Ptr[int64](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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSPatch.json -func ExampleIotDpsResourceClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "myResourceGroup", - "myFirstProvisioningService", - armdeviceprovisioningservices.TagsResource{ - Tags: map[string]*string{ - "foo": to.Ptr("bar"), - }, - }, - 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSDelete.json -func ExampleIotDpsResourceClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "myFirstProvisioningService", - "myResourceGroup", - 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListBySubscription.json -func ExampleIotDpsResourceClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListByResourceGroup.json -func ExampleIotDpsResourceClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetOperationResult.json -func ExampleIotDpsResourceClient_GetOperationResult() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetOperationResult(ctx, - "MTY5OTNmZDctODI5Yy00N2E2LTkxNDQtMDU1NGIyYzY1ZjRl", - "myResourceGroup", - "myFirstProvisioningService", - "1508265712453", - 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCheckNameAvailability.json -func ExampleIotDpsResourceClient_CheckProvisioningServiceNameAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CheckProvisioningServiceNameAvailability(ctx, - armdeviceprovisioningservices.OperationInputs{ - Name: to.Ptr("test213123"), - }, - 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListKeys.json -func ExampleIotDpsResourceClient_NewListKeysPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListKeysPager("myFirstProvisioningService", - "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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetKey.json -func ExampleIotDpsResourceClient_ListKeysForKeyName() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListKeysForKeyName(ctx, - "myFirstProvisioningService", - "testKey", - "myResourceGroup", - 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListPrivateLinkResources.json -func ExampleIotDpsResourceClient_ListPrivateLinkResources() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListPrivateLinkResources(ctx, - "myResourceGroup", - "myFirstProvisioningService", - 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetPrivateLinkResources.json -func ExampleIotDpsResourceClient_GetPrivateLinkResources() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetPrivateLinkResources(ctx, - "myResourceGroup", - "myFirstProvisioningService", - "iotDps", - 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListPrivateEndpointConnections.json -func ExampleIotDpsResourceClient_ListPrivateEndpointConnections() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListPrivateEndpointConnections(ctx, - "myResourceGroup", - "myFirstProvisioningService", - 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetPrivateEndpointConnection.json -func ExampleIotDpsResourceClient_GetPrivateEndpointConnection() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetPrivateEndpointConnection(ctx, - "myResourceGroup", - "myFirstProvisioningService", - "myPrivateEndpointConnection", - 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCreateOrUpdatePrivateEndpointConnection.json -func ExampleIotDpsResourceClient_BeginCreateOrUpdatePrivateEndpointConnection() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdatePrivateEndpointConnection(ctx, - "myResourceGroup", - "myFirstProvisioningService", - "myPrivateEndpointConnection", - armdeviceprovisioningservices.PrivateEndpointConnection{ - Properties: &armdeviceprovisioningservices.PrivateEndpointConnectionProperties{ - PrivateLinkServiceConnectionState: &armdeviceprovisioningservices.PrivateLinkServiceConnectionState{ - Description: to.Ptr("Approved by johndoe@contoso.com"), - Status: to.Ptr(armdeviceprovisioningservices.PrivateLinkServiceConnectionStatusApproved), - }, - }, - }, - 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/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSDeletePrivateEndpointConnection.json -func ExampleIotDpsResourceClient_BeginDeletePrivateEndpointConnection() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdeviceprovisioningservices.NewIotDpsResourceClient("91d12660-3dec-467a-be2a-213b5544ddc0", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDeletePrivateEndpointConnection(ctx, - "myResourceGroup", - "myFirstProvisioningService", - "myPrivateEndpointConnection", - 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/deviceprovisioningservices/armdeviceprovisioningservices/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/ze_generated_example_operations_client_test.go deleted file mode 100644 index f0affa00e803..000000000000 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/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 armdeviceprovisioningservices_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSOperations.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 := armdeviceprovisioningservices.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/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_models_serde.go b/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_models_serde.go deleted file mode 100644 index 8a67ef980067..000000000000 --- a/sdk/resourcemanager/deviceprovisioningservices/armdeviceprovisioningservices/zz_generated_models_serde.go +++ /dev/null @@ -1,237 +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 armdeviceprovisioningservices - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type CertificateProperties. -func (c CertificateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateByteArray(objectMap, "certificate", c.Certificate, runtime.Base64StdFormat) - populateTimeRFC1123(objectMap, "created", c.Created) - populateTimeRFC1123(objectMap, "expiry", c.Expiry) - populate(objectMap, "isVerified", c.IsVerified) - populate(objectMap, "subject", c.Subject) - populate(objectMap, "thumbprint", c.Thumbprint) - populateTimeRFC1123(objectMap, "updated", c.Updated) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type CertificateProperties. -func (c *CertificateProperties) UnmarshalJSON(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 "certificate": - err = runtime.DecodeByteArray(string(val), &c.Certificate, runtime.Base64StdFormat) - delete(rawMsg, key) - case "created": - err = unpopulateTimeRFC1123(val, "Created", &c.Created) - delete(rawMsg, key) - case "expiry": - err = unpopulateTimeRFC1123(val, "Expiry", &c.Expiry) - delete(rawMsg, key) - case "isVerified": - err = unpopulate(val, "IsVerified", &c.IsVerified) - delete(rawMsg, key) - case "subject": - err = unpopulate(val, "Subject", &c.Subject) - delete(rawMsg, key) - case "thumbprint": - err = unpopulate(val, "Thumbprint", &c.Thumbprint) - delete(rawMsg, key) - case "updated": - err = unpopulateTimeRFC1123(val, "Updated", &c.Updated) - 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 IotDpsPropertiesDescription. -func (i IotDpsPropertiesDescription) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "allocationPolicy", i.AllocationPolicy) - populate(objectMap, "authorizationPolicies", i.AuthorizationPolicies) - populate(objectMap, "deviceProvisioningHostName", i.DeviceProvisioningHostName) - populate(objectMap, "enableDataResidency", i.EnableDataResidency) - populate(objectMap, "idScope", i.IDScope) - populate(objectMap, "ipFilterRules", i.IPFilterRules) - populate(objectMap, "iotHubs", i.IotHubs) - populate(objectMap, "privateEndpointConnections", i.PrivateEndpointConnections) - populate(objectMap, "provisioningState", i.ProvisioningState) - populate(objectMap, "publicNetworkAccess", i.PublicNetworkAccess) - populate(objectMap, "serviceOperationsHostName", i.ServiceOperationsHostName) - populate(objectMap, "state", i.State) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ProvisioningServiceDescription. -func (p ProvisioningServiceDescription) 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, "sku", p.SKU) - populate(objectMap, "systemData", p.SystemData) - 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, "tags", r.Tags) - populate(objectMap, "type", r.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 TagsResource. -func (t TagsResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", t.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type VerificationCodeResponseProperties. -func (v *VerificationCodeResponseProperties) UnmarshalJSON(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 "certificate": - err = runtime.DecodeByteArray(string(val), &v.Certificate, runtime.Base64StdFormat) - delete(rawMsg, key) - case "created": - err = unpopulate(val, "Created", &v.Created) - delete(rawMsg, key) - case "expiry": - err = unpopulate(val, "Expiry", &v.Expiry) - delete(rawMsg, key) - case "isVerified": - err = unpopulate(val, "IsVerified", &v.IsVerified) - delete(rawMsg, key) - case "subject": - err = unpopulate(val, "Subject", &v.Subject) - delete(rawMsg, key) - case "thumbprint": - err = unpopulate(val, "Thumbprint", &v.Thumbprint) - delete(rawMsg, key) - case "updated": - err = unpopulate(val, "Updated", &v.Updated) - delete(rawMsg, key) - case "verificationCode": - err = unpopulate(val, "VerificationCode", &v.VerificationCode) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func populateByteArray(m map[string]interface{}, k string, b []byte, f runtime.Base64Encoding) { - if azcore.IsNullValue(b) { - m[k] = nil - } else if len(b) == 0 { - return - } else { - m[k] = runtime.EncodeByteArray(b, f) - } -} - -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/deviceupdate/armdeviceupdate/CHANGELOG.md b/sdk/resourcemanager/deviceupdate/armdeviceupdate/CHANGELOG.md index db3ab6b8d7ff..4c98c907c080 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/CHANGELOG.md +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-08-11) ### Other Changes - Release stable version. diff --git a/sdk/resourcemanager/deviceupdate/armdeviceupdate/README.md b/sdk/resourcemanager/deviceupdate/armdeviceupdate/README.md index 687af22a1898..12c4b9b782c5 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/README.md +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/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 Device Update 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 Device Update 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 := armdeviceupdate.NewPrivateEndpointConnectionProxiesClient(, cred, nil) +clientFactory, err := armdeviceupdate.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 := armdeviceupdate.NewPrivateEndpointConnectionProxiesClient(, cred, &options) +clientFactory, err := armdeviceupdate.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.NewAccountsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/deviceupdate/armdeviceupdate/accounts_client.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/accounts_client.go index c792f3b69fdb..2ebc37e51808 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/accounts_client.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/accounts_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 ( // AccountsClient contains the methods for the Accounts group. // Don't use this type directly, use NewAccountsClient() instead. type AccountsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAccountsClient creates a new instance of AccountsClient with the specified values. -// subscriptionID - The Azure subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AccountsClient, 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+".AccountsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AccountsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Creates or updates Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// account - Account details. -// options - AccountsClientBeginCreateOptions contains the optional parameters for the AccountsClient.BeginCreate method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - account - Account details. +// - options - AccountsClientBeginCreateOptions contains the optional parameters for the AccountsClient.BeginCreate method. func (client *AccountsClient) BeginCreate(ctx context.Context, resourceGroupName string, accountName string, account Account, options *AccountsClientBeginCreateOptions) (*runtime.Poller[AccountsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, accountName, account, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AccountsClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AccountsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[AccountsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AccountsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Creates or updates Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 func (client *AccountsClient) create(ctx context.Context, resourceGroupName string, accountName string, account Account, options *AccountsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, account, 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 *AccountsClient) createCreateRequest(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 } @@ -122,33 +113,35 @@ func (client *AccountsClient) createCreateRequest(ctx context.Context, resourceG // BeginDelete - Deletes account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// options - AccountsClientBeginDeleteOptions contains the optional parameters for the AccountsClient.BeginDelete method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - options - AccountsClientBeginDeleteOptions contains the optional parameters for the AccountsClient.BeginDelete method. func (client *AccountsClient) BeginDelete(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientBeginDeleteOptions) (*runtime.Poller[AccountsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, accountName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AccountsClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AccountsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[AccountsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AccountsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 func (client *AccountsClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, 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 } @@ -173,7 +166,7 @@ func (client *AccountsClient) deleteCreateRequest(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.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 } @@ -186,16 +179,17 @@ func (client *AccountsClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Returns account details for the given account name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// options - AccountsClientGetOptions contains the optional parameters for the AccountsClient.Get method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - options - AccountsClientGetOptions contains the optional parameters for the AccountsClient.Get method. func (client *AccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientGetOptions) (AccountsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return AccountsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientGetResponse{}, err } @@ -220,7 +214,7 @@ func (client *AccountsClient) getCreateRequest(ctx context.Context, resourceGrou 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 } @@ -241,16 +235,17 @@ func (client *AccountsClient) getHandleResponse(resp *http.Response) (AccountsCl } // Head - Checks whether account exists. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// options - AccountsClientHeadOptions contains the optional parameters for the AccountsClient.Head method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - options - AccountsClientHeadOptions contains the optional parameters for the AccountsClient.Head method. func (client *AccountsClient) Head(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientHeadOptions) (AccountsClientHeadResponse, error) { req, err := client.headCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return AccountsClientHeadResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientHeadResponse{}, err } @@ -275,7 +270,7 @@ func (client *AccountsClient) headCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodHead, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -287,11 +282,11 @@ func (client *AccountsClient) headCreateRequest(ctx context.Context, resourceGro } // NewListByResourceGroupPager - Returns list of Accounts. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// options - AccountsClientListByResourceGroupOptions contains the optional parameters for the AccountsClient.ListByResourceGroup -// method. +// - resourceGroupName - The resource group name. +// - options - AccountsClientListByResourceGroupOptions contains the optional parameters for the AccountsClient.NewListByResourceGroupPager +// method. func (client *AccountsClient) NewListByResourceGroupPager(resourceGroupName string, options *AccountsClientListByResourceGroupOptions) *runtime.Pager[AccountsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[AccountsClientListByResourceGroupResponse]{ More: func(page AccountsClientListByResourceGroupResponse) bool { @@ -308,7 +303,7 @@ func (client *AccountsClient) NewListByResourceGroupPager(resourceGroupName stri if err != nil { return AccountsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientListByResourceGroupResponse{}, err } @@ -331,7 +326,7 @@ func (client *AccountsClient) listByResourceGroupCreateRequest(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 } @@ -352,10 +347,10 @@ func (client *AccountsClient) listByResourceGroupHandleResponse(resp *http.Respo } // NewListBySubscriptionPager - Returns list of Accounts. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// options - AccountsClientListBySubscriptionOptions contains the optional parameters for the AccountsClient.ListBySubscription -// method. +// - options - AccountsClientListBySubscriptionOptions contains the optional parameters for the AccountsClient.NewListBySubscriptionPager +// method. func (client *AccountsClient) NewListBySubscriptionPager(options *AccountsClientListBySubscriptionOptions) *runtime.Pager[AccountsClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[AccountsClientListBySubscriptionResponse]{ More: func(page AccountsClientListBySubscriptionResponse) bool { @@ -372,7 +367,7 @@ func (client *AccountsClient) NewListBySubscriptionPager(options *AccountsClient if err != nil { return AccountsClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientListBySubscriptionResponse{}, err } @@ -391,7 +386,7 @@ func (client *AccountsClient) 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 } @@ -413,34 +408,36 @@ func (client *AccountsClient) listBySubscriptionHandleResponse(resp *http.Respon // BeginUpdate - Updates account's patchable properties // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// accountUpdatePayload - Updated Account. -// options - AccountsClientBeginUpdateOptions contains the optional parameters for the AccountsClient.BeginUpdate method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - accountUpdatePayload - Updated Account. +// - options - AccountsClientBeginUpdateOptions contains the optional parameters for the AccountsClient.BeginUpdate method. func (client *AccountsClient) BeginUpdate(ctx context.Context, resourceGroupName string, accountName string, accountUpdatePayload AccountUpdate, options *AccountsClientBeginUpdateOptions) (*runtime.Poller[AccountsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, accountName, accountUpdatePayload, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AccountsClientUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AccountsClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[AccountsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AccountsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates account's patchable properties // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 func (client *AccountsClient) update(ctx context.Context, resourceGroupName string, accountName string, accountUpdatePayload AccountUpdate, options *AccountsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, accountUpdatePayload, 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 } @@ -465,7 +462,7 @@ func (client *AccountsClient) updateCreateRequest(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.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/deviceupdate/armdeviceupdate/accounts_client_example_test.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/accounts_client_example_test.go index c161b704e4e1..abfc11ecd31d 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/accounts_client_example_test.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/accounts_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 armdeviceupdate_test @@ -17,78 +18,161 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceupdate/armdeviceupdate" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Accounts/Accounts_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Accounts/Accounts_List.json func ExampleAccountsClient_NewListBySubscriptionPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewAccountsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySubscriptionPager(nil) + pager := clientFactory.NewAccountsClient().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.AccountList = armdeviceupdate.AccountList{ + // Value: []*armdeviceupdate.Account{ + // { + // Name: to.Ptr("contoso"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso"), + // Location: to.Ptr("westus2"), + // Properties: &armdeviceupdate.AccountProperties{ + // HostName: to.Ptr("contoso.api.adu.microsoft.com"), + // Locations: []*armdeviceupdate.Location{ + // { + // Name: to.Ptr("westus2"), + // Role: to.Ptr(armdeviceupdate.RolePrimary), + // }, + // { + // Name: to.Ptr("westcentralus"), + // Role: to.Ptr(armdeviceupdate.RoleFailover), + // }}, + // PrivateEndpointConnections: []*armdeviceupdate.PrivateEndpointConnection{ + // { + // Name: to.Ptr("peexample01"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso/privateEndpointConnections/peexample01"), + // Properties: &armdeviceupdate.PrivateEndpointConnectionProperties{ + // GroupIDs: []*string{ + // to.Ptr("groupId")}, + // PrivateEndpoint: &armdeviceupdate.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/peexample01"), + // }, + // PrivateLinkServiceConnectionState: &armdeviceupdate.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armdeviceupdate.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armdeviceupdate.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }}, + // ProvisioningState: to.Ptr(armdeviceupdate.ProvisioningStateSucceeded), + // SKU: to.Ptr(armdeviceupdate.SKUStandard), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Accounts/Accounts_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Accounts/Accounts_Get.json func ExampleAccountsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewAccountsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "test-rg", "contoso", nil) + res, err := clientFactory.NewAccountsClient().Get(ctx, "test-rg", "contoso", 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.Account = armdeviceupdate.Account{ + // Name: to.Ptr("contoso"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso"), + // Location: to.Ptr("westus2"), + // Properties: &armdeviceupdate.AccountProperties{ + // HostName: to.Ptr("contoso.api.adu.microsoft.com"), + // Locations: []*armdeviceupdate.Location{ + // { + // Name: to.Ptr("westus2"), + // Role: to.Ptr(armdeviceupdate.RolePrimary), + // }, + // { + // Name: to.Ptr("westcentralus"), + // Role: to.Ptr(armdeviceupdate.RoleFailover), + // }}, + // PrivateEndpointConnections: []*armdeviceupdate.PrivateEndpointConnection{ + // { + // Name: to.Ptr("peexample01"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso/privateEndpointConnections/peexample01"), + // Properties: &armdeviceupdate.PrivateEndpointConnectionProperties{ + // GroupIDs: []*string{ + // to.Ptr("groupId")}, + // PrivateEndpoint: &armdeviceupdate.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/peexample01"), + // }, + // PrivateLinkServiceConnectionState: &armdeviceupdate.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armdeviceupdate.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armdeviceupdate.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }}, + // ProvisioningState: to.Ptr(armdeviceupdate.ProvisioningStateSucceeded), + // SKU: to.Ptr(armdeviceupdate.SKUStandard), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Accounts/Accounts_Head.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Accounts/Accounts_Head.json func ExampleAccountsClient_Head() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewAccountsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Head(ctx, "test-rg", "contoso", nil) + _, err = clientFactory.NewAccountsClient().Head(ctx, "test-rg", "contoso", 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/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Accounts/Accounts_Create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Accounts/Accounts_Create.json func ExampleAccountsClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewAccountsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "test-rg", "contoso", armdeviceupdate.Account{ + poller, err := clientFactory.NewAccountsClient().BeginCreate(ctx, "test-rg", "contoso", armdeviceupdate.Account{ Location: to.Ptr("westus2"), Properties: &armdeviceupdate.AccountProperties{}, }, nil) @@ -101,18 +185,18 @@ func ExampleAccountsClient_BeginCreate() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Accounts/Accounts_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Accounts/Accounts_Delete.json func ExampleAccountsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewAccountsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "test-rg", "contoso", nil) + poller, err := clientFactory.NewAccountsClient().BeginDelete(ctx, "test-rg", "contoso", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -122,18 +206,18 @@ func ExampleAccountsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Accounts/Accounts_Update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Accounts/Accounts_Update.json func ExampleAccountsClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewAccountsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "test-rg", "contoso", armdeviceupdate.AccountUpdate{ + poller, err := clientFactory.NewAccountsClient().BeginUpdate(ctx, "test-rg", "contoso", armdeviceupdate.AccountUpdate{ Tags: map[string]*string{ "tagKey": to.Ptr("tagValue"), }, @@ -145,6 +229,49 @@ func ExampleAccountsClient_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.Account = armdeviceupdate.Account{ + // Name: to.Ptr("contoso"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "tagKey": to.Ptr("tagValue"), + // }, + // Properties: &armdeviceupdate.AccountProperties{ + // HostName: to.Ptr("contoso.api.adu.microsoft.com"), + // Locations: []*armdeviceupdate.Location{ + // { + // Name: to.Ptr("westus2"), + // Role: to.Ptr(armdeviceupdate.RolePrimary), + // }, + // { + // Name: to.Ptr("westcentralus"), + // Role: to.Ptr(armdeviceupdate.RoleFailover), + // }}, + // PrivateEndpointConnections: []*armdeviceupdate.PrivateEndpointConnection{ + // { + // Name: to.Ptr("peexample01"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso/privateEndpointConnections/peexample01"), + // Properties: &armdeviceupdate.PrivateEndpointConnectionProperties{ + // GroupIDs: []*string{ + // to.Ptr("groupId")}, + // PrivateEndpoint: &armdeviceupdate.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/peexample01"), + // }, + // PrivateLinkServiceConnectionState: &armdeviceupdate.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armdeviceupdate.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armdeviceupdate.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }}, + // ProvisioningState: to.Ptr(armdeviceupdate.ProvisioningStateSucceeded), + // SKU: to.Ptr(armdeviceupdate.SKUStandard), + // }, + // } } diff --git a/sdk/resourcemanager/deviceupdate/armdeviceupdate/autorest.md b/sdk/resourcemanager/deviceupdate/armdeviceupdate/autorest.md index 66d3effcb309..bca64a698063 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/autorest.md +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/autorest.md @@ -8,5 +8,5 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/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/deviceupdate/armdeviceupdate/client.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/client.go index 0c3353da7b1a..0d206f7fabde 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/client.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/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,46 +24,38 @@ import ( // Client contains the methods for the DeviceUpdate 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. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. +// - 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 } // CheckNameAvailability - Checks ADU resource name availability. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// request - Check Name Availability Request. -// options - ClientCheckNameAvailabilityOptions contains the optional parameters for the Client.CheckNameAvailability method. +// - request - Check Name Availability Request. +// - options - ClientCheckNameAvailabilityOptions contains the optional parameters for the Client.CheckNameAvailability method. func (client *Client) CheckNameAvailability(ctx context.Context, request CheckNameAvailabilityRequest, options *ClientCheckNameAvailabilityOptions) (ClientCheckNameAvailabilityResponse, error) { req, err := client.checkNameAvailabilityCreateRequest(ctx, request, options) if err != nil { return ClientCheckNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientCheckNameAvailabilityResponse{}, err } @@ -82,7 +72,7 @@ func (client *Client) checkNameAvailabilityCreateRequest(ctx context.Context, re 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/deviceupdate/armdeviceupdate/client_example_test.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/client_example_test.go index dda62ebc9356..5c7063e31675 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/client_example_test.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/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 armdeviceupdate_test @@ -17,46 +18,56 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceupdate/armdeviceupdate" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/CheckNameAvailability_AlreadyExists.json -func ExampleClient_CheckNameAvailability_checkNameAvailability_AlreadyExists() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/CheckNameAvailability_AlreadyExists.json +func ExampleClient_CheckNameAvailability_checkNameAvailabilityAlreadyExists() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckNameAvailability(ctx, armdeviceupdate.CheckNameAvailabilityRequest{ + res, err := clientFactory.NewClient().CheckNameAvailability(ctx, armdeviceupdate.CheckNameAvailabilityRequest{ Name: to.Ptr("contoso"), Type: to.Ptr("Microsoft.DeviceUpdate/accounts"), }, 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.CheckNameAvailabilityResponse = armdeviceupdate.CheckNameAvailabilityResponse{ + // Message: to.Ptr("Resource name already exists"), + // NameAvailable: to.Ptr(false), + // Reason: to.Ptr(armdeviceupdate.CheckNameAvailabilityReasonAlreadyExists), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/CheckNameAvailability_Available.json -func ExampleClient_CheckNameAvailability_checkNameAvailability_Available() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/CheckNameAvailability_Available.json +func ExampleClient_CheckNameAvailability_checkNameAvailabilityAvailable() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckNameAvailability(ctx, armdeviceupdate.CheckNameAvailabilityRequest{ + res, err := clientFactory.NewClient().CheckNameAvailability(ctx, armdeviceupdate.CheckNameAvailabilityRequest{ Name: to.Ptr("contoso"), Type: to.Ptr("Microsoft.DeviceUpdate/accounts"), }, 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.CheckNameAvailabilityResponse = armdeviceupdate.CheckNameAvailabilityResponse{ + // NameAvailable: to.Ptr(true), + // } } diff --git a/sdk/resourcemanager/deviceupdate/armdeviceupdate/client_factory.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/client_factory.go new file mode 100644 index 000000000000..598f16f71193 --- /dev/null +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/client_factory.go @@ -0,0 +1,74 @@ +//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 armdeviceupdate + +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. +// - 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.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAccountsClient() *AccountsClient { + subClient, _ := NewAccountsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewInstancesClient() *InstancesClient { + subClient, _ := NewInstancesClient(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) NewPrivateEndpointConnectionProxiesClient() *PrivateEndpointConnectionProxiesClient { + subClient, _ := NewPrivateEndpointConnectionProxiesClient(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/deviceupdate/armdeviceupdate/constants.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/constants.go index 67a8d84b3ea0..4ddd8c35658b 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/constants.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/constants.go @@ -11,7 +11,7 @@ package armdeviceupdate const ( moduleName = "armdeviceupdate" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/deviceupdate/armdeviceupdate/go.mod b/sdk/resourcemanager/deviceupdate/armdeviceupdate/go.mod index 13f1be8749b0..4accc4c1da29 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/go.mod +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceupdate/armdev 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/deviceupdate/armdeviceupdate/go.sum b/sdk/resourcemanager/deviceupdate/armdeviceupdate/go.sum index 8828b17b1853..8ba445a8c4da 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/go.sum +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/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/deviceupdate/armdeviceupdate/instances_client.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/instances_client.go index a5c435be6512..bdd5ef0e4f10 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/instances_client.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/instances_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 ( // InstancesClient contains the methods for the Instances group. // Don't use this type directly, use NewInstancesClient() instead. type InstancesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewInstancesClient creates a new instance of InstancesClient with the specified values. -// subscriptionID - The Azure subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewInstancesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*InstancesClient, 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+".InstancesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &InstancesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Creates or updates instance. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// instanceName - Instance name. -// instance - Instance details. -// options - InstancesClientBeginCreateOptions contains the optional parameters for the InstancesClient.BeginCreate method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - instanceName - Instance name. +// - instance - Instance details. +// - options - InstancesClientBeginCreateOptions contains the optional parameters for the InstancesClient.BeginCreate method. func (client *InstancesClient) BeginCreate(ctx context.Context, resourceGroupName string, accountName string, instanceName string, instance Instance, options *InstancesClientBeginCreateOptions) (*runtime.Poller[InstancesClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, accountName, instanceName, instance, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[InstancesClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[InstancesClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[InstancesClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[InstancesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Creates or updates instance. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 func (client *InstancesClient) create(ctx context.Context, resourceGroupName string, accountName string, instanceName string, instance Instance, options *InstancesClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, instanceName, instance, 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 *InstancesClient) createCreateRequest(ctx context.Context, resource return nil, errors.New("parameter instanceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{instanceName}", url.PathEscape(instanceName)) - 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,34 +118,36 @@ func (client *InstancesClient) createCreateRequest(ctx context.Context, resource // BeginDelete - Deletes instance. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// instanceName - Instance name. -// options - InstancesClientBeginDeleteOptions contains the optional parameters for the InstancesClient.BeginDelete method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - instanceName - Instance name. +// - options - InstancesClientBeginDeleteOptions contains the optional parameters for the InstancesClient.BeginDelete method. func (client *InstancesClient) BeginDelete(ctx context.Context, resourceGroupName string, accountName string, instanceName string, options *InstancesClientBeginDeleteOptions) (*runtime.Poller[InstancesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, accountName, instanceName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[InstancesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[InstancesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[InstancesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[InstancesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes instance. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 func (client *InstancesClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, instanceName string, options *InstancesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, instanceName, 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 } @@ -183,7 +176,7 @@ func (client *InstancesClient) deleteCreateRequest(ctx context.Context, resource return nil, errors.New("parameter instanceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{instanceName}", url.PathEscape(instanceName)) - 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 } @@ -196,17 +189,18 @@ func (client *InstancesClient) deleteCreateRequest(ctx context.Context, resource // Get - Returns instance details for the given instance and account name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// instanceName - Instance name. -// options - InstancesClientGetOptions contains the optional parameters for the InstancesClient.Get method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - instanceName - Instance name. +// - options - InstancesClientGetOptions contains the optional parameters for the InstancesClient.Get method. func (client *InstancesClient) Get(ctx context.Context, resourceGroupName string, accountName string, instanceName string, options *InstancesClientGetOptions) (InstancesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, instanceName, options) if err != nil { return InstancesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return InstancesClientGetResponse{}, err } @@ -235,7 +229,7 @@ func (client *InstancesClient) getCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter instanceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{instanceName}", url.PathEscape(instanceName)) - 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 } @@ -256,17 +250,18 @@ func (client *InstancesClient) getHandleResponse(resp *http.Response) (Instances } // Head - Checks whether instance exists. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// instanceName - Instance name. -// options - InstancesClientHeadOptions contains the optional parameters for the InstancesClient.Head method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - instanceName - Instance name. +// - options - InstancesClientHeadOptions contains the optional parameters for the InstancesClient.Head method. func (client *InstancesClient) Head(ctx context.Context, resourceGroupName string, accountName string, instanceName string, options *InstancesClientHeadOptions) (InstancesClientHeadResponse, error) { req, err := client.headCreateRequest(ctx, resourceGroupName, accountName, instanceName, options) if err != nil { return InstancesClientHeadResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return InstancesClientHeadResponse{}, err } @@ -295,7 +290,7 @@ func (client *InstancesClient) headCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter instanceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{instanceName}", url.PathEscape(instanceName)) - req, err := runtime.NewRequest(ctx, http.MethodHead, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -307,11 +302,12 @@ func (client *InstancesClient) headCreateRequest(ctx context.Context, resourceGr } // NewListByAccountPager - Returns instances for the given account name. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// options - InstancesClientListByAccountOptions contains the optional parameters for the InstancesClient.ListByAccount method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - options - InstancesClientListByAccountOptions contains the optional parameters for the InstancesClient.NewListByAccountPager +// method. func (client *InstancesClient) NewListByAccountPager(resourceGroupName string, accountName string, options *InstancesClientListByAccountOptions) *runtime.Pager[InstancesClientListByAccountResponse] { return runtime.NewPager(runtime.PagingHandler[InstancesClientListByAccountResponse]{ More: func(page InstancesClientListByAccountResponse) bool { @@ -328,7 +324,7 @@ func (client *InstancesClient) NewListByAccountPager(resourceGroupName string, a if err != nil { return InstancesClientListByAccountResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return InstancesClientListByAccountResponse{}, err } @@ -355,7 +351,7 @@ func (client *InstancesClient) listByAccountCreateRequest(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 } @@ -377,18 +373,19 @@ func (client *InstancesClient) listByAccountHandleResponse(resp *http.Response) // Update - Updates instance's tags. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// instanceName - Instance name. -// tagUpdatePayload - Updated tags. -// options - InstancesClientUpdateOptions contains the optional parameters for the InstancesClient.Update method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - instanceName - Instance name. +// - tagUpdatePayload - Updated tags. +// - options - InstancesClientUpdateOptions contains the optional parameters for the InstancesClient.Update method. func (client *InstancesClient) Update(ctx context.Context, resourceGroupName string, accountName string, instanceName string, tagUpdatePayload TagUpdate, options *InstancesClientUpdateOptions) (InstancesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, instanceName, tagUpdatePayload, options) if err != nil { return InstancesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return InstancesClientUpdateResponse{}, err } @@ -417,7 +414,7 @@ func (client *InstancesClient) updateCreateRequest(ctx context.Context, resource return nil, errors.New("parameter instanceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{instanceName}", url.PathEscape(instanceName)) - 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/deviceupdate/armdeviceupdate/instances_client_example_test.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/instances_client_example_test.go index d5d63005d6f6..019398247730 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/instances_client_example_test.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/instances_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 armdeviceupdate_test @@ -17,78 +18,140 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceupdate/armdeviceupdate" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Instances/Instances_ListByAccount.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Instances/Instances_ListByAccount.json func ExampleInstancesClient_NewListByAccountPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewInstancesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByAccountPager("test-rg", "contoso", nil) + pager := clientFactory.NewInstancesClient().NewListByAccountPager("test-rg", "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.InstanceList = armdeviceupdate.InstanceList{ + // Value: []*armdeviceupdate.Instance{ + // { + // Name: to.Ptr("blue"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts/instances"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso/instances/blue"), + // Location: to.Ptr("westus2"), + // Properties: &armdeviceupdate.InstanceProperties{ + // AccountName: to.Ptr("contoso"), + // DiagnosticStorageProperties: &armdeviceupdate.DiagnosticStorageProperties{ + // AuthenticationType: to.Ptr(armdeviceupdate.AuthenticationTypeKeyBased), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/adu-resource-group/providers/Microsoft.Storage/storageAccounts/testAccount"), + // }, + // EnableDiagnostics: to.Ptr(false), + // IotHubs: []*armdeviceupdate.IotHubSettings{ + // { + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Devices/IotHubs/blue-contoso-hub"), + // }}, + // ProvisioningState: to.Ptr(armdeviceupdate.ProvisioningStateSucceeded), + // }, + // }, + // { + // Name: to.Ptr("red"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts/instances"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso/instances/red"), + // Location: to.Ptr("westus2"), + // Properties: &armdeviceupdate.InstanceProperties{ + // AccountName: to.Ptr("contoso"), + // DiagnosticStorageProperties: &armdeviceupdate.DiagnosticStorageProperties{ + // AuthenticationType: to.Ptr(armdeviceupdate.AuthenticationTypeKeyBased), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/adu-resource-group/providers/Microsoft.Storage/storageAccounts/testAccount"), + // }, + // EnableDiagnostics: to.Ptr(false), + // IotHubs: []*armdeviceupdate.IotHubSettings{ + // { + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Devices/IotHubs/red-contoso-hub"), + // }}, + // ProvisioningState: to.Ptr(armdeviceupdate.ProvisioningStateSucceeded), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Instances/Instances_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Instances/Instances_Get.json func ExampleInstancesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewInstancesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "test-rg", "contoso", "blue", nil) + res, err := clientFactory.NewInstancesClient().Get(ctx, "test-rg", "contoso", "blue", 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.Instance = armdeviceupdate.Instance{ + // Name: to.Ptr("blue"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts/instances"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso/instances/blue"), + // Location: to.Ptr("westus2"), + // Properties: &armdeviceupdate.InstanceProperties{ + // AccountName: to.Ptr("contoso"), + // DiagnosticStorageProperties: &armdeviceupdate.DiagnosticStorageProperties{ + // AuthenticationType: to.Ptr(armdeviceupdate.AuthenticationTypeKeyBased), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/adu-resource-group/providers/Microsoft.Storage/storageAccounts/testAccount"), + // }, + // EnableDiagnostics: to.Ptr(false), + // IotHubs: []*armdeviceupdate.IotHubSettings{ + // { + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Devices/IotHubs/blue-contoso-hub"), + // }}, + // ProvisioningState: to.Ptr(armdeviceupdate.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Instances/Instances_Head.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Instances/Instances_Head.json func ExampleInstancesClient_Head() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewInstancesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Head(ctx, "test-rg", "contoso", "blue", nil) + _, err = clientFactory.NewInstancesClient().Head(ctx, "test-rg", "contoso", "blue", 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/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Instances/Instances_Create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Instances/Instances_Create.json func ExampleInstancesClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewInstancesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "test-rg", "contoso", "blue", armdeviceupdate.Instance{ + poller, err := clientFactory.NewInstancesClient().BeginCreate(ctx, "test-rg", "contoso", "blue", armdeviceupdate.Instance{ Location: to.Ptr("westus2"), Properties: &armdeviceupdate.InstanceProperties{ DiagnosticStorageProperties: &armdeviceupdate.DiagnosticStorageProperties{ @@ -112,18 +175,18 @@ func ExampleInstancesClient_BeginCreate() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Instances/Instances_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Instances/Instances_Delete.json func ExampleInstancesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewInstancesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "test-rg", "contoso", "blue", nil) + poller, err := clientFactory.NewInstancesClient().BeginDelete(ctx, "test-rg", "contoso", "blue", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -133,18 +196,18 @@ func ExampleInstancesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Instances/Instances_Update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Instances/Instances_Update.json func ExampleInstancesClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewInstancesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "test-rg", "contoso", "blue", armdeviceupdate.TagUpdate{ + res, err := clientFactory.NewInstancesClient().Update(ctx, "test-rg", "contoso", "blue", armdeviceupdate.TagUpdate{ Tags: map[string]*string{ "tagKey": to.Ptr("tagValue"), }, @@ -152,6 +215,28 @@ func ExampleInstancesClient_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.Instance = armdeviceupdate.Instance{ + // Name: to.Ptr("blue"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts/instances"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso/instances/blue"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "tagKey": to.Ptr("tagValue"), + // }, + // Properties: &armdeviceupdate.InstanceProperties{ + // AccountName: to.Ptr("contoso"), + // DiagnosticStorageProperties: &armdeviceupdate.DiagnosticStorageProperties{ + // AuthenticationType: to.Ptr(armdeviceupdate.AuthenticationTypeKeyBased), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/adu-resource-group/providers/Microsoft.Storage/storageAccounts/testAccount"), + // }, + // EnableDiagnostics: to.Ptr(false), + // IotHubs: []*armdeviceupdate.IotHubSettings{ + // { + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Devices/IotHubs/blue-contoso-hub"), + // }}, + // }, + // } } diff --git a/sdk/resourcemanager/deviceupdate/armdeviceupdate/models.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/models.go index 918430ca0e68..dcfc0f19c0c1 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/models.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/models.go @@ -108,12 +108,14 @@ type AccountsClientHeadOptions struct { // placeholder for future optional parameters } -// AccountsClientListByResourceGroupOptions contains the optional parameters for the AccountsClient.ListByResourceGroup method. +// AccountsClientListByResourceGroupOptions contains the optional parameters for the AccountsClient.NewListByResourceGroupPager +// method. type AccountsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// AccountsClientListBySubscriptionOptions contains the optional parameters for the AccountsClient.ListBySubscription method. +// AccountsClientListBySubscriptionOptions contains the optional parameters for the AccountsClient.NewListBySubscriptionPager +// method. type AccountsClientListBySubscriptionOptions struct { // placeholder for future optional parameters } @@ -177,7 +179,7 @@ type DiagnosticStorageProperties 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"` @@ -335,7 +337,7 @@ type InstancesClientHeadOptions struct { // placeholder for future optional parameters } -// InstancesClientListByAccountOptions contains the optional parameters for the InstancesClient.ListByAccount method. +// InstancesClientListByAccountOptions contains the optional parameters for the InstancesClient.NewListByAccountPager method. type InstancesClientListByAccountOptions struct { // placeholder for future optional parameters } @@ -427,7 +429,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 } @@ -497,7 +499,7 @@ type PrivateEndpointConnectionProxiesClientGetOptions struct { // placeholder for future optional parameters } -// PrivateEndpointConnectionProxiesClientListByAccountOptions contains the optional parameters for the PrivateEndpointConnectionProxiesClient.ListByAccount +// PrivateEndpointConnectionProxiesClientListByAccountOptions contains the optional parameters for the PrivateEndpointConnectionProxiesClient.NewListByAccountPager // method. type PrivateEndpointConnectionProxiesClientListByAccountOptions struct { // placeholder for future optional parameters @@ -590,7 +592,7 @@ type PrivateEndpointConnectionsClientGetOptions struct { // placeholder for future optional parameters } -// PrivateEndpointConnectionsClientListByAccountOptions contains the optional parameters for the PrivateEndpointConnectionsClient.ListByAccount +// PrivateEndpointConnectionsClientListByAccountOptions contains the optional parameters for the PrivateEndpointConnectionsClient.NewListByAccountPager // method. type PrivateEndpointConnectionsClientListByAccountOptions struct { // placeholder for future optional parameters @@ -640,7 +642,7 @@ type PrivateLinkResourcesClientGetOptions struct { // placeholder for future optional parameters } -// PrivateLinkResourcesClientListByAccountOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByAccount +// PrivateLinkResourcesClientListByAccountOptions contains the optional parameters for the PrivateLinkResourcesClient.NewListByAccountPager // method. type PrivateLinkResourcesClientListByAccountOptions struct { // placeholder for future optional parameters diff --git a/sdk/resourcemanager/deviceupdate/armdeviceupdate/models_serde.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/models_serde.go index 2ed208b167ac..04c89b6f99bb 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/models_serde.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type Account. func (a Account) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "identity", a.Identity) populate(objectMap, "location", a.Location) @@ -73,7 +73,7 @@ func (a *Account) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AccountList. func (a AccountList) 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 *AccountList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AccountProperties. func (a AccountProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "hostName", a.HostName) populate(objectMap, "locations", a.Locations) populate(objectMap, "privateEndpointConnections", a.PrivateEndpointConnections) @@ -151,7 +151,7 @@ func (a *AccountProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AccountUpdate. func (a AccountUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "identity", a.Identity) populate(objectMap, "location", a.Location) populate(objectMap, "tags", a.Tags) @@ -186,7 +186,7 @@ func (a *AccountUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityRequest. func (c CheckNameAvailabilityRequest) 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) @@ -217,7 +217,7 @@ func (c *CheckNameAvailabilityRequest) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityResponse. func (c CheckNameAvailabilityResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "message", c.Message) populate(objectMap, "nameAvailable", c.NameAvailable) populate(objectMap, "reason", c.Reason) @@ -252,7 +252,7 @@ func (c *CheckNameAvailabilityResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectionDetails. func (c ConnectionDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "groupId", c.GroupID) populate(objectMap, "id", c.ID) populate(objectMap, "linkIdentifier", c.LinkIdentifier) @@ -295,7 +295,7 @@ func (c *ConnectionDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DiagnosticStorageProperties. func (d DiagnosticStorageProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "authenticationType", d.AuthenticationType) populate(objectMap, "connectionString", d.ConnectionString) populate(objectMap, "resourceId", d.ResourceID) @@ -330,7 +330,7 @@ func (d *DiagnosticStorageProperties) 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) @@ -361,7 +361,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) @@ -404,7 +404,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) } @@ -431,7 +431,7 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GroupConnectivityInformation. func (g GroupConnectivityInformation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "customerVisibleFqdns", g.CustomerVisibleFqdns) populate(objectMap, "groupId", g.GroupID) populate(objectMap, "internalFqdn", g.InternalFqdn) @@ -478,7 +478,7 @@ func (g *GroupConnectivityInformation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GroupInformation. func (g GroupInformation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", g.ID) populate(objectMap, "name", g.Name) populate(objectMap, "properties", g.Properties) @@ -521,7 +521,7 @@ func (g *GroupInformation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GroupInformationProperties. func (g GroupInformationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "groupId", g.GroupID) populate(objectMap, "provisioningState", g.ProvisioningState) populate(objectMap, "requiredMembers", g.RequiredMembers) @@ -560,7 +560,7 @@ func (g *GroupInformationProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Instance. func (i Instance) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", i.ID) populate(objectMap, "location", i.Location) populate(objectMap, "name", i.Name) @@ -611,7 +611,7 @@ func (i *Instance) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InstanceList. func (i InstanceList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", i.NextLink) populate(objectMap, "value", i.Value) return json.Marshal(objectMap) @@ -642,7 +642,7 @@ func (i *InstanceList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InstanceProperties. func (i InstanceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "accountName", i.AccountName) populate(objectMap, "diagnosticStorageProperties", i.DiagnosticStorageProperties) populate(objectMap, "enableDiagnostics", i.EnableDiagnostics) @@ -685,7 +685,7 @@ func (i *InstanceProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IotHubSettings. func (i IotHubSettings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "resourceId", i.ResourceID) return json.Marshal(objectMap) } @@ -712,7 +712,7 @@ func (i *IotHubSettings) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Location. func (l Location) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", l.Name) populate(objectMap, "role", l.Role) return json.Marshal(objectMap) @@ -743,7 +743,7 @@ func (l *Location) 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) @@ -782,7 +782,7 @@ func (m *ManagedServiceIdentity) 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) @@ -825,7 +825,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) @@ -864,7 +864,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) @@ -895,7 +895,7 @@ func (o *OperationListResult) 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) } @@ -922,7 +922,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) @@ -965,7 +965,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) } @@ -992,7 +992,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, "groupIds", p.GroupIDs) populate(objectMap, "privateEndpoint", p.PrivateEndpoint) populate(objectMap, "privateLinkServiceConnectionState", p.PrivateLinkServiceConnectionState) @@ -1031,7 +1031,7 @@ func (p *PrivateEndpointConnectionProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionProxy. func (p PrivateEndpointConnectionProxy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "eTag", p.ETag) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) @@ -1086,7 +1086,7 @@ func (p *PrivateEndpointConnectionProxy) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionProxyListResult. func (p PrivateEndpointConnectionProxyListResult) 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) @@ -1117,7 +1117,7 @@ func (p *PrivateEndpointConnectionProxyListResult) UnmarshalJSON(data []byte) er // MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionProxyProperties. func (p PrivateEndpointConnectionProxyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "provisioningState", p.ProvisioningState) return json.Marshal(objectMap) } @@ -1144,7 +1144,7 @@ func (p *PrivateEndpointConnectionProxyProperties) UnmarshalJSON(data []byte) er // MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionProxyPropertiesAutoGenerated. func (p PrivateEndpointConnectionProxyPropertiesAutoGenerated) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "eTag", p.ETag) populate(objectMap, "remotePrivateEndpoint", p.RemotePrivateEndpoint) populate(objectMap, "status", p.Status) @@ -1179,7 +1179,7 @@ func (p *PrivateEndpointConnectionProxyPropertiesAutoGenerated) UnmarshalJSON(da // MarshalJSON implements the json.Marshaller interface for type PrivateEndpointUpdate. func (p PrivateEndpointUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "immutableResourceId", p.ImmutableResourceID) populate(objectMap, "immutableSubscriptionId", p.ImmutableSubscriptionID) @@ -1222,7 +1222,7 @@ func (p *PrivateEndpointUpdate) 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, "nextLink", p.NextLink) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) @@ -1253,7 +1253,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) @@ -1288,7 +1288,7 @@ func (p *PrivateLinkResourceProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateLinkServiceConnection. func (p PrivateLinkServiceConnection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "groupIds", p.GroupIDs) populate(objectMap, "name", p.Name) populate(objectMap, "requestMessage", p.RequestMessage) @@ -1323,7 +1323,7 @@ func (p *PrivateLinkServiceConnection) 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) @@ -1358,7 +1358,7 @@ func (p *PrivateLinkServiceConnectionState) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateLinkServiceProxy. func (p PrivateLinkServiceProxy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "groupConnectivityInformation", p.GroupConnectivityInformation) populate(objectMap, "id", p.ID) populate(objectMap, "remotePrivateEndpointConnection", p.RemotePrivateEndpointConnection) @@ -1397,7 +1397,7 @@ func (p *PrivateLinkServiceProxy) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateLinkServiceProxyRemotePrivateEndpointConnection. func (p PrivateLinkServiceProxyRemotePrivateEndpointConnection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) return json.Marshal(objectMap) } @@ -1424,7 +1424,7 @@ func (p *PrivateLinkServiceProxyRemotePrivateEndpointConnection) UnmarshalJSON(d // 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) @@ -1463,7 +1463,7 @@ func (p *ProxyResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RemotePrivateEndpoint. func (r RemotePrivateEndpoint) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "connectionDetails", r.ConnectionDetails) populate(objectMap, "id", r.ID) populate(objectMap, "immutableResourceId", r.ImmutableResourceID) @@ -1522,7 +1522,7 @@ func (r *RemotePrivateEndpoint) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RemotePrivateEndpointConnection. func (r RemotePrivateEndpointConnection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) return json.Marshal(objectMap) } @@ -1549,7 +1549,7 @@ func (r *RemotePrivateEndpointConnection) 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) @@ -1588,7 +1588,7 @@ func (r *Resource) 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) @@ -1635,7 +1635,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TagUpdate. func (t TagUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "tags", t.Tags) return json.Marshal(objectMap) } @@ -1662,7 +1662,7 @@ func (t *TagUpdate) 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) @@ -1709,7 +1709,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) @@ -1738,7 +1738,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) { @@ -1748,7 +1748,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/deviceupdate/armdeviceupdate/operations_client.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/operations_client.go index 5b3b38660885..60686761aa24 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/operations_client.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/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,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 - Returns list of operations for Microsoft.DeviceUpdate resource provider. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-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 { @@ -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.DeviceUpdate/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/deviceupdate/armdeviceupdate/operations_client_example_test.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/operations_client_example_test.go index d4bf03e5ae11..1fa49807dc13 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/operations_client_example_test.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/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 armdeviceupdate_test @@ -16,26 +17,50 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceupdate/armdeviceupdate" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/Operations_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-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 := armdeviceupdate.NewOperationsClient(cred, nil) + clientFactory, err := armdeviceupdate.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 = armdeviceupdate.OperationListResult{ + // Value: []*armdeviceupdate.Operation{ + // { + // Name: to.Ptr("Microsoft.DeviceUpdate/accounts/read"), + // Display: &armdeviceupdate.OperationDisplay{ + // Description: to.Ptr("Returns the list of Device Update Accounts"), + // Operation: to.Ptr("Get/List Accounts"), + // Provider: to.Ptr("Microsoft.DeviceUpdate"), + // Resource: to.Ptr("Device Update Account"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.DeviceUpdate/accounts/write"), + // Display: &armdeviceupdate.OperationDisplay{ + // Description: to.Ptr("Creates or updates a Device Update Account"), + // Operation: to.Ptr("Create/Update Account"), + // Provider: to.Ptr("Microsoft.DeviceUpdate"), + // Resource: to.Ptr("Device Update Account"), + // }, + // IsDataAction: to.Ptr(false), + // }}, + // } } } diff --git a/sdk/resourcemanager/deviceupdate/armdeviceupdate/privateendpointconnectionproxies_client.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/privateendpointconnectionproxies_client.go index ce2a1ba665d9..3413f6d16cf5 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/privateendpointconnectionproxies_client.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/privateendpointconnectionproxies_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 ( // PrivateEndpointConnectionProxiesClient contains the methods for the PrivateEndpointConnectionProxies group. // Don't use this type directly, use NewPrivateEndpointConnectionProxiesClient() instead. type PrivateEndpointConnectionProxiesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPrivateEndpointConnectionProxiesClient creates a new instance of PrivateEndpointConnectionProxiesClient with the specified values. -// subscriptionID - The Azure subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPrivateEndpointConnectionProxiesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionProxiesClient, 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+".PrivateEndpointConnectionProxiesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PrivateEndpointConnectionProxiesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,37 +47,39 @@ func NewPrivateEndpointConnectionProxiesClient(subscriptionID string, credential // BeginCreateOrUpdate - (INTERNAL - DO NOT USE) Creates or updates the specified private endpoint connection proxy resource // associated with the device update account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// privateEndpointConnectionProxyID - The ID of the private endpoint connection proxy object. -// privateEndpointConnectionProxy - The parameters for creating a private endpoint connection proxy. -// options - PrivateEndpointConnectionProxiesClientBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnectionProxiesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - privateEndpointConnectionProxyID - The ID of the private endpoint connection proxy object. +// - privateEndpointConnectionProxy - The parameters for creating a private endpoint connection proxy. +// - options - PrivateEndpointConnectionProxiesClientBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnectionProxiesClient.BeginCreateOrUpdate +// method. func (client *PrivateEndpointConnectionProxiesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionProxyID string, privateEndpointConnectionProxy PrivateEndpointConnectionProxy, options *PrivateEndpointConnectionProxiesClientBeginCreateOrUpdateOptions) (*runtime.Poller[PrivateEndpointConnectionProxiesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, accountName, privateEndpointConnectionProxyID, privateEndpointConnectionProxy, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PrivateEndpointConnectionProxiesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionProxiesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionProxiesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionProxiesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - (INTERNAL - DO NOT USE) Creates or updates the specified private endpoint connection proxy resource associated // with the device update account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 func (client *PrivateEndpointConnectionProxiesClient) createOrUpdate(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionProxyID string, privateEndpointConnectionProxy PrivateEndpointConnectionProxy, options *PrivateEndpointConnectionProxiesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, privateEndpointConnectionProxyID, privateEndpointConnectionProxy, 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 *PrivateEndpointConnectionProxiesClient) createOrUpdateCreateReques return nil, errors.New("parameter privateEndpointConnectionProxyID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionProxyId}", url.PathEscape(privateEndpointConnectionProxyID)) - 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,36 +122,38 @@ func (client *PrivateEndpointConnectionProxiesClient) createOrUpdateCreateReques // BeginDelete - (INTERNAL - DO NOT USE) Deletes the specified private endpoint connection proxy associated with the device // update account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// privateEndpointConnectionProxyID - The ID of the private endpoint connection proxy object. -// options - PrivateEndpointConnectionProxiesClientBeginDeleteOptions contains the optional parameters for the PrivateEndpointConnectionProxiesClient.BeginDelete -// method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - privateEndpointConnectionProxyID - The ID of the private endpoint connection proxy object. +// - options - PrivateEndpointConnectionProxiesClientBeginDeleteOptions contains the optional parameters for the PrivateEndpointConnectionProxiesClient.BeginDelete +// method. func (client *PrivateEndpointConnectionProxiesClient) BeginDelete(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionProxyID string, options *PrivateEndpointConnectionProxiesClientBeginDeleteOptions) (*runtime.Poller[PrivateEndpointConnectionProxiesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, accountName, privateEndpointConnectionProxyID, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PrivateEndpointConnectionProxiesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionProxiesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionProxiesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionProxiesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - (INTERNAL - DO NOT USE) Deletes the specified private endpoint connection proxy associated with the device update // account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 func (client *PrivateEndpointConnectionProxiesClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionProxyID string, options *PrivateEndpointConnectionProxiesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, privateEndpointConnectionProxyID, 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 } @@ -189,7 +182,7 @@ func (client *PrivateEndpointConnectionProxiesClient) deleteCreateRequest(ctx co return nil, errors.New("parameter privateEndpointConnectionProxyID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionProxyId}", url.PathEscape(privateEndpointConnectionProxyID)) - 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 } @@ -202,18 +195,19 @@ func (client *PrivateEndpointConnectionProxiesClient) deleteCreateRequest(ctx co // Get - (INTERNAL - DO NOT USE) Get the specified private endpoint connection proxy associated with the device update account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// privateEndpointConnectionProxyID - The ID of the private endpoint connection proxy object. -// options - PrivateEndpointConnectionProxiesClientGetOptions contains the optional parameters for the PrivateEndpointConnectionProxiesClient.Get -// method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - privateEndpointConnectionProxyID - The ID of the private endpoint connection proxy object. +// - options - PrivateEndpointConnectionProxiesClientGetOptions contains the optional parameters for the PrivateEndpointConnectionProxiesClient.Get +// method. func (client *PrivateEndpointConnectionProxiesClient) Get(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionProxyID string, options *PrivateEndpointConnectionProxiesClientGetOptions) (PrivateEndpointConnectionProxiesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, privateEndpointConnectionProxyID, options) if err != nil { return PrivateEndpointConnectionProxiesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionProxiesClientGetResponse{}, err } @@ -242,7 +236,7 @@ func (client *PrivateEndpointConnectionProxiesClient) getCreateRequest(ctx conte return nil, errors.New("parameter privateEndpointConnectionProxyID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionProxyId}", url.PathEscape(privateEndpointConnectionProxyID)) - 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 } @@ -263,12 +257,12 @@ func (client *PrivateEndpointConnectionProxiesClient) getHandleResponse(resp *ht } // NewListByAccountPager - (INTERNAL - DO NOT USE) List all private endpoint connection proxies in a device update account. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// options - PrivateEndpointConnectionProxiesClientListByAccountOptions contains the optional parameters for the PrivateEndpointConnectionProxiesClient.ListByAccount -// method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - options - PrivateEndpointConnectionProxiesClientListByAccountOptions contains the optional parameters for the PrivateEndpointConnectionProxiesClient.NewListByAccountPager +// method. func (client *PrivateEndpointConnectionProxiesClient) NewListByAccountPager(resourceGroupName string, accountName string, options *PrivateEndpointConnectionProxiesClientListByAccountOptions) *runtime.Pager[PrivateEndpointConnectionProxiesClientListByAccountResponse] { return runtime.NewPager(runtime.PagingHandler[PrivateEndpointConnectionProxiesClientListByAccountResponse]{ More: func(page PrivateEndpointConnectionProxiesClientListByAccountResponse) bool { @@ -279,7 +273,7 @@ func (client *PrivateEndpointConnectionProxiesClient) NewListByAccountPager(reso if err != nil { return PrivateEndpointConnectionProxiesClientListByAccountResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionProxiesClientListByAccountResponse{}, err } @@ -306,7 +300,7 @@ func (client *PrivateEndpointConnectionProxiesClient) listByAccountCreateRequest 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 } @@ -329,19 +323,20 @@ func (client *PrivateEndpointConnectionProxiesClient) listByAccountHandleRespons // UpdatePrivateEndpointProperties - (INTERNAL - DO NOT USE) Updates a private endpoint inside the private endpoint connection // proxy object. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// privateEndpointConnectionProxyID - The ID of the private endpoint connection proxy object. -// privateEndpointUpdate - The parameters for updating a private endpoint connection proxy. -// options - PrivateEndpointConnectionProxiesClientUpdatePrivateEndpointPropertiesOptions contains the optional parameters -// for the PrivateEndpointConnectionProxiesClient.UpdatePrivateEndpointProperties method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - privateEndpointConnectionProxyID - The ID of the private endpoint connection proxy object. +// - privateEndpointUpdate - The parameters for updating a private endpoint connection proxy. +// - options - PrivateEndpointConnectionProxiesClientUpdatePrivateEndpointPropertiesOptions contains the optional parameters +// for the PrivateEndpointConnectionProxiesClient.UpdatePrivateEndpointProperties method. func (client *PrivateEndpointConnectionProxiesClient) UpdatePrivateEndpointProperties(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionProxyID string, privateEndpointUpdate PrivateEndpointUpdate, options *PrivateEndpointConnectionProxiesClientUpdatePrivateEndpointPropertiesOptions) (PrivateEndpointConnectionProxiesClientUpdatePrivateEndpointPropertiesResponse, error) { req, err := client.updatePrivateEndpointPropertiesCreateRequest(ctx, resourceGroupName, accountName, privateEndpointConnectionProxyID, privateEndpointUpdate, options) if err != nil { return PrivateEndpointConnectionProxiesClientUpdatePrivateEndpointPropertiesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionProxiesClientUpdatePrivateEndpointPropertiesResponse{}, err } @@ -370,7 +365,7 @@ func (client *PrivateEndpointConnectionProxiesClient) updatePrivateEndpointPrope return nil, errors.New("parameter privateEndpointConnectionProxyID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionProxyId}", url.PathEscape(privateEndpointConnectionProxyID)) - 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 } @@ -383,19 +378,20 @@ func (client *PrivateEndpointConnectionProxiesClient) updatePrivateEndpointPrope // Validate - (INTERNAL - DO NOT USE) Validates a private endpoint connection proxy object. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// privateEndpointConnectionProxyID - The ID of the private endpoint connection proxy object. -// privateEndpointConnectionProxy - The parameters for creating a private endpoint connection proxy. -// options - PrivateEndpointConnectionProxiesClientValidateOptions contains the optional parameters for the PrivateEndpointConnectionProxiesClient.Validate -// method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - privateEndpointConnectionProxyID - The ID of the private endpoint connection proxy object. +// - privateEndpointConnectionProxy - The parameters for creating a private endpoint connection proxy. +// - options - PrivateEndpointConnectionProxiesClientValidateOptions contains the optional parameters for the PrivateEndpointConnectionProxiesClient.Validate +// method. func (client *PrivateEndpointConnectionProxiesClient) Validate(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionProxyID string, privateEndpointConnectionProxy PrivateEndpointConnectionProxy, options *PrivateEndpointConnectionProxiesClientValidateOptions) (PrivateEndpointConnectionProxiesClientValidateResponse, error) { req, err := client.validateCreateRequest(ctx, resourceGroupName, accountName, privateEndpointConnectionProxyID, privateEndpointConnectionProxy, options) if err != nil { return PrivateEndpointConnectionProxiesClientValidateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionProxiesClientValidateResponse{}, err } @@ -424,7 +420,7 @@ func (client *PrivateEndpointConnectionProxiesClient) validateCreateRequest(ctx return nil, errors.New("parameter privateEndpointConnectionProxyID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionProxyId}", url.PathEscape(privateEndpointConnectionProxyID)) - 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/deviceupdate/armdeviceupdate/privateendpointconnectionproxies_client_example_test.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/privateendpointconnectionproxies_client_example_test.go index 8530ab80d142..34b20f9294b0 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/privateendpointconnectionproxies_client_example_test.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/privateendpointconnectionproxies_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 armdeviceupdate_test @@ -17,42 +18,73 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceupdate/armdeviceupdate" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_ListByAccount.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_ListByAccount.json func ExamplePrivateEndpointConnectionProxiesClient_NewListByAccountPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewPrivateEndpointConnectionProxiesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByAccountPager("test-rg", "contoso", nil) + pager := clientFactory.NewPrivateEndpointConnectionProxiesClient().NewListByAccountPager("test-rg", "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.PrivateEndpointConnectionProxyListResult = armdeviceupdate.PrivateEndpointConnectionProxyListResult{ + // Value: []*armdeviceupdate.PrivateEndpointConnectionProxy{ + // { + // RemotePrivateEndpoint: &armdeviceupdate.RemotePrivateEndpoint{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), + // ImmutableResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), + // ImmutableSubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Location: to.Ptr("westus2"), + // ManualPrivateLinkServiceConnections: []*armdeviceupdate.PrivateLinkServiceConnection{ + // { + // Name: to.Ptr("{plsConnectionName}"), + // GroupIDs: []*string{ + // to.Ptr("DeviceUpdate")}, + // RequestMessage: to.Ptr("Please approve my connection, thanks."), + // }}, + // PrivateLinkServiceProxies: []*armdeviceupdate.PrivateLinkServiceProxy{ + // { + // GroupConnectivityInformation: []*armdeviceupdate.GroupConnectivityInformation{ + // { + // GroupID: to.Ptr("DeviceUpdate"), + // MemberName: to.Ptr("adu"), + // }}, + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{privateEndpointConnectionProxyId}/privateLinkServiceProxies/{privateEndpointConnectionProxyId}"), + // }}, + // }, + // Name: to.Ptr("peexample01"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts/privateEndpointConnectionProxies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso/privateEndpointConnectionProxies/peexample01"), + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Validate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Validate.json func ExamplePrivateEndpointConnectionProxiesClient_Validate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewPrivateEndpointConnectionProxiesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Validate(ctx, "test-rg", "contoso", "peexample01", armdeviceupdate.PrivateEndpointConnectionProxy{ + _, err = clientFactory.NewPrivateEndpointConnectionProxiesClient().Validate(ctx, "test-rg", "contoso", "peexample01", armdeviceupdate.PrivateEndpointConnectionProxy{ RemotePrivateEndpoint: &armdeviceupdate.RemotePrivateEndpoint{ ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{privateEndpointConnectionProxyId}"), ImmutableResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), @@ -77,18 +109,18 @@ func ExamplePrivateEndpointConnectionProxiesClient_Validate() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_PrivateEndpointUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_PrivateEndpointUpdate.json func ExamplePrivateEndpointConnectionProxiesClient_UpdatePrivateEndpointProperties() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewPrivateEndpointConnectionProxiesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.UpdatePrivateEndpointProperties(ctx, "test-rg", "contoso", "peexample01", armdeviceupdate.PrivateEndpointUpdate{ + _, err = clientFactory.NewPrivateEndpointConnectionProxiesClient().UpdatePrivateEndpointProperties(ctx, "test-rg", "contoso", "peexample01", armdeviceupdate.PrivateEndpointUpdate{ ID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), ImmutableResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), ImmutableSubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), @@ -100,37 +132,65 @@ func ExamplePrivateEndpointConnectionProxiesClient_UpdatePrivateEndpointProperti } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Get.json func ExamplePrivateEndpointConnectionProxiesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewPrivateEndpointConnectionProxiesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "test-rg", "contoso", "peexample01", nil) + res, err := clientFactory.NewPrivateEndpointConnectionProxiesClient().Get(ctx, "test-rg", "contoso", "peexample01", 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.PrivateEndpointConnectionProxy = armdeviceupdate.PrivateEndpointConnectionProxy{ + // RemotePrivateEndpoint: &armdeviceupdate.RemotePrivateEndpoint{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), + // ImmutableResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), + // ImmutableSubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Location: to.Ptr("westus2"), + // ManualPrivateLinkServiceConnections: []*armdeviceupdate.PrivateLinkServiceConnection{ + // { + // Name: to.Ptr("{plsConnectionName}"), + // GroupIDs: []*string{ + // to.Ptr("DeviceUpdate")}, + // RequestMessage: to.Ptr("Please approve my connection, thanks."), + // }}, + // PrivateLinkServiceProxies: []*armdeviceupdate.PrivateLinkServiceProxy{ + // { + // GroupConnectivityInformation: []*armdeviceupdate.GroupConnectivityInformation{ + // { + // GroupID: to.Ptr("DeviceUpdate"), + // MemberName: to.Ptr("adu"), + // }}, + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{privateEndpointConnectionProxyId}/privateLinkServiceProxies/{privateEndpointConnectionProxyId}"), + // }}, + // }, + // Name: to.Ptr("peexample01"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts/privateEndpointConnectionProxies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso/privateEndpointConnectionProxies/peexample01"), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_CreateOrUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_CreateOrUpdate.json func ExamplePrivateEndpointConnectionProxiesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewPrivateEndpointConnectionProxiesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "test-rg", "contoso", "peexample01", armdeviceupdate.PrivateEndpointConnectionProxy{ + poller, err := clientFactory.NewPrivateEndpointConnectionProxiesClient().BeginCreateOrUpdate(ctx, "test-rg", "contoso", "peexample01", armdeviceupdate.PrivateEndpointConnectionProxy{ RemotePrivateEndpoint: &armdeviceupdate.RemotePrivateEndpoint{ ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), ImmutableResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), @@ -159,18 +219,18 @@ func ExamplePrivateEndpointConnectionProxiesClient_BeginCreateOrUpdate() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Delete.json func ExamplePrivateEndpointConnectionProxiesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewPrivateEndpointConnectionProxiesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "test-rg", "contoso", "peexample01", nil) + poller, err := clientFactory.NewPrivateEndpointConnectionProxiesClient().BeginDelete(ctx, "test-rg", "contoso", "peexample01", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/deviceupdate/armdeviceupdate/privateendpointconnections_client.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/privateendpointconnections_client.go index 5b0d10790bac..0d03bcd3d934 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/privateendpointconnections_client.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/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,67 +24,60 @@ 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 Azure subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. +// - 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 - Update the state of specified private endpoint connection associated with the device update account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource -// privateEndpointConnection - The parameters for creating a private endpoint connection. -// options - PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource +// - privateEndpointConnection - The parameters for creating a private endpoint connection. +// - options - PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginCreateOrUpdate +// method. func (client *PrivateEndpointConnectionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, options *PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[PrivateEndpointConnectionsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, accountName, privateEndpointConnectionName, privateEndpointConnection, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PrivateEndpointConnectionsClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Update the state of specified private endpoint connection associated with the device update account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 func (client *PrivateEndpointConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, options *PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, privateEndpointConnectionName, privateEndpointConnection, 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 *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx 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 } @@ -128,35 +119,37 @@ func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx // BeginDelete - Deletes the specified private endpoint connection associated with the device update account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource -// options - PrivateEndpointConnectionsClientBeginDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginDelete -// method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource +// - options - PrivateEndpointConnectionsClientBeginDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginDelete +// method. func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*runtime.Poller[PrivateEndpointConnectionsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, accountName, privateEndpointConnectionName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PrivateEndpointConnectionsClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the specified private endpoint connection associated with the device update account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, 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 } @@ -185,7 +178,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. 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 } @@ -198,18 +191,19 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // Get - Get the specified private endpoint connection associated with the device update account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource -// options - PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get -// method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource +// - options - PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get +// method. func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (PrivateEndpointConnectionsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, 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 } @@ -238,7 +232,7 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con 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 } @@ -259,12 +253,12 @@ func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Res } // NewListByAccountPager - List all private endpoint connections in a device update account. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// options - PrivateEndpointConnectionsClientListByAccountOptions contains the optional parameters for the PrivateEndpointConnectionsClient.ListByAccount -// method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - options - PrivateEndpointConnectionsClientListByAccountOptions contains the optional parameters for the PrivateEndpointConnectionsClient.NewListByAccountPager +// method. func (client *PrivateEndpointConnectionsClient) NewListByAccountPager(resourceGroupName string, accountName string, options *PrivateEndpointConnectionsClientListByAccountOptions) *runtime.Pager[PrivateEndpointConnectionsClientListByAccountResponse] { return runtime.NewPager(runtime.PagingHandler[PrivateEndpointConnectionsClientListByAccountResponse]{ More: func(page PrivateEndpointConnectionsClientListByAccountResponse) bool { @@ -275,7 +269,7 @@ func (client *PrivateEndpointConnectionsClient) NewListByAccountPager(resourceGr if err != nil { return PrivateEndpointConnectionsClientListByAccountResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientListByAccountResponse{}, err } @@ -302,7 +296,7 @@ func (client *PrivateEndpointConnectionsClient) listByAccountCreateRequest(ctx c 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/deviceupdate/armdeviceupdate/privateendpointconnections_client_example_test.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/privateendpointconnections_client_example_test.go index 95e0e173b19e..ac30d82de09e 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/privateendpointconnections_client_example_test.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/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 armdeviceupdate_test @@ -17,61 +18,102 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceupdate/armdeviceupdate" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_ListByAccount.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_ListByAccount.json func ExamplePrivateEndpointConnectionsClient_NewListByAccountPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewPrivateEndpointConnectionsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByAccountPager("test-rg", "contoso", nil) + pager := clientFactory.NewPrivateEndpointConnectionsClient().NewListByAccountPager("test-rg", "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.PrivateEndpointConnectionListResult = armdeviceupdate.PrivateEndpointConnectionListResult{ + // Value: []*armdeviceupdate.PrivateEndpointConnection{ + // { + // Name: to.Ptr("peexample01"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso/privateEndpointConnections/peexample01"), + // Properties: &armdeviceupdate.PrivateEndpointConnectionProperties{ + // GroupIDs: []*string{ + // to.Ptr("groupId")}, + // PrivateEndpoint: &armdeviceupdate.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/peexample01"), + // }, + // PrivateLinkServiceConnectionState: &armdeviceupdate.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armdeviceupdate.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armdeviceupdate.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_Get.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 := armdeviceupdate.NewPrivateEndpointConnectionsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "test-rg", "contoso", "peexample01", nil) + res, err := clientFactory.NewPrivateEndpointConnectionsClient().Get(ctx, "test-rg", "contoso", "peexample01", 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 = armdeviceupdate.PrivateEndpointConnection{ + // Name: to.Ptr("peexample01"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso/privateEndpointConnections/peexample01"), + // Properties: &armdeviceupdate.PrivateEndpointConnectionProperties{ + // GroupIDs: []*string{ + // to.Ptr("groupId")}, + // PrivateEndpoint: &armdeviceupdate.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/peexample01"), + // }, + // PrivateLinkServiceConnectionState: &armdeviceupdate.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armdeviceupdate.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armdeviceupdate.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_CreateOrUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_CreateOrUpdate.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 := armdeviceupdate.NewPrivateEndpointConnectionsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "test-rg", "contoso", "peexample01", armdeviceupdate.PrivateEndpointConnection{ + poller, err := clientFactory.NewPrivateEndpointConnectionsClient().BeginCreateOrUpdate(ctx, "test-rg", "contoso", "peexample01", armdeviceupdate.PrivateEndpointConnection{ Properties: &armdeviceupdate.PrivateEndpointConnectionProperties{ PrivateLinkServiceConnectionState: &armdeviceupdate.PrivateLinkServiceConnectionState{ Description: to.Ptr("Auto-Approved"), @@ -88,18 +130,18 @@ func ExamplePrivateEndpointConnectionsClient_BeginCreateOrUpdate() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_Delete.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 := armdeviceupdate.NewPrivateEndpointConnectionsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "test-rg", "contoso", "peexample01", nil) + poller, err := clientFactory.NewPrivateEndpointConnectionsClient().BeginDelete(ctx, "test-rg", "contoso", "peexample01", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/deviceupdate/armdeviceupdate/privatelinkresources_client.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/privatelinkresources_client.go index 98246dda7c6c..228f93974b64 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/privatelinkresources_client.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/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,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 Azure subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. +// - 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 the specified private link resource associated with the device update account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// groupID - The group ID of the private link resource. -// options - PrivateLinkResourcesClientGetOptions contains the optional parameters for the PrivateLinkResourcesClient.Get -// method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - groupID - The group ID 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, accountName string, groupID string, options *PrivateLinkResourcesClientGetOptions) (PrivateLinkResourcesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, groupID, 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 } @@ -97,7 +87,7 @@ func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter groupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) - 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,12 +108,12 @@ func (client *PrivateLinkResourcesClient) getHandleResponse(resp *http.Response) } // NewListByAccountPager - List all private link resources in a device update account. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01 -// resourceGroupName - The resource group name. -// accountName - Account name. -// options - PrivateLinkResourcesClientListByAccountOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByAccount -// method. +// - resourceGroupName - The resource group name. +// - accountName - Account name. +// - options - PrivateLinkResourcesClientListByAccountOptions contains the optional parameters for the PrivateLinkResourcesClient.NewListByAccountPager +// method. func (client *PrivateLinkResourcesClient) NewListByAccountPager(resourceGroupName string, accountName string, options *PrivateLinkResourcesClientListByAccountOptions) *runtime.Pager[PrivateLinkResourcesClientListByAccountResponse] { return runtime.NewPager(runtime.PagingHandler[PrivateLinkResourcesClientListByAccountResponse]{ More: func(page PrivateLinkResourcesClientListByAccountResponse) bool { @@ -134,7 +124,7 @@ func (client *PrivateLinkResourcesClient) NewListByAccountPager(resourceGroupNam if err != nil { return PrivateLinkResourcesClientListByAccountResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkResourcesClientListByAccountResponse{}, err } @@ -161,7 +151,7 @@ func (client *PrivateLinkResourcesClient) listByAccountCreateRequest(ctx 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/deviceupdate/armdeviceupdate/privatelinkresources_client_example_test.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/privatelinkresources_client_example_test.go index f16635276215..586e1119af20 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/privatelinkresources_client_example_test.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/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 armdeviceupdate_test @@ -16,45 +17,74 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceupdate/armdeviceupdate" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateLinkResources/PrivateLinkResources_ListByAccount.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateLinkResources/PrivateLinkResources_ListByAccount.json func ExamplePrivateLinkResourcesClient_NewListByAccountPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdeviceupdate.NewPrivateLinkResourcesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByAccountPager("test-rg", "contoso", nil) + pager := clientFactory.NewPrivateLinkResourcesClient().NewListByAccountPager("test-rg", "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.PrivateLinkResourceListResult = armdeviceupdate.PrivateLinkResourceListResult{ + // Value: []*armdeviceupdate.GroupInformation{ + // { + // Name: to.Ptr("adu"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts/privateLinkResources"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso/privateLinkResources/adu"), + // Properties: &armdeviceupdate.GroupInformationProperties{ + // GroupID: to.Ptr("adu"), + // RequiredMembers: []*string{ + // to.Ptr("adu")}, + // RequiredZoneNames: []*string{ + // to.Ptr("privatelink.adu.microsoft.com")}, + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateLinkResources/PrivateLinkResources_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/80065490402157d0df0dd37ab347c651b22eb576/specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2022-10-01/examples/PrivateLinkResources/PrivateLinkResources_Get.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 := armdeviceupdate.NewPrivateLinkResourcesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdeviceupdate.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "test-rg", "contoso", "adu", nil) + res, err := clientFactory.NewPrivateLinkResourcesClient().Get(ctx, "test-rg", "contoso", "adu", 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.GroupInformation = armdeviceupdate.GroupInformation{ + // Name: to.Ptr("adu"), + // Type: to.Ptr("Microsoft.DeviceUpdate/accounts/privateLinkResources"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DeviceUpdate/accounts/contoso/privateLinkResources/adu"), + // Properties: &armdeviceupdate.GroupInformationProperties{ + // GroupID: to.Ptr("adu"), + // RequiredMembers: []*string{ + // to.Ptr("adu")}, + // RequiredZoneNames: []*string{ + // to.Ptr("privatelink.adu.microsoft.com")}, + // }, + // } } diff --git a/sdk/resourcemanager/deviceupdate/armdeviceupdate/response_types.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/response_types.go index abaef2836cf2..ad1be9e754da 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/response_types.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/response_types.go @@ -9,12 +9,12 @@ package armdeviceupdate -// AccountsClientCreateResponse contains the response from method AccountsClient.Create. +// AccountsClientCreateResponse contains the response from method AccountsClient.BeginCreate. type AccountsClientCreateResponse struct { Account } -// AccountsClientDeleteResponse contains the response from method AccountsClient.Delete. +// AccountsClientDeleteResponse contains the response from method AccountsClient.BeginDelete. type AccountsClientDeleteResponse struct { // placeholder for future response values } @@ -30,17 +30,17 @@ type AccountsClientHeadResponse struct { Success bool } -// AccountsClientListByResourceGroupResponse contains the response from method AccountsClient.ListByResourceGroup. +// AccountsClientListByResourceGroupResponse contains the response from method AccountsClient.NewListByResourceGroupPager. type AccountsClientListByResourceGroupResponse struct { AccountList } -// AccountsClientListBySubscriptionResponse contains the response from method AccountsClient.ListBySubscription. +// AccountsClientListBySubscriptionResponse contains the response from method AccountsClient.NewListBySubscriptionPager. type AccountsClientListBySubscriptionResponse struct { AccountList } -// AccountsClientUpdateResponse contains the response from method AccountsClient.Update. +// AccountsClientUpdateResponse contains the response from method AccountsClient.BeginUpdate. type AccountsClientUpdateResponse struct { Account } @@ -50,12 +50,12 @@ type ClientCheckNameAvailabilityResponse struct { CheckNameAvailabilityResponse } -// InstancesClientCreateResponse contains the response from method InstancesClient.Create. +// InstancesClientCreateResponse contains the response from method InstancesClient.BeginCreate. type InstancesClientCreateResponse struct { Instance } -// InstancesClientDeleteResponse contains the response from method InstancesClient.Delete. +// InstancesClientDeleteResponse contains the response from method InstancesClient.BeginDelete. type InstancesClientDeleteResponse struct { // placeholder for future response values } @@ -71,7 +71,7 @@ type InstancesClientHeadResponse struct { Success bool } -// InstancesClientListByAccountResponse contains the response from method InstancesClient.ListByAccount. +// InstancesClientListByAccountResponse contains the response from method InstancesClient.NewListByAccountPager. type InstancesClientListByAccountResponse struct { InstanceList } @@ -81,17 +81,17 @@ type InstancesClientUpdateResponse struct { Instance } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult } -// PrivateEndpointConnectionProxiesClientCreateOrUpdateResponse contains the response from method PrivateEndpointConnectionProxiesClient.CreateOrUpdate. +// PrivateEndpointConnectionProxiesClientCreateOrUpdateResponse contains the response from method PrivateEndpointConnectionProxiesClient.BeginCreateOrUpdate. type PrivateEndpointConnectionProxiesClientCreateOrUpdateResponse struct { PrivateEndpointConnectionProxy } -// PrivateEndpointConnectionProxiesClientDeleteResponse contains the response from method PrivateEndpointConnectionProxiesClient.Delete. +// PrivateEndpointConnectionProxiesClientDeleteResponse contains the response from method PrivateEndpointConnectionProxiesClient.BeginDelete. type PrivateEndpointConnectionProxiesClientDeleteResponse struct { // placeholder for future response values } @@ -101,7 +101,7 @@ type PrivateEndpointConnectionProxiesClientGetResponse struct { PrivateEndpointConnectionProxy } -// PrivateEndpointConnectionProxiesClientListByAccountResponse contains the response from method PrivateEndpointConnectionProxiesClient.ListByAccount. +// PrivateEndpointConnectionProxiesClientListByAccountResponse contains the response from method PrivateEndpointConnectionProxiesClient.NewListByAccountPager. type PrivateEndpointConnectionProxiesClientListByAccountResponse struct { PrivateEndpointConnectionProxyListResult } @@ -116,12 +116,12 @@ type PrivateEndpointConnectionProxiesClientValidateResponse struct { // placeholder for future response values } -// 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 } @@ -131,7 +131,7 @@ type PrivateEndpointConnectionsClientGetResponse struct { PrivateEndpointConnection } -// PrivateEndpointConnectionsClientListByAccountResponse contains the response from method PrivateEndpointConnectionsClient.ListByAccount. +// PrivateEndpointConnectionsClientListByAccountResponse contains the response from method PrivateEndpointConnectionsClient.NewListByAccountPager. type PrivateEndpointConnectionsClientListByAccountResponse struct { PrivateEndpointConnectionListResult } @@ -141,7 +141,7 @@ type PrivateLinkResourcesClientGetResponse struct { GroupInformation } -// PrivateLinkResourcesClientListByAccountResponse contains the response from method PrivateLinkResourcesClient.ListByAccount. +// PrivateLinkResourcesClientListByAccountResponse contains the response from method PrivateLinkResourcesClient.NewListByAccountPager. type PrivateLinkResourcesClientListByAccountResponse struct { PrivateLinkResourceListResult } diff --git a/sdk/resourcemanager/deviceupdate/armdeviceupdate/time_rfc3339.go b/sdk/resourcemanager/deviceupdate/armdeviceupdate/time_rfc3339.go index 019559891d4f..bda7f2e27983 100644 --- a/sdk/resourcemanager/deviceupdate/armdeviceupdate/time_rfc3339.go +++ b/sdk/resourcemanager/deviceupdate/armdeviceupdate/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/devops/armdevops/CHANGELOG.md b/sdk/resourcemanager/devops/armdevops/CHANGELOG.md index cc887e52704d..9718278a55ab 100644 --- a/sdk/resourcemanager/devops/armdevops/CHANGELOG.md +++ b/sdk/resourcemanager/devops/armdevops/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.6.0 (2023-03-28) +### 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/devops/armdevops` 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/devops/armdevops/README.md b/sdk/resourcemanager/devops/armdevops/README.md index b2c8a91471fb..958eea6807df 100644 --- a/sdk/resourcemanager/devops/armdevops/README.md +++ b/sdk/resourcemanager/devops/armdevops/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 DevOps 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 DevOps 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 := armdevops.NewPipelinesClient(, cred, nil) +clientFactory, err := armdevops.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 := armdevops.NewPipelinesClient(, cred, &options) +clientFactory, err := armdevops.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.NewPipelinesClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/devops/armdevops/autorest.md b/sdk/resourcemanager/devops/armdevops/autorest.md index 9a1c01e20d19..79c2e7be7e26 100644 --- a/sdk/resourcemanager/devops/armdevops/autorest.md +++ b/sdk/resourcemanager/devops/armdevops/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devops/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devops/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/devops/armdevops/client_factory.go b/sdk/resourcemanager/devops/armdevops/client_factory.go new file mode 100644 index 000000000000..617262c52873 --- /dev/null +++ b/sdk/resourcemanager/devops/armdevops/client_factory.go @@ -0,0 +1,54 @@ +//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 armdevops + +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 - Unique identifier of the Azure subscription. 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) NewPipelineTemplateDefinitionsClient() *PipelineTemplateDefinitionsClient { + subClient, _ := NewPipelineTemplateDefinitionsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPipelinesClient() *PipelinesClient { + subClient, _ := NewPipelinesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/devops/armdevops/zz_generated_constants.go b/sdk/resourcemanager/devops/armdevops/constants.go similarity index 97% rename from sdk/resourcemanager/devops/armdevops/zz_generated_constants.go rename to sdk/resourcemanager/devops/armdevops/constants.go index e49c4b9c3caa..b62bc03cfa7e 100644 --- a/sdk/resourcemanager/devops/armdevops/zz_generated_constants.go +++ b/sdk/resourcemanager/devops/armdevops/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 armdevops const ( moduleName = "armdevops" - moduleVersion = "v0.5.0" + moduleVersion = "v0.6.0" ) // AuthorizationType - Type of authorization. diff --git a/sdk/resourcemanager/devops/armdevops/go.mod b/sdk/resourcemanager/devops/armdevops/go.mod index 91cb74fcd54b..268f2e88ee1d 100644 --- a/sdk/resourcemanager/devops/armdevops/go.mod +++ b/sdk/resourcemanager/devops/armdevops/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devops/armdevops 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/devops/armdevops/go.sum b/sdk/resourcemanager/devops/armdevops/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/devops/armdevops/go.sum +++ b/sdk/resourcemanager/devops/armdevops/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/devops/armdevops/zz_generated_models.go b/sdk/resourcemanager/devops/armdevops/models.go similarity index 89% rename from sdk/resourcemanager/devops/armdevops/zz_generated_models.go rename to sdk/resourcemanager/devops/armdevops/models.go index 586eb64006f6..6b63c0aa88c6 100644 --- a/sdk/resourcemanager/devops/armdevops/zz_generated_models.go +++ b/sdk/resourcemanager/devops/armdevops/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 armdevops @@ -26,27 +27,6 @@ type BootstrapConfiguration struct { Repository *CodeRepository `json:"repository,omitempty"` } -// CloudError - An error response from the Pipelines Resource Provider. -type CloudError struct { - // Details of the error from the Pipelines Resource Provider. - Error *CloudErrorBody `json:"error,omitempty"` -} - -// CloudErrorBody - An error response from the Pipelines Resource Provider. -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 or the method where the error occurred. - Target *string `json:"target,omitempty"` -} - // CodeRepository - Repository containing the source code for a pipeline. type CodeRepository struct { // REQUIRED; Default branch used to configure Continuous Integration (CI) in the pipeline. @@ -125,7 +105,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 } @@ -214,7 +194,7 @@ type PipelineTemplateDefinitionListResult struct { Value []*PipelineTemplateDefinition `json:"value,omitempty"` } -// PipelineTemplateDefinitionsClientListOptions contains the optional parameters for the PipelineTemplateDefinitionsClient.List +// PipelineTemplateDefinitionsClientListOptions contains the optional parameters for the PipelineTemplateDefinitionsClient.NewListPager // method. type PipelineTemplateDefinitionsClientListOptions struct { // placeholder for future optional parameters @@ -243,13 +223,14 @@ type PipelinesClientGetOptions struct { // placeholder for future optional parameters } -// PipelinesClientListByResourceGroupOptions contains the optional parameters for the PipelinesClient.ListByResourceGroup +// PipelinesClientListByResourceGroupOptions contains the optional parameters for the PipelinesClient.NewListByResourceGroupPager // method. type PipelinesClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// PipelinesClientListBySubscriptionOptions contains the optional parameters for the PipelinesClient.ListBySubscription method. +// PipelinesClientListBySubscriptionOptions contains the optional parameters for the PipelinesClient.NewListBySubscriptionPager +// method. type PipelinesClientListBySubscriptionOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/devops/armdevops/models_serde.go b/sdk/resourcemanager/devops/armdevops/models_serde.go new file mode 100644 index 000000000000..895372f8c78b --- /dev/null +++ b/sdk/resourcemanager/devops/armdevops/models_serde.go @@ -0,0 +1,663 @@ +//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 armdevops + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Authorization. +func (a Authorization) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authorizationType", a.AuthorizationType) + populate(objectMap, "parameters", a.Parameters) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Authorization. +func (a *Authorization) UnmarshalJSON(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 "authorizationType": + err = unpopulate(val, "AuthorizationType", &a.AuthorizationType) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &a.Parameters) + 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 BootstrapConfiguration. +func (b BootstrapConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "repository", b.Repository) + populate(objectMap, "template", b.Template) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BootstrapConfiguration. +func (b *BootstrapConfiguration) UnmarshalJSON(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 "repository": + err = unpopulate(val, "Repository", &b.Repository) + delete(rawMsg, key) + case "template": + err = unpopulate(val, "Template", &b.Template) + 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 CodeRepository. +func (c CodeRepository) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authorization", c.Authorization) + populate(objectMap, "defaultBranch", c.DefaultBranch) + populate(objectMap, "id", c.ID) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "repositoryType", c.RepositoryType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CodeRepository. +func (c *CodeRepository) UnmarshalJSON(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 "authorization": + err = unpopulate(val, "Authorization", &c.Authorization) + delete(rawMsg, key) + case "defaultBranch": + err = unpopulate(val, "DefaultBranch", &c.DefaultBranch) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "repositoryType": + err = unpopulate(val, "RepositoryType", &c.RepositoryType) + 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 InputDescriptor. +func (i InputDescriptor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", i.Description) + populate(objectMap, "id", i.ID) + populate(objectMap, "possibleValues", i.PossibleValues) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InputDescriptor. +func (i *InputDescriptor) UnmarshalJSON(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 "description": + err = unpopulate(val, "Description", &i.Description) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "possibleValues": + err = unpopulate(val, "PossibleValues", &i.PossibleValues) + 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 InputValue. +func (i InputValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayValue", i.DisplayValue) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InputValue. +func (i *InputValue) UnmarshalJSON(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 "displayValue": + err = unpopulate(val, "DisplayValue", &i.DisplayValue) + delete(rawMsg, 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 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) + 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) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplayValue. +func (o OperationDisplayValue) 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 OperationDisplayValue. +func (o *OperationDisplayValue) UnmarshalJSON(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 OrganizationReference. +func (o OrganizationReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrganizationReference. +func (o *OrganizationReference) UnmarshalJSON(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 "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 Pipeline. +func (p Pipeline) 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, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Pipeline. +func (p *Pipeline) UnmarshalJSON(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 "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 PipelineListResult. +func (p PipelineListResult) 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 PipelineListResult. +func (p *PipelineListResult) UnmarshalJSON(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 PipelineProperties. +func (p PipelineProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "bootstrapConfiguration", p.BootstrapConfiguration) + populate(objectMap, "organization", p.Organization) + populate(objectMap, "pipelineId", p.PipelineID) + populate(objectMap, "project", p.Project) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelineProperties. +func (p *PipelineProperties) UnmarshalJSON(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 "bootstrapConfiguration": + err = unpopulate(val, "BootstrapConfiguration", &p.BootstrapConfiguration) + delete(rawMsg, key) + case "organization": + err = unpopulate(val, "Organization", &p.Organization) + delete(rawMsg, key) + case "pipelineId": + err = unpopulate(val, "PipelineID", &p.PipelineID) + delete(rawMsg, key) + case "project": + err = unpopulate(val, "Project", &p.Project) + 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 PipelineTemplate. +func (p PipelineTemplate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "parameters", p.Parameters) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelineTemplate. +func (p *PipelineTemplate) UnmarshalJSON(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 "parameters": + err = unpopulate(val, "Parameters", &p.Parameters) + 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 PipelineTemplateDefinition. +func (p PipelineTemplateDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", p.Description) + populate(objectMap, "id", p.ID) + populate(objectMap, "inputs", p.Inputs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelineTemplateDefinition. +func (p *PipelineTemplateDefinition) UnmarshalJSON(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 "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "inputs": + err = unpopulate(val, "Inputs", &p.Inputs) + 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 PipelineTemplateDefinitionListResult. +func (p PipelineTemplateDefinitionListResult) 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 PipelineTemplateDefinitionListResult. +func (p *PipelineTemplateDefinitionListResult) UnmarshalJSON(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 PipelineUpdateParameters. +func (p PipelineUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelineUpdateParameters. +func (p *PipelineUpdateParameters) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &p.Tags) + 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 ProjectReference. +func (p ProjectReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectReference. +func (p *ProjectReference) UnmarshalJSON(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) + } + 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, "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 "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 +} + +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/devops/armdevops/zz_generated_operations_client.go b/sdk/resourcemanager/devops/armdevops/operations_client.go similarity index 77% rename from sdk/resourcemanager/devops/armdevops/zz_generated_operations_client.go rename to sdk/resourcemanager/devops/armdevops/operations_client.go index 69aa6315c6bf..9cde878f4bc8 100644 --- a/sdk/resourcemanager/devops/armdevops/zz_generated_operations_client.go +++ b/sdk/resourcemanager/devops/armdevops/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 armdevops @@ -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 the operations supported by Microsoft.DevOps resource provider. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-07-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.DevOps/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/devops/armdevops/operations_client_example_test.go b/sdk/resourcemanager/devops/armdevops/operations_client_example_test.go new file mode 100644 index 000000000000..05f216a92c7f --- /dev/null +++ b/sdk/resourcemanager/devops/armdevops/operations_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 armdevops_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devops/armdevops" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/ListOperations.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 := armdevops.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 = armdevops.OperationListResult{ + // Value: []*armdevops.Operation{ + // { + // Name: to.Ptr("Microsoft.DevOps/register/action"), + // Display: &armdevops.OperationDisplayValue{ + // Description: to.Ptr("Registers the specified subscription with Microsoft.DevOps resource provider and enables the creation of Pipelines"), + // Operation: to.Ptr("Register for Microsoft.DevOps"), + // Provider: to.Ptr("Microsoft DevOps"), + // Resource: to.Ptr("register"), + // }, + // IsDataAction: to.Ptr("false"), + // }, + // { + // Name: to.Ptr("Microsoft.DevOps/pipelines/write"), + // Display: &armdevops.OperationDisplayValue{ + // Description: to.Ptr("Creates or Updates any Pipeline"), + // Operation: to.Ptr("Create or Update Pipeline"), + // Provider: to.Ptr("Microsoft DevOps"), + // Resource: to.Ptr("Pipelines"), + // }, + // IsDataAction: to.Ptr("false"), + // }, + // { + // Name: to.Ptr("Microsoft.DevOps/pipelines/read"), + // Display: &armdevops.OperationDisplayValue{ + // Description: to.Ptr("Reads any Pipeline"), + // Operation: to.Ptr("Read Pipeline"), + // Provider: to.Ptr("Microsoft DevOps"), + // Resource: to.Ptr("Pipelines"), + // }, + // IsDataAction: to.Ptr("false"), + // }, + // { + // Name: to.Ptr("Microsoft.DevOps/pipelines/delete"), + // Display: &armdevops.OperationDisplayValue{ + // Description: to.Ptr("Deletes any Pipeline"), + // Operation: to.Ptr("Delete Pipeline"), + // Provider: to.Ptr("Microsoft DevOps"), + // Resource: to.Ptr("Pipelines"), + // }, + // IsDataAction: to.Ptr("false"), + // }, + // { + // Name: to.Ptr("Microsoft.DevOps/pipelineTemplateDefinitions/read"), + // Display: &armdevops.OperationDisplayValue{ + // Description: to.Ptr("Reads any PipelineTemplateDefinition"), + // Operation: to.Ptr("Read PipelineTemplateDefinition"), + // Provider: to.Ptr("Microsoft DevOps"), + // Resource: to.Ptr("PipelineTemplateDefinitions"), + // }, + // IsDataAction: to.Ptr("false"), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/devops/armdevops/zz_generated_pipelines_client.go b/sdk/resourcemanager/devops/armdevops/pipelines_client.go similarity index 84% rename from sdk/resourcemanager/devops/armdevops/zz_generated_pipelines_client.go rename to sdk/resourcemanager/devops/armdevops/pipelines_client.go index eb75c0fa3675..6aa10f811a06 100644 --- a/sdk/resourcemanager/devops/armdevops/zz_generated_pipelines_client.go +++ b/sdk/resourcemanager/devops/armdevops/pipelines_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 armdevops @@ -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,64 +24,57 @@ import ( // PipelinesClient contains the methods for the Pipelines group. // Don't use this type directly, use NewPipelinesClient() instead. type PipelinesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPipelinesClient creates a new instance of PipelinesClient with the specified values. -// subscriptionID - Unique identifier of the Azure subscription. 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 - Unique identifier of the Azure subscription. 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 NewPipelinesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PipelinesClient, 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+".PipelinesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PipelinesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates an Azure Pipeline. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-07-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// pipelineName - The name of the Azure Pipeline resource in ARM. -// createOperationParameters - The request payload to create the Azure Pipeline. -// options - PipelinesClientBeginCreateOrUpdateOptions contains the optional parameters for the PipelinesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - pipelineName - The name of the Azure Pipeline resource in ARM. +// - createOperationParameters - The request payload to create the Azure Pipeline. +// - options - PipelinesClientBeginCreateOrUpdateOptions contains the optional parameters for the PipelinesClient.BeginCreateOrUpdate +// method. func (client *PipelinesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, pipelineName string, createOperationParameters Pipeline, options *PipelinesClientBeginCreateOrUpdateOptions) (*runtime.Poller[PipelinesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, pipelineName, createOperationParameters, options) if err != nil { return nil, err } - return runtime.NewPoller[PipelinesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[PipelinesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[PipelinesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PipelinesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates an Azure Pipeline. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-07-01-preview func (client *PipelinesClient) createOrUpdate(ctx context.Context, resourceGroupName string, pipelineName string, createOperationParameters Pipeline, options *PipelinesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, pipelineName, createOperationParameters, 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 +99,7 @@ func (client *PipelinesClient) createOrUpdateCreateRequest(ctx context.Context, return nil, errors.New("parameter pipelineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{pipelineName}", url.PathEscape(pipelineName)) - 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 +112,17 @@ func (client *PipelinesClient) createOrUpdateCreateRequest(ctx context.Context, // Delete - Deletes an Azure Pipeline. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-07-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// pipelineName - The name of the Azure Pipeline resource. -// options - PipelinesClientDeleteOptions contains the optional parameters for the PipelinesClient.Delete method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - pipelineName - The name of the Azure Pipeline resource. +// - options - PipelinesClientDeleteOptions contains the optional parameters for the PipelinesClient.Delete method. func (client *PipelinesClient) Delete(ctx context.Context, resourceGroupName string, pipelineName string, options *PipelinesClientDeleteOptions) (PipelinesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, pipelineName, options) if err != nil { return PipelinesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PipelinesClientDeleteResponse{}, err } @@ -154,7 +147,7 @@ func (client *PipelinesClient) deleteCreateRequest(ctx context.Context, resource return nil, errors.New("parameter pipelineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{pipelineName}", url.PathEscape(pipelineName)) - 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 +160,17 @@ func (client *PipelinesClient) deleteCreateRequest(ctx context.Context, resource // Get - Gets an existing Azure Pipeline. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-07-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// pipelineName - The name of the Azure Pipeline resource in ARM. -// options - PipelinesClientGetOptions contains the optional parameters for the PipelinesClient.Get method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - pipelineName - The name of the Azure Pipeline resource in ARM. +// - options - PipelinesClientGetOptions contains the optional parameters for the PipelinesClient.Get method. func (client *PipelinesClient) Get(ctx context.Context, resourceGroupName string, pipelineName string, options *PipelinesClientGetOptions) (PipelinesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, pipelineName, options) if err != nil { return PipelinesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PipelinesClientGetResponse{}, err } @@ -201,7 +195,7 @@ func (client *PipelinesClient) getCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter pipelineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{pipelineName}", url.PathEscape(pipelineName)) - 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,11 +216,11 @@ func (client *PipelinesClient) getHandleResponse(resp *http.Response) (Pipelines } // NewListByResourceGroupPager - Lists all Azure Pipelines under the specified resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-07-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// options - PipelinesClientListByResourceGroupOptions contains the optional parameters for the PipelinesClient.ListByResourceGroup -// method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - options - PipelinesClientListByResourceGroupOptions contains the optional parameters for the PipelinesClient.NewListByResourceGroupPager +// method. func (client *PipelinesClient) NewListByResourceGroupPager(resourceGroupName string, options *PipelinesClientListByResourceGroupOptions) *runtime.Pager[PipelinesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[PipelinesClientListByResourceGroupResponse]{ More: func(page PipelinesClientListByResourceGroupResponse) bool { @@ -243,7 +237,7 @@ func (client *PipelinesClient) NewListByResourceGroupPager(resourceGroupName str if err != nil { return PipelinesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PipelinesClientListByResourceGroupResponse{}, err } @@ -266,7 +260,7 @@ func (client *PipelinesClient) listByResourceGroupCreateRequest(ctx context.Cont 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 } @@ -287,10 +281,10 @@ func (client *PipelinesClient) listByResourceGroupHandleResponse(resp *http.Resp } // NewListBySubscriptionPager - Lists all Azure Pipelines under the specified subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-07-01-preview -// options - PipelinesClientListBySubscriptionOptions contains the optional parameters for the PipelinesClient.ListBySubscription -// method. +// - options - PipelinesClientListBySubscriptionOptions contains the optional parameters for the PipelinesClient.NewListBySubscriptionPager +// method. func (client *PipelinesClient) NewListBySubscriptionPager(options *PipelinesClientListBySubscriptionOptions) *runtime.Pager[PipelinesClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[PipelinesClientListBySubscriptionResponse]{ More: func(page PipelinesClientListBySubscriptionResponse) bool { @@ -307,7 +301,7 @@ func (client *PipelinesClient) NewListBySubscriptionPager(options *PipelinesClie if err != nil { return PipelinesClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PipelinesClientListBySubscriptionResponse{}, err } @@ -326,7 +320,7 @@ func (client *PipelinesClient) 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 } @@ -348,17 +342,18 @@ func (client *PipelinesClient) listBySubscriptionHandleResponse(resp *http.Respo // Update - Updates the properties of an Azure Pipeline. Currently, only tags can be updated. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-07-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// pipelineName - The name of the Azure Pipeline resource. -// updateOperationParameters - The request payload containing the properties to update in the Azure Pipeline. -// options - PipelinesClientUpdateOptions contains the optional parameters for the PipelinesClient.Update method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - pipelineName - The name of the Azure Pipeline resource. +// - updateOperationParameters - The request payload containing the properties to update in the Azure Pipeline. +// - options - PipelinesClientUpdateOptions contains the optional parameters for the PipelinesClient.Update method. func (client *PipelinesClient) Update(ctx context.Context, resourceGroupName string, pipelineName string, updateOperationParameters PipelineUpdateParameters, options *PipelinesClientUpdateOptions) (PipelinesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, pipelineName, updateOperationParameters, options) if err != nil { return PipelinesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PipelinesClientUpdateResponse{}, err } @@ -383,7 +378,7 @@ func (client *PipelinesClient) updateCreateRequest(ctx context.Context, resource return nil, errors.New("parameter pipelineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{pipelineName}", url.PathEscape(pipelineName)) - 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/devops/armdevops/pipelines_client_example_test.go b/sdk/resourcemanager/devops/armdevops/pipelines_client_example_test.go new file mode 100644 index 000000000000..7a7390b6ca8b --- /dev/null +++ b/sdk/resourcemanager/devops/armdevops/pipelines_client_example_test.go @@ -0,0 +1,356 @@ +//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 armdevops_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/devops/armdevops" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/CreateAzurePipeline-Sample-AspNet-WindowsWebApp.json +func ExamplePipelinesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevops.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPipelinesClient().BeginCreateOrUpdate(ctx, "myAspNetWebAppPipeline-rg", "myAspNetWebAppPipeline", armdevops.Pipeline{ + Location: to.Ptr("South India"), + Tags: map[string]*string{}, + Properties: &armdevops.PipelineProperties{ + BootstrapConfiguration: &armdevops.BootstrapConfiguration{ + Template: &armdevops.PipelineTemplate{ + ID: to.Ptr("ms.vss-continuous-delivery-pipeline-templates.aspnet-windowswebapp"), + Parameters: map[string]*string{ + "appInsightLocation": to.Ptr("South India"), + "appServicePlan": to.Ptr("S1 Standard"), + "azureAuth": to.Ptr("{\"scheme\":\"ServicePrincipal\",\"parameters\":{\"tenantid\":\"{subscriptionTenantId}\",\"objectid\":\"{appObjectId}\",\"serviceprincipalid\":\"{appId}\",\"serviceprincipalkey\":\"{appSecret}\"}}"), + "location": to.Ptr("South India"), + "resourceGroup": to.Ptr("myAspNetWebAppPipeline-rg"), + "subscriptionId": to.Ptr("{subscriptionId}"), + "webAppName": to.Ptr("myAspNetWebApp"), + }, + }, + }, + Organization: &armdevops.OrganizationReference{ + Name: to.Ptr("myAspNetWebAppPipeline-org"), + }, + Project: &armdevops.ProjectReference{ + Name: to.Ptr("myAspNetWebAppPipeline-project"), + }, + }, + }, 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.Pipeline = armdevops.Pipeline{ + // Name: to.Ptr("myAspNetWebAppPipeline"), + // Type: to.Ptr("Microsoft.DevOps/pipelines"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myAspNetWebAppPipeline-rg/providers/Microsoft.DevOps/pipelines/myAspNetWebAppPipeline"), + // Location: to.Ptr("South India"), + // Properties: &armdevops.PipelineProperties{ + // BootstrapConfiguration: &armdevops.BootstrapConfiguration{ + // Template: &armdevops.PipelineTemplate{ + // ID: to.Ptr("ms.vss-continuous-delivery-pipeline-templates.aspnet-windowswebapp"), + // Parameters: map[string]*string{ + // "appInsightLocation": to.Ptr("South India"), + // "appServicePlan": to.Ptr("S1 Standard"), + // "azureAuth": nil, + // "location": to.Ptr("South India"), + // "resourceGroup": to.Ptr("myAspNetWebAppPipeline-rg"), + // "subscriptionId": to.Ptr("{subscriptionId}"), + // "webAppName": to.Ptr("myAspNetWebApp"), + // }, + // }, + // }, + // Organization: &armdevops.OrganizationReference{ + // Name: to.Ptr("myAspNetWebAppPipeline-org"), + // }, + // Project: &armdevops.ProjectReference{ + // Name: to.Ptr("myAspNetWebAppPipeline-project"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/GetAzurePipeline.json +func ExamplePipelinesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevops.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPipelinesClient().Get(ctx, "myAspNetWebAppPipeline-rg", "myAspNetWebAppPipeline", 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.Pipeline = armdevops.Pipeline{ + // Name: to.Ptr("myAspNetWebAppPipeline"), + // Type: to.Ptr("Microsoft.DevOps/pipelines"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myAspNetWebAppPipeline-rg/providers/Microsoft.DevOps/pipelines/myAspNetWebAppPipeline"), + // Location: to.Ptr("South India"), + // Properties: &armdevops.PipelineProperties{ + // BootstrapConfiguration: &armdevops.BootstrapConfiguration{ + // Template: &armdevops.PipelineTemplate{ + // ID: to.Ptr("ms.vss-continuous-delivery-pipeline-templates.aspnet-windowswebapp"), + // Parameters: map[string]*string{ + // "appInsightLocation": to.Ptr("South India"), + // "appServicePlan": to.Ptr("S1 Standard"), + // "azureAuth": nil, + // "location": to.Ptr("South India"), + // "resourceGroup": to.Ptr("myAspNetWebAppPipeline-rg"), + // "subscriptionId": to.Ptr("{subscriptionId}"), + // "webAppName": to.Ptr("myAspNetWebApp"), + // }, + // }, + // }, + // Organization: &armdevops.OrganizationReference{ + // Name: to.Ptr("myAspNetWebAppPipeline-org"), + // }, + // Project: &armdevops.ProjectReference{ + // Name: to.Ptr("myAspNetWebAppPipeline-project"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/UpdateAzurePipeline.json +func ExamplePipelinesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevops.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPipelinesClient().Update(ctx, "myAspNetWebAppPipeline-rg", "myAspNetWebAppPipeline", armdevops.PipelineUpdateParameters{ + Tags: map[string]*string{ + "tagKey": to.Ptr("tagvalue"), + }, + }, 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.Pipeline = armdevops.Pipeline{ + // Name: to.Ptr("myAspNetWebAppPipeline"), + // Type: to.Ptr("Microsoft.DevOps/pipelines"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myAspNetWebAppPipeline-rg/providers/Microsoft.DevOps/pipelines/myAspNetWebAppPipeline"), + // Location: to.Ptr("South India"), + // Tags: map[string]*string{ + // "tagKey": to.Ptr("tagvalue"), + // }, + // Properties: &armdevops.PipelineProperties{ + // BootstrapConfiguration: &armdevops.BootstrapConfiguration{ + // Template: &armdevops.PipelineTemplate{ + // ID: to.Ptr("ms.vss-continuous-delivery-pipeline-templates.aspnet-windowswebapp"), + // Parameters: map[string]*string{ + // "appInsightLocation": to.Ptr("South India"), + // "appServicePlan": to.Ptr("S1 Standard"), + // "azureAuth": nil, + // "location": to.Ptr("South India"), + // "resourceGroup": to.Ptr("myAspNetWebAppPipeline-rg"), + // "subscriptionId": to.Ptr("{subscriptionId}"), + // "webAppName": to.Ptr("myAspNetWebApp"), + // }, + // }, + // }, + // Organization: &armdevops.OrganizationReference{ + // Name: to.Ptr("myAspNetWebAppPipeline-org"), + // }, + // Project: &armdevops.ProjectReference{ + // Name: to.Ptr("myAspNetWebAppPipeline-project"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/DeleteAzurePipeline.json +func ExamplePipelinesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevops.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewPipelinesClient().Delete(ctx, "myAspNetWebAppPipeline-rg", "myAspNetWebAppPipeline", 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/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/ListAzurePipelinesByResourceGroup.json +func ExamplePipelinesClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevops.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPipelinesClient().NewListByResourceGroupPager("myAspNetWebAppPipeline-rg", 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.PipelineListResult = armdevops.PipelineListResult{ + // Value: []*armdevops.Pipeline{ + // { + // Name: to.Ptr("myAspNetWebAppPipeline"), + // Type: to.Ptr("Microsoft.DevOps/pipelines"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myAspNetWebAppPipeline-rg/providers/Microsoft.DevOps/pipelines/myAspNetWebAppPipeline"), + // Location: to.Ptr("South India"), + // Properties: &armdevops.PipelineProperties{ + // BootstrapConfiguration: &armdevops.BootstrapConfiguration{ + // Template: &armdevops.PipelineTemplate{ + // ID: to.Ptr("ms.vss-continuous-delivery-pipeline-templates.aspnet-windowswebapp"), + // Parameters: map[string]*string{ + // "appInsightLocation": to.Ptr("South India"), + // "appServicePlan": to.Ptr("S1 Standard"), + // "azureAuth": nil, + // "location": to.Ptr("South India"), + // "resourceGroup": to.Ptr("myAspNetWebAppPipeline-rg"), + // "subscriptionId": to.Ptr("{subscriptionId}"), + // "webAppName": to.Ptr("myAspNetWebApp"), + // }, + // }, + // }, + // Organization: &armdevops.OrganizationReference{ + // Name: to.Ptr("myAspNetWebAppPipeline-org"), + // }, + // Project: &armdevops.ProjectReference{ + // Name: to.Ptr("myAspNetWebAppPipeline-project"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/ListAzurePipelinesBySubscription.json +func ExamplePipelinesClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevops.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPipelinesClient().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.PipelineListResult = armdevops.PipelineListResult{ + // Value: []*armdevops.Pipeline{ + // { + // Name: to.Ptr("myAspNetWebAppPipeline"), + // Type: to.Ptr("Microsoft.DevOps/pipelines"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myAspNetWebAppPipeline-rg/providers/Microsoft.DevOps/pipelines/myAspNetWebAppPipeline"), + // Location: to.Ptr("South India"), + // Properties: &armdevops.PipelineProperties{ + // BootstrapConfiguration: &armdevops.BootstrapConfiguration{ + // Template: &armdevops.PipelineTemplate{ + // ID: to.Ptr("ms.vss-continuous-delivery-pipeline-templates.aspnet-windowswebapp"), + // Parameters: map[string]*string{ + // "appInsightLocation": to.Ptr("South India"), + // "appServicePlan": to.Ptr("S1 Standard"), + // "azureAuth": nil, + // "location": to.Ptr("South India"), + // "resourceGroup": to.Ptr("myAspNetWebAppPipeline-rg"), + // "subscriptionId": to.Ptr("{subscriptionId}"), + // "webAppName": to.Ptr("myAspNetWebApp"), + // }, + // }, + // }, + // Organization: &armdevops.OrganizationReference{ + // Name: to.Ptr("myAspNetWebAppPipeline-org"), + // }, + // Project: &armdevops.ProjectReference{ + // Name: to.Ptr("myAspNetWebAppPipeline-project"), + // }, + // }, + // }, + // { + // Name: to.Ptr("myAspNetWebAppPipeline1"), + // Type: to.Ptr("Microsoft.DevOps/pipelines"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myAspNetWebAppPipeline-rg1/providers/Microsoft.DevOps/pipelines/myAspNetWebAppPipeline1"), + // Location: to.Ptr("South India"), + // Properties: &armdevops.PipelineProperties{ + // BootstrapConfiguration: &armdevops.BootstrapConfiguration{ + // Template: &armdevops.PipelineTemplate{ + // ID: to.Ptr("ms.vss-continuous-delivery-pipeline-templates.aspnet-windowswebapp"), + // Parameters: map[string]*string{ + // "appInsightLocation": to.Ptr("South India"), + // "appServicePlan": to.Ptr("S1 Standard"), + // "azureAuth": nil, + // "location": to.Ptr("South India"), + // "resourceGroup": to.Ptr("myAspNetWebAppPipeline-rg"), + // "subscriptionId": to.Ptr("{subscriptionId}"), + // "webAppName": to.Ptr("myAspNetWebApp"), + // }, + // }, + // }, + // Organization: &armdevops.OrganizationReference{ + // Name: to.Ptr("myAspNetWebAppPipeline-org1"), + // }, + // Project: &armdevops.ProjectReference{ + // Name: to.Ptr("myAspNetWebAppPipeline-project1"), + // }, + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/devops/armdevops/zz_generated_pipelinetemplatedefinitions_client.go b/sdk/resourcemanager/devops/armdevops/pipelinetemplatedefinitions_client.go similarity index 79% rename from sdk/resourcemanager/devops/armdevops/zz_generated_pipelinetemplatedefinitions_client.go rename to sdk/resourcemanager/devops/armdevops/pipelinetemplatedefinitions_client.go index 7abd373f4a8a..685c666058cc 100644 --- a/sdk/resourcemanager/devops/armdevops/zz_generated_pipelinetemplatedefinitions_client.go +++ b/sdk/resourcemanager/devops/armdevops/pipelinetemplatedefinitions_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 armdevops @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,37 +21,28 @@ import ( // PipelineTemplateDefinitionsClient contains the methods for the PipelineTemplateDefinitions group. // Don't use this type directly, use NewPipelineTemplateDefinitionsClient() instead. type PipelineTemplateDefinitionsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewPipelineTemplateDefinitionsClient creates a new instance of PipelineTemplateDefinitionsClient 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 NewPipelineTemplateDefinitionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*PipelineTemplateDefinitionsClient, 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+".PipelineTemplateDefinitionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PipelineTemplateDefinitionsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists all pipeline templates which can be used to configure an Azure Pipeline. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-07-01-preview -// options - PipelineTemplateDefinitionsClientListOptions contains the optional parameters for the PipelineTemplateDefinitionsClient.List -// method. +// - options - PipelineTemplateDefinitionsClientListOptions contains the optional parameters for the PipelineTemplateDefinitionsClient.NewListPager +// method. func (client *PipelineTemplateDefinitionsClient) NewListPager(options *PipelineTemplateDefinitionsClientListOptions) *runtime.Pager[PipelineTemplateDefinitionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[PipelineTemplateDefinitionsClientListResponse]{ More: func(page PipelineTemplateDefinitionsClientListResponse) bool { @@ -69,7 +59,7 @@ func (client *PipelineTemplateDefinitionsClient) NewListPager(options *PipelineT if err != nil { return PipelineTemplateDefinitionsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PipelineTemplateDefinitionsClientListResponse{}, err } @@ -84,7 +74,7 @@ func (client *PipelineTemplateDefinitionsClient) NewListPager(options *PipelineT // listCreateRequest creates the List request. func (client *PipelineTemplateDefinitionsClient) listCreateRequest(ctx context.Context, options *PipelineTemplateDefinitionsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.DevOps/pipelineTemplateDefinitions" - 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/devops/armdevops/pipelinetemplatedefinitions_client_example_test.go b/sdk/resourcemanager/devops/armdevops/pipelinetemplatedefinitions_client_example_test.go new file mode 100644 index 000000000000..c20698c21d34 --- /dev/null +++ b/sdk/resourcemanager/devops/armdevops/pipelinetemplatedefinitions_client_example_test.go @@ -0,0 +1,143 @@ +//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 armdevops_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devops/armdevops" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/ListPipelineTemplateDefinitions.json +func ExamplePipelineTemplateDefinitionsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevops.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPipelineTemplateDefinitionsClient().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.PipelineTemplateDefinitionListResult = armdevops.PipelineTemplateDefinitionListResult{ + // Value: []*armdevops.PipelineTemplateDefinition{ + // { + // Description: to.Ptr("Template for configuring CI/CD pipeline for ASP.Net app on Azure windows app service"), + // ID: to.Ptr("ms.vss-continuous-delivery-pipeline-templates.aspnet-windowswebapp"), + // Inputs: []*armdevops.InputDescriptor{ + // { + // Type: to.Ptr(armdevops.InputDataTypeString), + // Description: to.Ptr("Authorization for Azure ARM endpoints."), + // ID: to.Ptr("azureAuth"), + // PossibleValues: []*armdevops.InputValue{ + // }, + // }, + // { + // Type: to.Ptr(armdevops.InputDataTypeString), + // Description: to.Ptr("Id of subscription where azure resources will be created."), + // ID: to.Ptr("subscriptionId"), + // PossibleValues: []*armdevops.InputValue{ + // }, + // }, + // { + // Type: to.Ptr(armdevops.InputDataTypeString), + // Description: to.Ptr("A resource group is a collection of resources that share the same lifecycle, permissions, and policies. Name of resource group which should contain web app."), + // ID: to.Ptr("resourceGroup"), + // PossibleValues: []*armdevops.InputValue{ + // }, + // }, + // { + // Type: to.Ptr(armdevops.InputDataTypeString), + // Description: to.Ptr("Name of web app to be created"), + // ID: to.Ptr("webAppName"), + // PossibleValues: []*armdevops.InputValue{ + // }, + // }, + // { + // Type: to.Ptr(armdevops.InputDataTypeString), + // Description: to.Ptr("Choose the Azure region that's right for you and your customers."), + // ID: to.Ptr("location"), + // PossibleValues: []*armdevops.InputValue{ + // }, + // }, + // { + // Type: to.Ptr(armdevops.InputDataTypeString), + // Description: to.Ptr("Details of cost and compute resource associated with the web app"), + // ID: to.Ptr("appServicePlan"), + // PossibleValues: []*armdevops.InputValue{ + // { + // DisplayValue: to.Ptr("P1 Premium (1 Core, 1.75 GB RAM)"), + // Value: to.Ptr("P1 Premium"), + // }, + // { + // DisplayValue: to.Ptr("P2 Premium (2 Core, 3.5 GB RAM)"), + // Value: to.Ptr("P2 Premium"), + // }, + // { + // DisplayValue: to.Ptr("P3 Premium (4 Core, 7 GB RAM)"), + // Value: to.Ptr("P3 Premium"), + // }, + // { + // DisplayValue: to.Ptr("S1 Standard (1 Core, 1.75 GB RAM)"), + // Value: to.Ptr("S1 Standard"), + // }, + // { + // DisplayValue: to.Ptr("S2 Standard (2 Core, 3.5 GB RAM)"), + // Value: to.Ptr("S2 Standard"), + // }, + // { + // DisplayValue: to.Ptr("S3 Standard (4 Core, 7 GB RAM)"), + // Value: to.Ptr("S3 Standard"), + // }, + // { + // DisplayValue: to.Ptr("B1 Basic (1 Core, 1.75 GB RAM)"), + // Value: to.Ptr("B1 Basic"), + // }, + // { + // DisplayValue: to.Ptr("B2 Basic (2 Core, 3.5 GB RAM)"), + // Value: to.Ptr("B2 Basic"), + // }, + // { + // DisplayValue: to.Ptr("B3 Basic (4 Core, 7 GB RAM)"), + // Value: to.Ptr("B3 Basic"), + // }, + // { + // DisplayValue: to.Ptr("F1 Free"), + // Value: to.Ptr("F1 Free"), + // }, + // { + // DisplayValue: to.Ptr("D1 Shared"), + // Value: to.Ptr("D1 Shared"), + // }}, + // }, + // { + // Type: to.Ptr(armdevops.InputDataTypeString), + // Description: to.Ptr("Collect application monitoring data using Application Insights."), + // ID: to.Ptr("appInsightLocation"), + // PossibleValues: []*armdevops.InputValue{ + // }, + // }}, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/devops/armdevops/zz_generated_response_types.go b/sdk/resourcemanager/devops/armdevops/response_types.go similarity index 84% rename from sdk/resourcemanager/devops/armdevops/zz_generated_response_types.go rename to sdk/resourcemanager/devops/armdevops/response_types.go index 097574ed5de2..89330627e214 100644 --- a/sdk/resourcemanager/devops/armdevops/zz_generated_response_types.go +++ b/sdk/resourcemanager/devops/armdevops/response_types.go @@ -5,20 +5,21 @@ // Licensed under the MIT License. See License.txt in the project root for 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 armdevops -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult } -// PipelineTemplateDefinitionsClientListResponse contains the response from method PipelineTemplateDefinitionsClient.List. +// PipelineTemplateDefinitionsClientListResponse contains the response from method PipelineTemplateDefinitionsClient.NewListPager. type PipelineTemplateDefinitionsClientListResponse struct { PipelineTemplateDefinitionListResult } -// PipelinesClientCreateOrUpdateResponse contains the response from method PipelinesClient.CreateOrUpdate. +// PipelinesClientCreateOrUpdateResponse contains the response from method PipelinesClient.BeginCreateOrUpdate. type PipelinesClientCreateOrUpdateResponse struct { Pipeline } @@ -33,12 +34,12 @@ type PipelinesClientGetResponse struct { Pipeline } -// PipelinesClientListByResourceGroupResponse contains the response from method PipelinesClient.ListByResourceGroup. +// PipelinesClientListByResourceGroupResponse contains the response from method PipelinesClient.NewListByResourceGroupPager. type PipelinesClientListByResourceGroupResponse struct { PipelineListResult } -// PipelinesClientListBySubscriptionResponse contains the response from method PipelinesClient.ListBySubscription. +// PipelinesClientListBySubscriptionResponse contains the response from method PipelinesClient.NewListBySubscriptionPager. type PipelinesClientListBySubscriptionResponse struct { PipelineListResult } diff --git a/sdk/resourcemanager/devops/armdevops/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/devops/armdevops/ze_generated_example_operations_client_test.go deleted file mode 100644 index 6ec5fb4d4bf6..000000000000 --- a/sdk/resourcemanager/devops/armdevops/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 armdevops_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devops/armdevops" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/ListOperations.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 := armdevops.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/devops/armdevops/ze_generated_example_pipelines_client_test.go b/sdk/resourcemanager/devops/armdevops/ze_generated_example_pipelines_client_test.go deleted file mode 100644 index 94f56a5b806f..000000000000 --- a/sdk/resourcemanager/devops/armdevops/ze_generated_example_pipelines_client_test.go +++ /dev/null @@ -1,188 +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 armdevops_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/devops/armdevops" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/CreateAzurePipeline-Sample-AspNet-WindowsWebApp.json -func ExamplePipelinesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevops.NewPipelinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "myAspNetWebAppPipeline-rg", - "myAspNetWebAppPipeline", - armdevops.Pipeline{ - Location: to.Ptr("South India"), - Tags: map[string]*string{}, - Properties: &armdevops.PipelineProperties{ - BootstrapConfiguration: &armdevops.BootstrapConfiguration{ - Template: &armdevops.PipelineTemplate{ - ID: to.Ptr("ms.vss-continuous-delivery-pipeline-templates.aspnet-windowswebapp"), - Parameters: map[string]*string{ - "appInsightLocation": to.Ptr("South India"), - "appServicePlan": to.Ptr("S1 Standard"), - "azureAuth": to.Ptr("{\"scheme\":\"ServicePrincipal\",\"parameters\":{\"tenantid\":\"{subscriptionTenantId}\",\"objectid\":\"{appObjectId}\",\"serviceprincipalid\":\"{appId}\",\"serviceprincipalkey\":\"{appSecret}\"}}"), - "location": to.Ptr("South India"), - "resourceGroup": to.Ptr("myAspNetWebAppPipeline-rg"), - "subscriptionId": to.Ptr("{subscriptionId}"), - "webAppName": to.Ptr("myAspNetWebApp"), - }, - }, - }, - Organization: &armdevops.OrganizationReference{ - Name: to.Ptr("myAspNetWebAppPipeline-org"), - }, - Project: &armdevops.ProjectReference{ - Name: to.Ptr("myAspNetWebAppPipeline-project"), - }, - }, - }, - 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/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/GetAzurePipeline.json -func ExamplePipelinesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevops.NewPipelinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myAspNetWebAppPipeline-rg", - "myAspNetWebAppPipeline", - 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/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/UpdateAzurePipeline.json -func ExamplePipelinesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevops.NewPipelinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "myAspNetWebAppPipeline-rg", - "myAspNetWebAppPipeline", - armdevops.PipelineUpdateParameters{ - Tags: map[string]*string{ - "tagKey": to.Ptr("tagvalue"), - }, - }, - 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/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/DeleteAzurePipeline.json -func ExamplePipelinesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevops.NewPipelinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "myAspNetWebAppPipeline-rg", - "myAspNetWebAppPipeline", - 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/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/ListAzurePipelinesByResourceGroup.json -func ExamplePipelinesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevops.NewPipelinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("myAspNetWebAppPipeline-rg", - 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/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/ListAzurePipelinesBySubscription.json -func ExamplePipelinesClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevops.NewPipelinesClient("{subscriptionId}", 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 - } - } -} diff --git a/sdk/resourcemanager/devops/armdevops/ze_generated_example_pipelinetemplatedefinitions_client_test.go b/sdk/resourcemanager/devops/armdevops/ze_generated_example_pipelinetemplatedefinitions_client_test.go deleted file mode 100644 index b5ba1162dbea..000000000000 --- a/sdk/resourcemanager/devops/armdevops/ze_generated_example_pipelinetemplatedefinitions_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 armdevops_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devops/armdevops" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devops/resource-manager/Microsoft.DevOps/preview/2019-07-01-preview/examples/ListPipelineTemplateDefinitions.json -func ExamplePipelineTemplateDefinitionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevops.NewPipelineTemplateDefinitionsClient(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/devops/armdevops/zz_generated_models_serde.go b/sdk/resourcemanager/devops/armdevops/zz_generated_models_serde.go deleted file mode 100644 index 29dbc17df536..000000000000 --- a/sdk/resourcemanager/devops/armdevops/zz_generated_models_serde.go +++ /dev/null @@ -1,82 +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 armdevops - -import ( - "encoding/json" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type Authorization. -func (a Authorization) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "authorizationType", a.AuthorizationType) - populate(objectMap, "parameters", a.Parameters) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type CodeRepository. -func (c CodeRepository) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "authorization", c.Authorization) - populate(objectMap, "defaultBranch", c.DefaultBranch) - populate(objectMap, "id", c.ID) - populate(objectMap, "properties", c.Properties) - populate(objectMap, "repositoryType", c.RepositoryType) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Pipeline. -func (p Pipeline) 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, "tags", p.Tags) - populate(objectMap, "type", p.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type PipelineTemplate. -func (p PipelineTemplate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", p.ID) - populate(objectMap, "parameters", p.Parameters) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type PipelineUpdateParameters. -func (p PipelineUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", p.Tags) - 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, "tags", r.Tags) - populate(objectMap, "type", r.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 - } -} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/CHANGELOG.md b/sdk/resourcemanager/devtestlabs/armdevtestlabs/CHANGELOG.md index 1c224d6b5d00..75a1d9855563 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/CHANGELOG.md +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-28) +### 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/devtestlabs/armdevtestlabs` 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/devtestlabs/armdevtestlabs/README.md b/sdk/resourcemanager/devtestlabs/armdevtestlabs/README.md index 1f12d73b04f0..28985ebfbb46 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/README.md +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/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 Lab 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 Lab 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 := armdevtestlabs.NewPolicySetsClient(, cred, nil) +clientFactory, err := armdevtestlabs.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 := armdevtestlabs.NewPolicySetsClient(, cred, &options) +clientFactory, err := armdevtestlabs.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.NewPolicySetsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_armtemplates_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/armtemplates_client.go similarity index 83% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_armtemplates_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/armtemplates_client.go index 972376d1a4ea..01662e4fb8c5 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_armtemplates_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/armtemplates_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 armdevtestlabs @@ -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" @@ -26,49 +25,41 @@ import ( // ArmTemplatesClient contains the methods for the ArmTemplates group. // Don't use this type directly, use NewArmTemplatesClient() instead. type ArmTemplatesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewArmTemplatesClient creates a new instance of ArmTemplatesClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewArmTemplatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ArmTemplatesClient, 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+".ArmTemplatesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ArmTemplatesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get azure resource manager template. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// artifactSourceName - The name of the artifact source. -// name - The name of the azure resource manager template. -// options - ArmTemplatesClientGetOptions contains the optional parameters for the ArmTemplatesClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - artifactSourceName - The name of the artifact source. +// - name - The name of the azure resource manager template. +// - options - ArmTemplatesClientGetOptions contains the optional parameters for the ArmTemplatesClient.Get method. func (client *ArmTemplatesClient) Get(ctx context.Context, resourceGroupName string, labName string, artifactSourceName string, name string, options *ArmTemplatesClientGetOptions) (ArmTemplatesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, artifactSourceName, name, options) if err != nil { return ArmTemplatesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ArmTemplatesClientGetResponse{}, err } @@ -101,7 +92,7 @@ func (client *ArmTemplatesClient) getCreateRequest(ctx context.Context, resource 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 } @@ -125,12 +116,12 @@ func (client *ArmTemplatesClient) getHandleResponse(resp *http.Response) (ArmTem } // NewListPager - List azure resource manager templates in a given artifact source. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// artifactSourceName - The name of the artifact source. -// options - ArmTemplatesClientListOptions contains the optional parameters for the ArmTemplatesClient.List method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - artifactSourceName - The name of the artifact source. +// - options - ArmTemplatesClientListOptions contains the optional parameters for the ArmTemplatesClient.NewListPager method. func (client *ArmTemplatesClient) NewListPager(resourceGroupName string, labName string, artifactSourceName string, options *ArmTemplatesClientListOptions) *runtime.Pager[ArmTemplatesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ArmTemplatesClientListResponse]{ More: func(page ArmTemplatesClientListResponse) bool { @@ -147,7 +138,7 @@ func (client *ArmTemplatesClient) NewListPager(resourceGroupName string, labName if err != nil { return ArmTemplatesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ArmTemplatesClientListResponse{}, err } @@ -178,7 +169,7 @@ func (client *ArmTemplatesClient) listCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter artifactSourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{artifactSourceName}", url.PathEscape(artifactSourceName)) - 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/devtestlabs/armdevtestlabs/armtemplates_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/armtemplates_client_example_test.go new file mode 100644 index 000000000000..decac6a4213a --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/armtemplates_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 armdevtestlabs_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArmTemplates_List.json +func ExampleArmTemplatesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewArmTemplatesClient().NewListPager("resourceGroupName", "{labName}", "{artifactSourceName}", &armdevtestlabs.ArmTemplatesClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.ArmTemplateList = armdevtestlabs.ArmTemplateList{ + // Value: []*armdevtestlabs.ArmTemplate{ + // { + // Name: to.Ptr("Template1"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/artifactSources/armTemplates"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/artifactSources/{artifactSourceName}/armTemplates/{armTemplateName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "MyTag": to.Ptr("MyValue"), + // }, + // Properties: &armdevtestlabs.ArmTemplateProperties{ + // Contents: map[string]any{ + // "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#", + // "contentVersion": "1.0.0.0", + // "parameters":map[string]any{ + // }, + // "resources":[]any{ + // }, + // "variables":map[string]any{ + // "hostingPlanName": "[toLower(concat(variables('resourceNamePrefix'), '-', take(uniqueString(resourceGroup().id), 6), '-sp'))]", + // "resourceNamePrefix": "[take(uniqueString(resourceGroup().id), 3)]", + // "siteName": "[toLower(concat(variables('resourceNamePrefix'), '-', take(uniqueString(resourceGroup().id), 6)))]", + // }, + // }, + // DisplayName: to.Ptr("Template1"), + // Enabled: to.Ptr(true), + // ParametersValueFilesInfo: []*armdevtestlabs.ParametersValueFileInfo{ + // }, + // Publisher: to.Ptr("Microsoft"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArmTemplates_Get.json +func ExampleArmTemplatesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewArmTemplatesClient().Get(ctx, "resourceGroupName", "{labName}", "{artifactSourceName}", "{armTemplateName}", &armdevtestlabs.ArmTemplatesClientGetOptions{Expand: 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.ArmTemplate = armdevtestlabs.ArmTemplate{ + // Name: to.Ptr("Template1"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/artifactSources/armTemplates"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/artifactSources/{artifactSourceName}/armTemplates/{armTemplateName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "MyTag": to.Ptr("MyValue"), + // }, + // Properties: &armdevtestlabs.ArmTemplateProperties{ + // Contents: map[string]any{ + // "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#", + // "contentVersion": "1.0.0.0", + // "parameters":map[string]any{ + // }, + // "resources":[]any{ + // }, + // "variables":map[string]any{ + // "hostingPlanName": "[toLower(concat(variables('resourceNamePrefix'), '-', take(uniqueString(resourceGroup().id), 6), '-sp'))]", + // "resourceNamePrefix": "[take(uniqueString(resourceGroup().id), 3)]", + // "siteName": "[toLower(concat(variables('resourceNamePrefix'), '-', take(uniqueString(resourceGroup().id), 6)))]", + // }, + // }, + // DisplayName: to.Ptr("Template1"), + // Enabled: to.Ptr(true), + // ParametersValueFilesInfo: []*armdevtestlabs.ParametersValueFileInfo{ + // }, + // Publisher: to.Ptr("Microsoft"), + // }, + // } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_artifacts_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/artifacts_client.go similarity index 84% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_artifacts_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/artifacts_client.go index 09c4dc7f0595..52a4e3fdeff4 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_artifacts_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/artifacts_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 armdevtestlabs @@ -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" @@ -26,31 +25,22 @@ import ( // ArtifactsClient contains the methods for the Artifacts group. // Don't use this type directly, use NewArtifactsClient() instead. type ArtifactsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewArtifactsClient creates a new instance of ArtifactsClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewArtifactsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ArtifactsClient, 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+".ArtifactsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ArtifactsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,20 +48,21 @@ func NewArtifactsClient(subscriptionID string, credential azcore.TokenCredential // GenerateArmTemplate - Generates an ARM template for the given artifact, uploads the required files to a storage account, // and validates the generated artifact. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// artifactSourceName - The name of the artifact source. -// name - The name of the artifact. -// generateArmTemplateRequest - Parameters for generating an ARM template for deploying artifacts. -// options - ArtifactsClientGenerateArmTemplateOptions contains the optional parameters for the ArtifactsClient.GenerateArmTemplate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - artifactSourceName - The name of the artifact source. +// - name - The name of the artifact. +// - generateArmTemplateRequest - Parameters for generating an ARM template for deploying artifacts. +// - options - ArtifactsClientGenerateArmTemplateOptions contains the optional parameters for the ArtifactsClient.GenerateArmTemplate +// method. func (client *ArtifactsClient) GenerateArmTemplate(ctx context.Context, resourceGroupName string, labName string, artifactSourceName string, name string, generateArmTemplateRequest GenerateArmTemplateRequest, options *ArtifactsClientGenerateArmTemplateOptions) (ArtifactsClientGenerateArmTemplateResponse, error) { req, err := client.generateArmTemplateCreateRequest(ctx, resourceGroupName, labName, artifactSourceName, name, generateArmTemplateRequest, options) if err != nil { return ArtifactsClientGenerateArmTemplateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ArtifactsClientGenerateArmTemplateResponse{}, err } @@ -104,7 +95,7 @@ func (client *ArtifactsClient) generateArmTemplateCreateRequest(ctx context.Cont return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 *ArtifactsClient) generateArmTemplateHandleResponse(resp *http.Resp // Get - Get artifact. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// artifactSourceName - The name of the artifact source. -// name - The name of the artifact. -// options - ArtifactsClientGetOptions contains the optional parameters for the ArtifactsClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - artifactSourceName - The name of the artifact source. +// - name - The name of the artifact. +// - options - ArtifactsClientGetOptions contains the optional parameters for the ArtifactsClient.Get method. func (client *ArtifactsClient) Get(ctx context.Context, resourceGroupName string, labName string, artifactSourceName string, name string, options *ArtifactsClientGetOptions) (ArtifactsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, artifactSourceName, name, options) if err != nil { return ArtifactsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ArtifactsClientGetResponse{}, err } @@ -170,7 +162,7 @@ func (client *ArtifactsClient) getCreateRequest(ctx context.Context, resourceGro 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 } @@ -194,12 +186,12 @@ func (client *ArtifactsClient) getHandleResponse(resp *http.Response) (Artifacts } // NewListPager - List artifacts in a given artifact source. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// artifactSourceName - The name of the artifact source. -// options - ArtifactsClientListOptions contains the optional parameters for the ArtifactsClient.List method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - artifactSourceName - The name of the artifact source. +// - options - ArtifactsClientListOptions contains the optional parameters for the ArtifactsClient.NewListPager method. func (client *ArtifactsClient) NewListPager(resourceGroupName string, labName string, artifactSourceName string, options *ArtifactsClientListOptions) *runtime.Pager[ArtifactsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ArtifactsClientListResponse]{ More: func(page ArtifactsClientListResponse) bool { @@ -216,7 +208,7 @@ func (client *ArtifactsClient) NewListPager(resourceGroupName string, labName st if err != nil { return ArtifactsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ArtifactsClientListResponse{}, err } @@ -247,7 +239,7 @@ func (client *ArtifactsClient) listCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter artifactSourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{artifactSourceName}", url.PathEscape(artifactSourceName)) - 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/devtestlabs/armdevtestlabs/artifacts_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/artifacts_client_example_test.go new file mode 100644 index 000000000000..1aa3bb1ddab8 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/artifacts_client_example_test.go @@ -0,0 +1,192 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Artifacts_List.json +func ExampleArtifactsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewArtifactsClient().NewListPager("resourceGroupName", "{labName}", "{artifactSourceName}", &armdevtestlabs.ArtifactsClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.ArtifactList = armdevtestlabs.ArtifactList{ + // Value: []*armdevtestlabs.Artifact{ + // { + // Name: to.Ptr("{artifactName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/artifactSources/artifacts"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/artifactSources/{artifactSourceName}/artifacts/{artifactName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "MyTag": to.Ptr("MyValue"), + // }, + // Properties: &armdevtestlabs.ArtifactProperties{ + // Description: to.Ptr("Sample artifact description."), + // FilePath: to.Ptr("{artifactsPath}/{artifactName}"), + // Parameters: map[string]any{ + // "uri":map[string]any{ + // "type": "string", + // "description": "Sample parameter 1 description.", + // "defaultValue": "https://{labStorageAccount}.blob.core.windows.net/{artifactName}/...", + // "displayName": "Sample Parameter 1", + // }, + // }, + // Publisher: to.Ptr("Microsoft"), + // TargetOsType: to.Ptr("Windows"), + // Title: to.Ptr("Sample Artifact Title"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Artifacts_Get.json +func ExampleArtifactsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewArtifactsClient().Get(ctx, "resourceGroupName", "{labName}", "{artifactSourceName}", "{artifactName}", &armdevtestlabs.ArtifactsClientGetOptions{Expand: 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.Artifact = armdevtestlabs.Artifact{ + // Name: to.Ptr("{artifactName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/artifactSources/artifacts"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/artifactSources/{artifactSourceName}/artifacts/{artifactName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "MyTag": to.Ptr("MyValue"), + // }, + // Properties: &armdevtestlabs.ArtifactProperties{ + // Description: to.Ptr("Sample artifact description."), + // FilePath: to.Ptr("{artifactsPath}/{artifactName}"), + // Parameters: map[string]any{ + // "uri":map[string]any{ + // "type": "string", + // "description": "Sample parameter 1 description.", + // "defaultValue": "https://{labStorageAccount}.blob.core.windows.net/{artifactName}/...", + // "displayName": "Sample Parameter 1", + // }, + // }, + // Publisher: to.Ptr("Microsoft"), + // TargetOsType: to.Ptr("Windows"), + // Title: to.Ptr("Sample Artifact Title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Artifacts_GenerateArmTemplate.json +func ExampleArtifactsClient_GenerateArmTemplate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewArtifactsClient().GenerateArmTemplate(ctx, "resourceGroupName", "{labName}", "{artifactSourceName}", "{artifactName}", armdevtestlabs.GenerateArmTemplateRequest{ + FileUploadOptions: to.Ptr(armdevtestlabs.FileUploadOptionsNone), + Location: to.Ptr("{location}"), + VirtualMachineName: to.Ptr("{vmName}"), + }, 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.ArmTemplateInfo = armdevtestlabs.ArmTemplateInfo{ + // Parameters: map[string]any{ + // "extensionName":map[string]any{ + // "value": "{vmName}/CustomScriptExtension", + // }, + // "location":map[string]any{ + // "value": "{location}", + // }, + // }, + // Template: map[string]any{ + // "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json", + // "contentVersion": "1.0.0.0", + // "parameters":map[string]any{ + // "extensionName":map[string]any{ + // "type": "string", + // }, + // "location":map[string]any{ + // "type": "string", + // }, + // }, + // "resources":[]any{ + // map[string]any{ + // "name": "[parameters('extensionName')]", + // "type": "Microsoft.Compute/virtualMachines/extensions", + // "apiVersion": "2015-06-15", + // "location": "[parameters('location')]", + // "properties":map[string]any{ + // "type": "CustomScriptExtension", + // "autoUpgradeMinorVersion": "true", + // "forceUpdateTag": "15/10/2018 00:00:00 +00:00", + // "protectedSettings":map[string]any{ + // "commandToExecute": "[concat('cd {MsDtlScriptFolder}/scripts && ', variables('_commandToExecute'))]", + // }, + // "publisher": "Microsoft.Compute", + // "settings":map[string]any{ + // "commandToExecute": "", + // "fileUris":[]any{ + // "{MsDtlArtifactFileUris}", + // }, + // }, + // "typeHandlerVersion": "1.9", + // }, + // }, + // }, + // "variables":map[string]any{ + // "_commandToExecute": "{commandToExecute}.", + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_artifactsources_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/artifactsources_client.go similarity index 85% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_artifactsources_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/artifactsources_client.go index c8b5c1ea8246..21cf027f3ce9 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_artifactsources_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/artifactsources_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 armdevtestlabs @@ -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" @@ -26,50 +25,42 @@ import ( // ArtifactSourcesClient contains the methods for the ArtifactSources group. // Don't use this type directly, use NewArtifactSourcesClient() instead. type ArtifactSourcesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewArtifactSourcesClient creates a new instance of ArtifactSourcesClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewArtifactSourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ArtifactSourcesClient, 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+".ArtifactSourcesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ArtifactSourcesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or replace an existing artifact source. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the artifact source. -// artifactSource - Properties of an artifact source. -// options - ArtifactSourcesClientCreateOrUpdateOptions contains the optional parameters for the ArtifactSourcesClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the artifact source. +// - artifactSource - Properties of an artifact source. +// - options - ArtifactSourcesClientCreateOrUpdateOptions contains the optional parameters for the ArtifactSourcesClient.CreateOrUpdate +// method. func (client *ArtifactSourcesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, artifactSource ArtifactSource, options *ArtifactSourcesClientCreateOrUpdateOptions) (ArtifactSourcesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, name, artifactSource, options) if err != nil { return ArtifactSourcesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ArtifactSourcesClientCreateOrUpdateResponse{}, err } @@ -98,7 +89,7 @@ func (client *ArtifactSourcesClient) createOrUpdateCreateRequest(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.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 +111,18 @@ func (client *ArtifactSourcesClient) createOrUpdateHandleResponse(resp *http.Res // Delete - Delete artifact source. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the artifact source. -// options - ArtifactSourcesClientDeleteOptions contains the optional parameters for the ArtifactSourcesClient.Delete method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the artifact source. +// - options - ArtifactSourcesClientDeleteOptions contains the optional parameters for the ArtifactSourcesClient.Delete method. func (client *ArtifactSourcesClient) Delete(ctx context.Context, resourceGroupName string, labName string, name string, options *ArtifactSourcesClientDeleteOptions) (ArtifactSourcesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return ArtifactSourcesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ArtifactSourcesClientDeleteResponse{}, err } @@ -159,7 +151,7 @@ func (client *ArtifactSourcesClient) deleteCreateRequest(ctx context.Context, re 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 } @@ -172,17 +164,18 @@ func (client *ArtifactSourcesClient) deleteCreateRequest(ctx context.Context, re // Get - Get artifact source. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the artifact source. -// options - ArtifactSourcesClientGetOptions contains the optional parameters for the ArtifactSourcesClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the artifact source. +// - options - ArtifactSourcesClientGetOptions contains the optional parameters for the ArtifactSourcesClient.Get method. func (client *ArtifactSourcesClient) Get(ctx context.Context, resourceGroupName string, labName string, name string, options *ArtifactSourcesClientGetOptions) (ArtifactSourcesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return ArtifactSourcesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ArtifactSourcesClientGetResponse{}, err } @@ -211,7 +204,7 @@ func (client *ArtifactSourcesClient) getCreateRequest(ctx context.Context, resou 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 } @@ -235,11 +228,12 @@ func (client *ArtifactSourcesClient) getHandleResponse(resp *http.Response) (Art } // NewListPager - List artifact sources in a given lab. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// options - ArtifactSourcesClientListOptions contains the optional parameters for the ArtifactSourcesClient.List method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - options - ArtifactSourcesClientListOptions contains the optional parameters for the ArtifactSourcesClient.NewListPager +// method. func (client *ArtifactSourcesClient) NewListPager(resourceGroupName string, labName string, options *ArtifactSourcesClientListOptions) *runtime.Pager[ArtifactSourcesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ArtifactSourcesClientListResponse]{ More: func(page ArtifactSourcesClientListResponse) bool { @@ -256,7 +250,7 @@ func (client *ArtifactSourcesClient) NewListPager(resourceGroupName string, labN if err != nil { return ArtifactSourcesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ArtifactSourcesClientListResponse{}, err } @@ -283,7 +277,7 @@ func (client *ArtifactSourcesClient) listCreateRequest(ctx context.Context, reso return nil, errors.New("parameter labName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) - 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 } @@ -317,18 +311,19 @@ func (client *ArtifactSourcesClient) listHandleResponse(resp *http.Response) (Ar // Update - Allows modifying tags of artifact sources. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the artifact source. -// artifactSource - Properties of an artifact source. -// options - ArtifactSourcesClientUpdateOptions contains the optional parameters for the ArtifactSourcesClient.Update method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the artifact source. +// - artifactSource - Properties of an artifact source. +// - options - ArtifactSourcesClientUpdateOptions contains the optional parameters for the ArtifactSourcesClient.Update method. func (client *ArtifactSourcesClient) Update(ctx context.Context, resourceGroupName string, labName string, name string, artifactSource ArtifactSourceFragment, options *ArtifactSourcesClientUpdateOptions) (ArtifactSourcesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, name, artifactSource, options) if err != nil { return ArtifactSourcesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ArtifactSourcesClientUpdateResponse{}, err } @@ -357,7 +352,7 @@ func (client *ArtifactSourcesClient) updateCreateRequest(ctx context.Context, re return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/artifactsources_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/artifactsources_client_example_test.go new file mode 100644 index 000000000000..7982e5959fa7 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/artifactsources_client_example_test.go @@ -0,0 +1,234 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_List.json +func ExampleArtifactSourcesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewArtifactSourcesClient().NewListPager("resourceGroupName", "{labName}", &armdevtestlabs.ArtifactSourcesClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.ArtifactSourceList = armdevtestlabs.ArtifactSourceList{ + // Value: []*armdevtestlabs.ArtifactSource{ + // { + // Name: to.Ptr("{artifactSourceName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/artifactsources"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ArtifactSourceProperties{ + // ArmTemplateFolderPath: to.Ptr("{armTemplateFolderPath}"), + // BranchRef: to.Ptr("{branchRef}"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-16T16:53:02.4830866-07:00"); return t}()), + // DisplayName: to.Ptr("{displayName}"), + // FolderPath: to.Ptr("{folderPath}"), + // ProvisioningState: to.Ptr("Succeeded"), + // SecurityToken: to.Ptr("{securityToken}"), + // SourceType: to.Ptr(armdevtestlabs.SourceControlType("{VsoGit|GitHub|StorageAccount}")), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // URI: to.Ptr("{artifactSourceUri}"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_Get.json +func ExampleArtifactSourcesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewArtifactSourcesClient().Get(ctx, "resourceGroupName", "{labName}", "{artifactSourceName}", &armdevtestlabs.ArtifactSourcesClientGetOptions{Expand: 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.ArtifactSource = armdevtestlabs.ArtifactSource{ + // Name: to.Ptr("{artifactSourceName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/artifactsources"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ArtifactSourceProperties{ + // ArmTemplateFolderPath: to.Ptr("{armTemplateFolderPath}"), + // BranchRef: to.Ptr("{branchRef}"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-16T16:53:02.4830866-07:00"); return t}()), + // DisplayName: to.Ptr("{displayName}"), + // FolderPath: to.Ptr("{folderPath}"), + // ProvisioningState: to.Ptr("Succeeded"), + // SecurityToken: to.Ptr("{securityToken}"), + // SourceType: to.Ptr(armdevtestlabs.SourceControlType("{VsoGit|GitHub|StorageAccount}")), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // URI: to.Ptr("{artifactSourceUri}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_CreateOrUpdate.json +func ExampleArtifactSourcesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewArtifactSourcesClient().CreateOrUpdate(ctx, "resourceGroupName", "{labName}", "{artifactSourceName}", armdevtestlabs.ArtifactSource{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + Properties: &armdevtestlabs.ArtifactSourceProperties{ + ArmTemplateFolderPath: to.Ptr("{armTemplateFolderPath}"), + BranchRef: to.Ptr("{branchRef}"), + DisplayName: to.Ptr("{displayName}"), + FolderPath: to.Ptr("{folderPath}"), + SecurityToken: to.Ptr("{securityToken}"), + SourceType: to.Ptr(armdevtestlabs.SourceControlType("{VsoGit|GitHub|StorageAccount}")), + Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + URI: to.Ptr("{artifactSourceUri}"), + }, + }, 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.ArtifactSource = armdevtestlabs.ArtifactSource{ + // Name: to.Ptr("{artifactSourceName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/artifactsources"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ArtifactSourceProperties{ + // ArmTemplateFolderPath: to.Ptr("{armTemplateFolderPath}"), + // BranchRef: to.Ptr("{branchRef}"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-16T16:53:02.4830866-07:00"); return t}()), + // DisplayName: to.Ptr("{displayName}"), + // FolderPath: to.Ptr("{folderPath}"), + // ProvisioningState: to.Ptr("Succeeded"), + // SecurityToken: to.Ptr("{securityToken}"), + // SourceType: to.Ptr(armdevtestlabs.SourceControlType("{VsoGit|GitHub|StorageAccount}")), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // URI: to.Ptr("{artifactSourceUri}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_Delete.json +func ExampleArtifactSourcesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewArtifactSourcesClient().Delete(ctx, "resourceGroupName", "{labName}", "{artifactSourceName}", 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_Update.json +func ExampleArtifactSourcesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewArtifactSourcesClient().Update(ctx, "resourceGroupName", "{labName}", "{artifactSourceName}", armdevtestlabs.ArtifactSourceFragment{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + }, 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.ArtifactSource = armdevtestlabs.ArtifactSource{ + // Name: to.Ptr("{artifactSourceName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/artifactsources"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ArtifactSourceProperties{ + // ArmTemplateFolderPath: to.Ptr("{armTemplateFolderPath}"), + // BranchRef: to.Ptr("{branchRef}"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-16T16:53:02.4830866-07:00"); return t}()), + // DisplayName: to.Ptr("{displayName}"), + // FolderPath: to.Ptr("{folderPath}"), + // ProvisioningState: to.Ptr("Succeeded"), + // SecurityToken: to.Ptr("{securityToken}"), + // SourceType: to.Ptr(armdevtestlabs.SourceControlType("{VsoGit|GitHub|StorageAccount}")), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // URI: to.Ptr("{artifactSourceUri}"), + // }, + // } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/autorest.md b/sdk/resourcemanager/devtestlabs/armdevtestlabs/autorest.md index 288146e0a692..034a82264e03 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/autorest.md +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/autorest.md @@ -8,5 +8,5 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/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/devtestlabs/armdevtestlabs/client_factory.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/client_factory.go new file mode 100644 index 000000000000..c33e121969fa --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/client_factory.go @@ -0,0 +1,164 @@ +//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 armdevtestlabs + +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. +// - 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) NewProviderOperationsClient() *ProviderOperationsClient { + subClient, _ := NewProviderOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLabsClient() *LabsClient { + subClient, _ := NewLabsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewGlobalSchedulesClient() *GlobalSchedulesClient { + subClient, _ := NewGlobalSchedulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewArtifactSourcesClient() *ArtifactSourcesClient { + subClient, _ := NewArtifactSourcesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewArmTemplatesClient() *ArmTemplatesClient { + subClient, _ := NewArmTemplatesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewArtifactsClient() *ArtifactsClient { + subClient, _ := NewArtifactsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCostsClient() *CostsClient { + subClient, _ := NewCostsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCustomImagesClient() *CustomImagesClient { + subClient, _ := NewCustomImagesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewFormulasClient() *FormulasClient { + subClient, _ := NewFormulasClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewGalleryImagesClient() *GalleryImagesClient { + subClient, _ := NewGalleryImagesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewNotificationChannelsClient() *NotificationChannelsClient { + subClient, _ := NewNotificationChannelsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPolicySetsClient() *PolicySetsClient { + subClient, _ := NewPolicySetsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPoliciesClient() *PoliciesClient { + subClient, _ := NewPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSchedulesClient() *SchedulesClient { + subClient, _ := NewSchedulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewServiceRunnersClient() *ServiceRunnersClient { + subClient, _ := NewServiceRunnersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewUsersClient() *UsersClient { + subClient, _ := NewUsersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDisksClient() *DisksClient { + subClient, _ := NewDisksClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewEnvironmentsClient() *EnvironmentsClient { + subClient, _ := NewEnvironmentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSecretsClient() *SecretsClient { + subClient, _ := NewSecretsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewServiceFabricsClient() *ServiceFabricsClient { + subClient, _ := NewServiceFabricsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewServiceFabricSchedulesClient() *ServiceFabricSchedulesClient { + subClient, _ := NewServiceFabricSchedulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVirtualMachinesClient() *VirtualMachinesClient { + subClient, _ := NewVirtualMachinesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVirtualMachineSchedulesClient() *VirtualMachineSchedulesClient { + subClient, _ := NewVirtualMachineSchedulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVirtualNetworksClient() *VirtualNetworksClient { + subClient, _ := NewVirtualNetworksClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_constants.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/constants.go similarity index 99% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_constants.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/constants.go index 4849c50f60f1..120b80741871 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_constants.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/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 armdevtestlabs const ( moduleName = "armdevtestlabs" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // CostThresholdStatus - Indicates whether this threshold will be displayed on cost charts. diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_costs_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/costs_client.go similarity index 82% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_costs_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/costs_client.go index f312c04ce8f6..54c14298b4f5 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_costs_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/costs_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 armdevtestlabs @@ -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 ( // CostsClient contains the methods for the Costs group. // Don't use this type directly, use NewCostsClient() instead. type CostsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCostsClient creates a new instance of CostsClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCostsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CostsClient, 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+".CostsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CostsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or replace an existing cost. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the cost. -// labCost - A cost item. -// options - CostsClientCreateOrUpdateOptions contains the optional parameters for the CostsClient.CreateOrUpdate method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the cost. +// - labCost - A cost item. +// - options - CostsClientCreateOrUpdateOptions contains the optional parameters for the CostsClient.CreateOrUpdate method. func (client *CostsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, labCost LabCost, options *CostsClientCreateOrUpdateOptions) (CostsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, name, labCost, options) if err != nil { return CostsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CostsClientCreateOrUpdateResponse{}, err } @@ -96,7 +87,7 @@ func (client *CostsClient) createOrUpdateCreateRequest(ctx context.Context, reso 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 } @@ -118,17 +109,18 @@ func (client *CostsClient) createOrUpdateHandleResponse(resp *http.Response) (Co // Get - Get cost. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the cost. -// options - CostsClientGetOptions contains the optional parameters for the CostsClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the cost. +// - options - CostsClientGetOptions contains the optional parameters for the CostsClient.Get method. func (client *CostsClient) Get(ctx context.Context, resourceGroupName string, labName string, name string, options *CostsClientGetOptions) (CostsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return CostsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CostsClientGetResponse{}, err } @@ -157,7 +149,7 @@ func (client *CostsClient) getCreateRequest(ctx context.Context, resourceGroupNa 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 } diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/costs_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/costs_client_example_test.go new file mode 100644 index 000000000000..08d910949eb9 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/costs_client_example_test.go @@ -0,0 +1,241 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Costs_Get.json +func ExampleCostsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCostsClient().Get(ctx, "resourceGroupName", "{labName}", "targetCost", &armdevtestlabs.CostsClientGetOptions{Expand: 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.LabCost = armdevtestlabs.LabCost{ + // Properties: &armdevtestlabs.LabCostProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-23T22:43:54.7253204+00:00"); return t}()), + // CurrencyCode: to.Ptr("USD"), + // EndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-31T23:59:59Z"); return t}()), + // ProvisioningState: to.Ptr("Succeeded"), + // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T00:00:00Z"); return t}()), + // TargetCost: &armdevtestlabs.TargetCostProperties{ + // CostThresholds: []*armdevtestlabs.CostThresholdProperties{ + // { + // DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // NotificationSent: to.Ptr("0001-01-01T00:00:00.0000000"), + // PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ + // ThresholdValue: to.Ptr[float64](25), + // }, + // SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // }, + // { + // DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusEnabled), + // NotificationSent: to.Ptr("0001-01-01T00:00:00.0000000"), + // PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ + // ThresholdValue: to.Ptr[float64](50), + // }, + // SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusEnabled), + // ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // }, + // { + // DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // NotificationSent: to.Ptr("0001-01-01T00:00:00.0000000"), + // PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ + // ThresholdValue: to.Ptr[float64](75), + // }, + // SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // }, + // { + // DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // NotificationSent: to.Ptr("0001-01-01T00:00:00.0000000"), + // PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ + // ThresholdValue: to.Ptr[float64](100), + // }, + // SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // }, + // { + // DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // NotificationSent: to.Ptr("0001-01-01T00:00:00.0000000"), + // PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ + // ThresholdValue: to.Ptr[float64](125), + // }, + // SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // }}, + // CycleEndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-31T23:59:59+00:00"); return t}()), + // CycleStartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T00:00:00+00:00"); return t}()), + // CycleType: to.Ptr(armdevtestlabs.ReportingCycleTypeCalendarMonth), + // Status: to.Ptr(armdevtestlabs.TargetCostStatusEnabled), + // Target: to.Ptr[int32](100), + // }, + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Costs_CreateOrUpdate.json +func ExampleCostsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCostsClient().CreateOrUpdate(ctx, "resourceGroupName", "{labName}", "targetCost", armdevtestlabs.LabCost{ + Properties: &armdevtestlabs.LabCostProperties{ + CurrencyCode: to.Ptr("USD"), + EndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-31T23:59:59Z"); return t }()), + StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T00:00:00Z"); return t }()), + TargetCost: &armdevtestlabs.TargetCostProperties{ + CostThresholds: []*armdevtestlabs.CostThresholdProperties{ + { + DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ + ThresholdValue: to.Ptr[float64](25), + }, + SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000001"), + }, + { + DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusEnabled), + PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ + ThresholdValue: to.Ptr[float64](50), + }, + SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusEnabled), + ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000002"), + }, + { + DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ + ThresholdValue: to.Ptr[float64](75), + }, + SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000003"), + }, + { + DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ + ThresholdValue: to.Ptr[float64](100), + }, + SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000004"), + }, + { + DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ + ThresholdValue: to.Ptr[float64](125), + }, + SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000005"), + }}, + CycleEndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-31T00:00:00.000Z"); return t }()), + CycleStartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T00:00:00.000Z"); return t }()), + CycleType: to.Ptr(armdevtestlabs.ReportingCycleTypeCalendarMonth), + Status: to.Ptr(armdevtestlabs.TargetCostStatusEnabled), + Target: to.Ptr[int32](100), + }, + }, + }, 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.LabCost = armdevtestlabs.LabCost{ + // Properties: &armdevtestlabs.LabCostProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-23T22:43:54.7253204+00:00"); return t}()), + // CurrencyCode: to.Ptr("USD"), + // EndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-31T23:59:59Z"); return t}()), + // ProvisioningState: to.Ptr("Succeeded"), + // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T00:00:00Z"); return t}()), + // TargetCost: &armdevtestlabs.TargetCostProperties{ + // CostThresholds: []*armdevtestlabs.CostThresholdProperties{ + // { + // DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // NotificationSent: to.Ptr("0001-01-01T00:00:00.0000000"), + // PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ + // ThresholdValue: to.Ptr[float64](25), + // }, + // SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // }, + // { + // DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusEnabled), + // NotificationSent: to.Ptr("0001-01-01T00:00:00.0000000"), + // PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ + // ThresholdValue: to.Ptr[float64](50), + // }, + // SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusEnabled), + // ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // }, + // { + // DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // NotificationSent: to.Ptr("0001-01-01T00:00:00.0000000"), + // PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ + // ThresholdValue: to.Ptr[float64](75), + // }, + // SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // }, + // { + // DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // NotificationSent: to.Ptr("0001-01-01T00:00:00.0000000"), + // PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ + // ThresholdValue: to.Ptr[float64](100), + // }, + // SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // }, + // { + // DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // NotificationSent: to.Ptr("0001-01-01T00:00:00.0000000"), + // PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ + // ThresholdValue: to.Ptr[float64](125), + // }, + // SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), + // ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // }}, + // CycleEndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-31T23:59:59+00:00"); return t}()), + // CycleStartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T00:00:00+00:00"); return t}()), + // CycleType: to.Ptr(armdevtestlabs.ReportingCycleTypeCalendarMonth), + // Status: to.Ptr(armdevtestlabs.TargetCostStatusEnabled), + // Target: to.Ptr[int32](100), + // }, + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_customimages_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/customimages_client.go similarity index 85% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_customimages_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/customimages_client.go index 187caa4bda76..fb75a004e95a 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_customimages_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/customimages_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 armdevtestlabs @@ -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" @@ -26,65 +25,58 @@ import ( // CustomImagesClient contains the methods for the CustomImages group. // Don't use this type directly, use NewCustomImagesClient() instead. type CustomImagesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCustomImagesClient creates a new instance of CustomImagesClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCustomImagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CustomImagesClient, 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+".CustomImagesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CustomImagesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create or replace an existing custom image. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the custom image. -// customImage - A custom image. -// options - CustomImagesClientBeginCreateOrUpdateOptions contains the optional parameters for the CustomImagesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the custom image. +// - customImage - A custom image. +// - options - CustomImagesClientBeginCreateOrUpdateOptions contains the optional parameters for the CustomImagesClient.BeginCreateOrUpdate +// method. func (client *CustomImagesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, customImage CustomImage, options *CustomImagesClientBeginCreateOrUpdateOptions) (*runtime.Poller[CustomImagesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, labName, name, customImage, options) if err != nil { return nil, err } - return runtime.NewPoller[CustomImagesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[CustomImagesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[CustomImagesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CustomImagesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or replace an existing custom image. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *CustomImagesClient) createOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, customImage CustomImage, options *CustomImagesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, name, customImage, 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 +105,7 @@ func (client *CustomImagesClient) createOrUpdateCreateRequest(ctx context.Contex 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 } @@ -126,33 +118,35 @@ func (client *CustomImagesClient) createOrUpdateCreateRequest(ctx context.Contex // BeginDelete - Delete custom image. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the custom image. -// options - CustomImagesClientBeginDeleteOptions contains the optional parameters for the CustomImagesClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the custom image. +// - options - CustomImagesClientBeginDeleteOptions contains the optional parameters for the CustomImagesClient.BeginDelete +// method. func (client *CustomImagesClient) BeginDelete(ctx context.Context, resourceGroupName string, labName string, name string, options *CustomImagesClientBeginDeleteOptions) (*runtime.Poller[CustomImagesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, labName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[CustomImagesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[CustomImagesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[CustomImagesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CustomImagesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete custom image. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *CustomImagesClient) deleteOperation(ctx context.Context, resourceGroupName string, labName string, name string, options *CustomImagesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, name, 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 } @@ -181,7 +175,7 @@ func (client *CustomImagesClient) deleteCreateRequest(ctx context.Context, resou 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 } @@ -194,17 +188,18 @@ func (client *CustomImagesClient) deleteCreateRequest(ctx context.Context, resou // Get - Get custom image. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the custom image. -// options - CustomImagesClientGetOptions contains the optional parameters for the CustomImagesClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the custom image. +// - options - CustomImagesClientGetOptions contains the optional parameters for the CustomImagesClient.Get method. func (client *CustomImagesClient) Get(ctx context.Context, resourceGroupName string, labName string, name string, options *CustomImagesClientGetOptions) (CustomImagesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return CustomImagesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomImagesClientGetResponse{}, err } @@ -233,7 +228,7 @@ func (client *CustomImagesClient) getCreateRequest(ctx context.Context, resource 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 } @@ -257,11 +252,11 @@ func (client *CustomImagesClient) getHandleResponse(resp *http.Response) (Custom } // NewListPager - List custom images in a given lab. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// options - CustomImagesClientListOptions contains the optional parameters for the CustomImagesClient.List method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - options - CustomImagesClientListOptions contains the optional parameters for the CustomImagesClient.NewListPager method. func (client *CustomImagesClient) NewListPager(resourceGroupName string, labName string, options *CustomImagesClientListOptions) *runtime.Pager[CustomImagesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[CustomImagesClientListResponse]{ More: func(page CustomImagesClientListResponse) bool { @@ -278,7 +273,7 @@ func (client *CustomImagesClient) NewListPager(resourceGroupName string, labName if err != nil { return CustomImagesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomImagesClientListResponse{}, err } @@ -305,7 +300,7 @@ func (client *CustomImagesClient) listCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter labName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) - 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 } @@ -339,18 +334,19 @@ func (client *CustomImagesClient) listHandleResponse(resp *http.Response) (Custo // Update - Allows modifying tags of custom images. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the custom image. -// customImage - A custom image. -// options - CustomImagesClientUpdateOptions contains the optional parameters for the CustomImagesClient.Update method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the custom image. +// - customImage - A custom image. +// - options - CustomImagesClientUpdateOptions contains the optional parameters for the CustomImagesClient.Update method. func (client *CustomImagesClient) Update(ctx context.Context, resourceGroupName string, labName string, name string, customImage CustomImageFragment, options *CustomImagesClientUpdateOptions) (CustomImagesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, name, customImage, options) if err != nil { return CustomImagesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomImagesClientUpdateResponse{}, err } @@ -379,7 +375,7 @@ func (client *CustomImagesClient) updateCreateRequest(ctx context.Context, resou return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/customimages_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/customimages_client_example_test.go new file mode 100644 index 000000000000..16093ea4321a --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/customimages_client_example_test.go @@ -0,0 +1,238 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_List.json +func ExampleCustomImagesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCustomImagesClient().NewListPager("resourceGroupName", "{labName}", &armdevtestlabs.CustomImagesClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.CustomImageList = armdevtestlabs.CustomImageList{ + // Value: []*armdevtestlabs.CustomImage{ + // { + // Name: to.Ptr("{customImageName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/customImages"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/customimages/{customImageName}"), + // Location: to.Ptr("{location}"), + // Properties: &armdevtestlabs.CustomImageProperties{ + // Description: to.Ptr("My Custom Image"), + // Author: to.Ptr("{authorName}"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-10T09:59:28.7985144+00:00"); return t}()), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // VM: &armdevtestlabs.CustomImagePropertiesFromVM{ + // LinuxOsInfo: &armdevtestlabs.LinuxOsInfo{ + // LinuxOsState: to.Ptr(armdevtestlabs.LinuxOsStateNonDeprovisioned), + // }, + // SourceVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_Get.json +func ExampleCustomImagesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCustomImagesClient().Get(ctx, "resourceGroupName", "{labName}", "{customImageName}", &armdevtestlabs.CustomImagesClientGetOptions{Expand: 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.CustomImage = armdevtestlabs.CustomImage{ + // Name: to.Ptr("{customImageName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/customImages"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/customimages/{customImageName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.CustomImageProperties{ + // Description: to.Ptr("My Custom Image"), + // Author: to.Ptr("{authorName}"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-10T09:59:28.7985144+00:00"); return t}()), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // VM: &armdevtestlabs.CustomImagePropertiesFromVM{ + // LinuxOsInfo: &armdevtestlabs.LinuxOsInfo{ + // LinuxOsState: to.Ptr(armdevtestlabs.LinuxOsStateNonDeprovisioned), + // }, + // SourceVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_CreateOrUpdate.json +func ExampleCustomImagesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCustomImagesClient().BeginCreateOrUpdate(ctx, "resourceGroupName", "{labName}", "{customImageName}", armdevtestlabs.CustomImage{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + Properties: &armdevtestlabs.CustomImageProperties{ + Description: to.Ptr("My Custom Image"), + VM: &armdevtestlabs.CustomImagePropertiesFromVM{ + LinuxOsInfo: &armdevtestlabs.LinuxOsInfo{ + LinuxOsState: to.Ptr(armdevtestlabs.LinuxOsStateNonDeprovisioned), + }, + SourceVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), + }, + }, + }, 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.CustomImage = armdevtestlabs.CustomImage{ + // Name: to.Ptr("{customImageName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/customImages"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/customimages/{customImageName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.CustomImageProperties{ + // Description: to.Ptr("My Custom Image"), + // Author: to.Ptr("{authorName}"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-10T09:59:28.7985144+00:00"); return t}()), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // VM: &armdevtestlabs.CustomImagePropertiesFromVM{ + // LinuxOsInfo: &armdevtestlabs.LinuxOsInfo{ + // LinuxOsState: to.Ptr(armdevtestlabs.LinuxOsStateNonDeprovisioned), + // }, + // SourceVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_Delete.json +func ExampleCustomImagesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCustomImagesClient().BeginDelete(ctx, "resourceGroupName", "{labName}", "{customImageName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_Update.json +func ExampleCustomImagesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCustomImagesClient().Update(ctx, "resourceGroupName", "{labName}", "{customImageName}", armdevtestlabs.CustomImageFragment{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue2"), + }, + }, 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.CustomImage = armdevtestlabs.CustomImage{ + // Name: to.Ptr("{customImageName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/customImages"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/customimages/{customImageName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue2"), + // }, + // Properties: &armdevtestlabs.CustomImageProperties{ + // Description: to.Ptr("My Custom Image"), + // Author: to.Ptr("{authorName}"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-10T09:59:28.7985144+00:00"); return t}()), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // VM: &armdevtestlabs.CustomImagePropertiesFromVM{ + // LinuxOsInfo: &armdevtestlabs.LinuxOsInfo{ + // LinuxOsState: to.Ptr(armdevtestlabs.LinuxOsStateNonDeprovisioned), + // }, + // SourceVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_disks_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/disks_client.go similarity index 86% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_disks_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/disks_client.go index c98c631a5523..b35e72dd0f1b 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_disks_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/disks_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 armdevtestlabs @@ -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" @@ -26,65 +25,58 @@ import ( // DisksClient contains the methods for the Disks group. // Don't use this type directly, use NewDisksClient() instead. type DisksClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDisksClient creates a new instance of DisksClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewDisksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DisksClient, 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+".DisksClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DisksClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginAttach - Attach and create the lease of the disk to the virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the disk. -// attachDiskProperties - Properties of the disk to attach. -// options - DisksClientBeginAttachOptions contains the optional parameters for the DisksClient.BeginAttach method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the disk. +// - attachDiskProperties - Properties of the disk to attach. +// - options - DisksClientBeginAttachOptions contains the optional parameters for the DisksClient.BeginAttach method. func (client *DisksClient) BeginAttach(ctx context.Context, resourceGroupName string, labName string, userName string, name string, attachDiskProperties AttachDiskProperties, options *DisksClientBeginAttachOptions) (*runtime.Poller[DisksClientAttachResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.attach(ctx, resourceGroupName, labName, userName, name, attachDiskProperties, options) if err != nil { return nil, err } - return runtime.NewPoller[DisksClientAttachResponse](resp, client.pl, nil) + return runtime.NewPoller[DisksClientAttachResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DisksClientAttachResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DisksClientAttachResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Attach - Attach and create the lease of the disk to the virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *DisksClient) attach(ctx context.Context, resourceGroupName string, labName string, userName string, name string, attachDiskProperties AttachDiskProperties, options *DisksClientBeginAttachOptions) (*http.Response, error) { req, err := client.attachCreateRequest(ctx, resourceGroupName, labName, userName, name, attachDiskProperties, 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 +109,7 @@ func (client *DisksClient) attachCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -130,35 +122,37 @@ func (client *DisksClient) attachCreateRequest(ctx context.Context, resourceGrou // BeginCreateOrUpdate - Create or replace an existing disk. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the disk. -// disk - A Disk. -// options - DisksClientBeginCreateOrUpdateOptions contains the optional parameters for the DisksClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the disk. +// - disk - A Disk. +// - options - DisksClientBeginCreateOrUpdateOptions contains the optional parameters for the DisksClient.BeginCreateOrUpdate +// method. func (client *DisksClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, userName string, name string, disk Disk, options *DisksClientBeginCreateOrUpdateOptions) (*runtime.Poller[DisksClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, labName, userName, name, disk, options) if err != nil { return nil, err } - return runtime.NewPoller[DisksClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[DisksClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DisksClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DisksClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or replace an existing disk. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *DisksClient) createOrUpdate(ctx context.Context, resourceGroupName string, labName string, userName string, name string, disk Disk, options *DisksClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, userName, name, disk, 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 } @@ -191,7 +185,7 @@ func (client *DisksClient) createOrUpdateCreateRequest(ctx context.Context, reso 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 } @@ -204,33 +198,35 @@ func (client *DisksClient) createOrUpdateCreateRequest(ctx context.Context, reso // BeginDelete - Delete disk. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the disk. -// options - DisksClientBeginDeleteOptions contains the optional parameters for the DisksClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the disk. +// - options - DisksClientBeginDeleteOptions contains the optional parameters for the DisksClient.BeginDelete method. func (client *DisksClient) BeginDelete(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *DisksClientBeginDeleteOptions) (*runtime.Poller[DisksClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, labName, userName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[DisksClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[DisksClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DisksClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DisksClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete disk. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *DisksClient) deleteOperation(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *DisksClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, userName, name, 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 } @@ -263,7 +259,7 @@ func (client *DisksClient) deleteCreateRequest(ctx context.Context, resourceGrou 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 } @@ -277,34 +273,36 @@ func (client *DisksClient) deleteCreateRequest(ctx context.Context, resourceGrou // BeginDetach - Detach and break the lease of the disk attached to the virtual machine. This operation can take a while to // complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the disk. -// detachDiskProperties - Properties of the disk to detach. -// options - DisksClientBeginDetachOptions contains the optional parameters for the DisksClient.BeginDetach method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the disk. +// - detachDiskProperties - Properties of the disk to detach. +// - options - DisksClientBeginDetachOptions contains the optional parameters for the DisksClient.BeginDetach method. func (client *DisksClient) BeginDetach(ctx context.Context, resourceGroupName string, labName string, userName string, name string, detachDiskProperties DetachDiskProperties, options *DisksClientBeginDetachOptions) (*runtime.Poller[DisksClientDetachResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.detach(ctx, resourceGroupName, labName, userName, name, detachDiskProperties, options) if err != nil { return nil, err } - return runtime.NewPoller[DisksClientDetachResponse](resp, client.pl, nil) + return runtime.NewPoller[DisksClientDetachResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DisksClientDetachResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DisksClientDetachResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Detach - Detach and break the lease of the disk attached to the virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *DisksClient) detach(ctx context.Context, resourceGroupName string, labName string, userName string, name string, detachDiskProperties DetachDiskProperties, options *DisksClientBeginDetachOptions) (*http.Response, error) { req, err := client.detachCreateRequest(ctx, resourceGroupName, labName, userName, name, detachDiskProperties, 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 } @@ -337,7 +335,7 @@ func (client *DisksClient) detachCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -350,18 +348,19 @@ func (client *DisksClient) detachCreateRequest(ctx context.Context, resourceGrou // Get - Get disk. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the disk. -// options - DisksClientGetOptions contains the optional parameters for the DisksClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the disk. +// - options - DisksClientGetOptions contains the optional parameters for the DisksClient.Get method. func (client *DisksClient) Get(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *DisksClientGetOptions) (DisksClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, userName, name, options) if err != nil { return DisksClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DisksClientGetResponse{}, err } @@ -394,7 +393,7 @@ func (client *DisksClient) getCreateRequest(ctx context.Context, resourceGroupNa 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 } @@ -418,12 +417,12 @@ func (client *DisksClient) getHandleResponse(resp *http.Response) (DisksClientGe } // NewListPager - List disks in a given user profile. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// options - DisksClientListOptions contains the optional parameters for the DisksClient.List method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - options - DisksClientListOptions contains the optional parameters for the DisksClient.NewListPager method. func (client *DisksClient) NewListPager(resourceGroupName string, labName string, userName string, options *DisksClientListOptions) *runtime.Pager[DisksClientListResponse] { return runtime.NewPager(runtime.PagingHandler[DisksClientListResponse]{ More: func(page DisksClientListResponse) bool { @@ -440,7 +439,7 @@ func (client *DisksClient) NewListPager(resourceGroupName string, labName string if err != nil { return DisksClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DisksClientListResponse{}, err } @@ -471,7 +470,7 @@ func (client *DisksClient) listCreateRequest(ctx context.Context, resourceGroupN return nil, errors.New("parameter userName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{userName}", url.PathEscape(userName)) - 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 } @@ -505,19 +504,20 @@ func (client *DisksClient) listHandleResponse(resp *http.Response) (DisksClientL // Update - Allows modifying tags of disks. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the disk. -// disk - A Disk. -// options - DisksClientUpdateOptions contains the optional parameters for the DisksClient.Update method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the disk. +// - disk - A Disk. +// - options - DisksClientUpdateOptions contains the optional parameters for the DisksClient.Update method. func (client *DisksClient) Update(ctx context.Context, resourceGroupName string, labName string, userName string, name string, disk DiskFragment, options *DisksClientUpdateOptions) (DisksClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, userName, name, disk, options) if err != nil { return DisksClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DisksClientUpdateResponse{}, err } @@ -550,7 +550,7 @@ func (client *DisksClient) updateCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/disks_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/disks_client_example_test.go new file mode 100644 index 000000000000..a8de1db5d752 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/disks_client_example_test.go @@ -0,0 +1,257 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_List.json +func ExampleDisksClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDisksClient().NewListPager("resourceGroupName", "{labName}", "@me", &armdevtestlabs.DisksClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.DiskList = armdevtestlabs.DiskList{ + // Value: []*armdevtestlabs.Disk{ + // { + // Name: to.Ptr("{diskName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/disks"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{userId}/disks/{diskName}"), + // Properties: &armdevtestlabs.DiskProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-04T20:27:32.1445632+00:00"); return t}()), + // DiskSizeGiB: to.Ptr[int32](1023), + // DiskType: to.Ptr(armdevtestlabs.StorageTypeStandard), + // DiskURI: to.Ptr(""), + // HostCaching: to.Ptr("None"), + // LeasedByLabVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/vmName"), + // ManagedDiskID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.compute/disks/{diskName}"), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("9bf098d1-1b64-41a5-aa05-286767074a0b"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_Get.json +func ExampleDisksClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDisksClient().Get(ctx, "resourceGroupName", "{labName}", "@me", "{diskName}", &armdevtestlabs.DisksClientGetOptions{Expand: 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.Disk = armdevtestlabs.Disk{ + // Name: to.Ptr("{diskName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/disks"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{userId}/disks/{diskName}"), + // Properties: &armdevtestlabs.DiskProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-04T20:27:32.1445632+00:00"); return t}()), + // DiskSizeGiB: to.Ptr[int32](1023), + // DiskType: to.Ptr(armdevtestlabs.StorageTypeStandard), + // DiskURI: to.Ptr(""), + // HostCaching: to.Ptr("None"), + // LeasedByLabVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/vmName"), + // ManagedDiskID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.compute/disks/{diskName}"), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("9bf098d1-1b64-41a5-aa05-286767074a0b"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_CreateOrUpdate.json +func ExampleDisksClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "resourceGroupName", "{labName}", "{userId}", "{diskName}", armdevtestlabs.Disk{ + Properties: &armdevtestlabs.DiskProperties{ + DiskSizeGiB: to.Ptr[int32](1023), + DiskType: to.Ptr(armdevtestlabs.StorageTypeStandard), + LeasedByLabVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/vmName"), + }, + }, 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.Disk = armdevtestlabs.Disk{ + // Name: to.Ptr("{diskName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/disks"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/l{labName}/users/{userId}/disks/{diskName}"), + // Properties: &armdevtestlabs.DiskProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-04T20:21:02.0182357+00:00"); return t}()), + // DiskSizeGiB: to.Ptr[int32](1023), + // DiskType: to.Ptr(armdevtestlabs.StorageTypeStandard), + // DiskURI: to.Ptr(""), + // HostCaching: to.Ptr("None"), + // LeasedByLabVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/vmName"), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("b7183ac5-1097-4513-b597-4d9d23e0a820"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_Delete.json +func ExampleDisksClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDisksClient().BeginDelete(ctx, "resourceGroupName", "{labName}", "{userId}", "{diskName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_Update.json +func ExampleDisksClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDisksClient().Update(ctx, "resourceGroupName", "{labName}", "@me", "diskName", armdevtestlabs.DiskFragment{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + }, 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.Disk = armdevtestlabs.Disk{ + // Name: to.Ptr("{disk-name}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/disks"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{user-id}/disks/{diskName}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.DiskProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-04T20:21:02.0182357+00:00"); return t}()), + // DiskSizeGiB: to.Ptr[int32](1023), + // DiskType: to.Ptr(armdevtestlabs.StorageTypeStandard), + // DiskURI: to.Ptr(""), + // HostCaching: to.Ptr("None"), + // LeasedByLabVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/vmName"), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("b7183ac5-1097-4513-b597-4d9d23e0a820"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_Attach.json +func ExampleDisksClient_BeginAttach() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDisksClient().BeginAttach(ctx, "resourceGroupName", "{labName}", "{userId}", "{diskName}", armdevtestlabs.AttachDiskProperties{ + LeasedByLabVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), + }, 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_Detach.json +func ExampleDisksClient_BeginDetach() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDisksClient().BeginDetach(ctx, "resourceGroupName", "{labName}", "{userId}", "{diskName}", armdevtestlabs.DetachDiskProperties{ + LeasedByLabVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/myResourceGroup/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), + }, 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/devtestlabs/armdevtestlabs/zz_generated_environments_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/environments_client.go similarity index 85% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_environments_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/environments_client.go index 0bef25f26d64..4622722a82c0 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_environments_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/environments_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 armdevtestlabs @@ -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" @@ -26,66 +25,59 @@ import ( // EnvironmentsClient contains the methods for the Environments group. // Don't use this type directly, use NewEnvironmentsClient() instead. type EnvironmentsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewEnvironmentsClient creates a new instance of EnvironmentsClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewEnvironmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EnvironmentsClient, 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+".EnvironmentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &EnvironmentsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create or replace an existing environment. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the environment. -// dtlEnvironment - An environment, which is essentially an ARM template deployment. -// options - EnvironmentsClientBeginCreateOrUpdateOptions contains the optional parameters for the EnvironmentsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the environment. +// - dtlEnvironment - An environment, which is essentially an ARM template deployment. +// - options - EnvironmentsClientBeginCreateOrUpdateOptions contains the optional parameters for the EnvironmentsClient.BeginCreateOrUpdate +// method. func (client *EnvironmentsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, userName string, name string, dtlEnvironment DtlEnvironment, options *EnvironmentsClientBeginCreateOrUpdateOptions) (*runtime.Poller[EnvironmentsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, labName, userName, name, dtlEnvironment, options) if err != nil { return nil, err } - return runtime.NewPoller[EnvironmentsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[EnvironmentsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[EnvironmentsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[EnvironmentsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or replace an existing environment. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *EnvironmentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, labName string, userName string, name string, dtlEnvironment DtlEnvironment, options *EnvironmentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, userName, name, dtlEnvironment, 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 +110,7 @@ func (client *EnvironmentsClient) createOrUpdateCreateRequest(ctx context.Contex 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 } @@ -131,34 +123,36 @@ func (client *EnvironmentsClient) createOrUpdateCreateRequest(ctx context.Contex // BeginDelete - Delete environment. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the environment. -// options - EnvironmentsClientBeginDeleteOptions contains the optional parameters for the EnvironmentsClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the environment. +// - options - EnvironmentsClientBeginDeleteOptions contains the optional parameters for the EnvironmentsClient.BeginDelete +// method. func (client *EnvironmentsClient) BeginDelete(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *EnvironmentsClientBeginDeleteOptions) (*runtime.Poller[EnvironmentsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, labName, userName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[EnvironmentsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[EnvironmentsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[EnvironmentsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[EnvironmentsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete environment. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *EnvironmentsClient) deleteOperation(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *EnvironmentsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, userName, name, 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 } @@ -191,7 +185,7 @@ func (client *EnvironmentsClient) deleteCreateRequest(ctx context.Context, resou 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 } @@ -204,18 +198,19 @@ func (client *EnvironmentsClient) deleteCreateRequest(ctx context.Context, resou // Get - Get environment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the environment. -// options - EnvironmentsClientGetOptions contains the optional parameters for the EnvironmentsClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the environment. +// - options - EnvironmentsClientGetOptions contains the optional parameters for the EnvironmentsClient.Get method. func (client *EnvironmentsClient) Get(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *EnvironmentsClientGetOptions) (EnvironmentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, userName, name, options) if err != nil { return EnvironmentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EnvironmentsClientGetResponse{}, err } @@ -248,7 +243,7 @@ func (client *EnvironmentsClient) getCreateRequest(ctx context.Context, resource 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 } @@ -272,12 +267,12 @@ func (client *EnvironmentsClient) getHandleResponse(resp *http.Response) (Enviro } // NewListPager - List environments in a given user profile. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// options - EnvironmentsClientListOptions contains the optional parameters for the EnvironmentsClient.List method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - options - EnvironmentsClientListOptions contains the optional parameters for the EnvironmentsClient.NewListPager method. func (client *EnvironmentsClient) NewListPager(resourceGroupName string, labName string, userName string, options *EnvironmentsClientListOptions) *runtime.Pager[EnvironmentsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[EnvironmentsClientListResponse]{ More: func(page EnvironmentsClientListResponse) bool { @@ -294,7 +289,7 @@ func (client *EnvironmentsClient) NewListPager(resourceGroupName string, labName if err != nil { return EnvironmentsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EnvironmentsClientListResponse{}, err } @@ -325,7 +320,7 @@ func (client *EnvironmentsClient) listCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter userName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{userName}", url.PathEscape(userName)) - 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 } @@ -359,19 +354,20 @@ func (client *EnvironmentsClient) listHandleResponse(resp *http.Response) (Envir // Update - Allows modifying tags of environments. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the environment. -// dtlEnvironment - An environment, which is essentially an ARM template deployment. -// options - EnvironmentsClientUpdateOptions contains the optional parameters for the EnvironmentsClient.Update method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the environment. +// - dtlEnvironment - An environment, which is essentially an ARM template deployment. +// - options - EnvironmentsClientUpdateOptions contains the optional parameters for the EnvironmentsClient.Update method. func (client *EnvironmentsClient) Update(ctx context.Context, resourceGroupName string, labName string, userName string, name string, dtlEnvironment DtlEnvironmentFragment, options *EnvironmentsClientUpdateOptions) (EnvironmentsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, userName, name, dtlEnvironment, options) if err != nil { return EnvironmentsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EnvironmentsClientUpdateResponse{}, err } @@ -404,7 +400,7 @@ func (client *EnvironmentsClient) updateCreateRequest(ctx context.Context, resou return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/environments_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/environments_client_example_test.go new file mode 100644 index 000000000000..35bea863c736 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/environments_client_example_test.go @@ -0,0 +1,215 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_List.json +func ExampleEnvironmentsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewEnvironmentsClient().NewListPager("resourceGroupName", "{labName}", "@me", &armdevtestlabs.EnvironmentsClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.DtlEnvironmentList = armdevtestlabs.DtlEnvironmentList{ + // Value: []*armdevtestlabs.DtlEnvironment{ + // { + // Name: to.Ptr("{environmentName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/environments"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{uniqueIdentifier}/environments/{environmentName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.EnvironmentProperties{ + // CreatedByUser: to.Ptr("user@contoso.com"), + // DeploymentProperties: &armdevtestlabs.EnvironmentDeploymentProperties{ + // ArmTemplateID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/artifactSources/{artifactSourceName}/armTemplates/{armTemplateName}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_Get.json +func ExampleEnvironmentsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEnvironmentsClient().Get(ctx, "resourceGroupName", "{labName}", "@me", "{environmentName}", &armdevtestlabs.EnvironmentsClientGetOptions{Expand: 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.DtlEnvironment = armdevtestlabs.DtlEnvironment{ + // Name: to.Ptr("{environmentName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/environments"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{uniqueIdentifier}/environments/{environmentName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.EnvironmentProperties{ + // CreatedByUser: to.Ptr("user@contoso.com"), + // DeploymentProperties: &armdevtestlabs.EnvironmentDeploymentProperties{ + // ArmTemplateID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/artifactSources/{artifactSourceName}/armTemplates/{armTemplateName}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_CreateOrUpdate.json +func ExampleEnvironmentsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEnvironmentsClient().BeginCreateOrUpdate(ctx, "resourceGroupName", "{labName}", "@me", "{environmentName}", armdevtestlabs.DtlEnvironment{ + Properties: &armdevtestlabs.EnvironmentProperties{ + DeploymentProperties: &armdevtestlabs.EnvironmentDeploymentProperties{ + ArmTemplateID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/artifactSources/{artifactSourceName}/armTemplates/{armTemplateName}"), + Parameters: []*armdevtestlabs.ArmTemplateParameterProperties{}, + }, + }, + }, 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.DtlEnvironment = armdevtestlabs.DtlEnvironment{ + // Name: to.Ptr("{environmentName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/environments"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{uniqueIdentifier}/environments/{environmentName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.EnvironmentProperties{ + // CreatedByUser: to.Ptr("user@contoso.com"), + // DeploymentProperties: &armdevtestlabs.EnvironmentDeploymentProperties{ + // ArmTemplateID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/artifactSources/{artifactSourceName}/armTemplates/{armTemplateName}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_Delete.json +func ExampleEnvironmentsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEnvironmentsClient().BeginDelete(ctx, "resourceGroupName", "{labName}", "@me", "{environmentName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_Update.json +func ExampleEnvironmentsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEnvironmentsClient().Update(ctx, "resourceGroupName", "{labName}", "@me", "{environmentName}", armdevtestlabs.DtlEnvironmentFragment{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + }, 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.DtlEnvironment = armdevtestlabs.DtlEnvironment{ + // Name: to.Ptr("{environmentName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/environments"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{uniqueIdentifier}/environments/{environmentName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.EnvironmentProperties{ + // CreatedByUser: to.Ptr("user@contoso.com"), + // DeploymentProperties: &armdevtestlabs.EnvironmentDeploymentProperties{ + // ArmTemplateID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/artifactSources/{artifactSourceName}/armTemplates/{armTemplateName}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_formulas_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/formulas_client.go similarity index 85% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_formulas_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/formulas_client.go index 8aefb3b219a5..70991febacbc 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_formulas_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/formulas_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 armdevtestlabs @@ -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" @@ -26,65 +25,58 @@ import ( // FormulasClient contains the methods for the Formulas group. // Don't use this type directly, use NewFormulasClient() instead. type FormulasClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewFormulasClient creates a new instance of FormulasClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewFormulasClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FormulasClient, 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+".FormulasClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &FormulasClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create or replace an existing formula. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the formula. -// formula - A formula for creating a VM, specifying an image base and other parameters -// options - FormulasClientBeginCreateOrUpdateOptions contains the optional parameters for the FormulasClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the formula. +// - formula - A formula for creating a VM, specifying an image base and other parameters +// - options - FormulasClientBeginCreateOrUpdateOptions contains the optional parameters for the FormulasClient.BeginCreateOrUpdate +// method. func (client *FormulasClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, formula Formula, options *FormulasClientBeginCreateOrUpdateOptions) (*runtime.Poller[FormulasClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, labName, name, formula, options) if err != nil { return nil, err } - return runtime.NewPoller[FormulasClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[FormulasClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[FormulasClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[FormulasClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or replace an existing formula. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *FormulasClient) createOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, formula Formula, options *FormulasClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, name, formula, 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 +105,7 @@ func (client *FormulasClient) createOrUpdateCreateRequest(ctx context.Context, r 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 } @@ -126,17 +118,18 @@ func (client *FormulasClient) createOrUpdateCreateRequest(ctx context.Context, r // Delete - Delete formula. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the formula. -// options - FormulasClientDeleteOptions contains the optional parameters for the FormulasClient.Delete method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the formula. +// - options - FormulasClientDeleteOptions contains the optional parameters for the FormulasClient.Delete method. func (client *FormulasClient) Delete(ctx context.Context, resourceGroupName string, labName string, name string, options *FormulasClientDeleteOptions) (FormulasClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return FormulasClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FormulasClientDeleteResponse{}, err } @@ -165,7 +158,7 @@ func (client *FormulasClient) deleteCreateRequest(ctx context.Context, resourceG 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 } @@ -178,17 +171,18 @@ func (client *FormulasClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Get formula. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the formula. -// options - FormulasClientGetOptions contains the optional parameters for the FormulasClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the formula. +// - options - FormulasClientGetOptions contains the optional parameters for the FormulasClient.Get method. func (client *FormulasClient) Get(ctx context.Context, resourceGroupName string, labName string, name string, options *FormulasClientGetOptions) (FormulasClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return FormulasClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FormulasClientGetResponse{}, err } @@ -217,7 +211,7 @@ func (client *FormulasClient) getCreateRequest(ctx context.Context, resourceGrou 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 } @@ -241,11 +235,11 @@ func (client *FormulasClient) getHandleResponse(resp *http.Response) (FormulasCl } // NewListPager - List formulas in a given lab. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// options - FormulasClientListOptions contains the optional parameters for the FormulasClient.List method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - options - FormulasClientListOptions contains the optional parameters for the FormulasClient.NewListPager method. func (client *FormulasClient) NewListPager(resourceGroupName string, labName string, options *FormulasClientListOptions) *runtime.Pager[FormulasClientListResponse] { return runtime.NewPager(runtime.PagingHandler[FormulasClientListResponse]{ More: func(page FormulasClientListResponse) bool { @@ -262,7 +256,7 @@ func (client *FormulasClient) NewListPager(resourceGroupName string, labName str if err != nil { return FormulasClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FormulasClientListResponse{}, err } @@ -289,7 +283,7 @@ func (client *FormulasClient) listCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter labName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) - 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 } @@ -323,18 +317,19 @@ func (client *FormulasClient) listHandleResponse(resp *http.Response) (FormulasC // Update - Allows modifying tags of formulas. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the formula. -// formula - A formula for creating a VM, specifying an image base and other parameters -// options - FormulasClientUpdateOptions contains the optional parameters for the FormulasClient.Update method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the formula. +// - formula - A formula for creating a VM, specifying an image base and other parameters +// - options - FormulasClientUpdateOptions contains the optional parameters for the FormulasClient.Update method. func (client *FormulasClient) Update(ctx context.Context, resourceGroupName string, labName string, name string, formula FormulaFragment, options *FormulasClientUpdateOptions) (FormulasClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, name, formula, options) if err != nil { return FormulasClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FormulasClientUpdateResponse{}, err } @@ -363,7 +358,7 @@ func (client *FormulasClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/formulas_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/formulas_client_example_test.go new file mode 100644 index 000000000000..d5f73fd37ac3 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/formulas_client_example_test.go @@ -0,0 +1,377 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_List.json +func ExampleFormulasClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFormulasClient().NewListPager("resourceGroupName", "{labName}", &armdevtestlabs.FormulasClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.FormulaList = armdevtestlabs.FormulaList{ + // Value: []*armdevtestlabs.Formula{ + // { + // Name: to.Ptr("{formulaName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/formulas"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/formulas/{formulaName}"), + // Properties: &armdevtestlabs.FormulaProperties{ + // Description: to.Ptr("Formula used to create a Linux VM"), + // Author: to.Ptr("user@contoso.com"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-12-22T19:13:35.9922091+00:00"); return t}()), + // FormulaContent: &armdevtestlabs.LabVirtualMachineCreationParameter{ + // Location: to.Ptr("{location}"), + // Properties: &armdevtestlabs.LabVirtualMachineCreationParameterProperties{ + // AllowClaim: to.Ptr(false), + // Artifacts: []*armdevtestlabs.ArtifactInstallProperties{ + // { + // ArtifactID: to.Ptr("/artifactsources/{artifactSourceName}/artifacts/linux-install-nodejs"), + // Parameters: []*armdevtestlabs.ArtifactParameterProperties{ + // }, + // }}, + // DisallowPublicIPAddress: to.Ptr(true), + // GalleryImageReference: &armdevtestlabs.GalleryImageReference{ + // Offer: to.Ptr("0001-com-ubuntu-server-groovy"), + // OSType: to.Ptr("Linux"), + // Publisher: to.Ptr("canonical"), + // SKU: to.Ptr("20_10"), + // Version: to.Ptr("latest"), + // }, + // IsAuthenticationWithSSHKey: to.Ptr(false), + // LabSubnetName: to.Ptr("Dtl{labName}Subnet"), + // LabVirtualNetworkID: to.Ptr("/virtualnetworks/dtl{labName}"), + // NetworkInterface: &armdevtestlabs.NetworkInterfaceProperties{ + // SharedPublicIPAddressConfiguration: &armdevtestlabs.SharedPublicIPAddressConfiguration{ + // InboundNatRules: []*armdevtestlabs.InboundNatRule{ + // { + // BackendPort: to.Ptr[int32](22), + // TransportProtocol: to.Ptr(armdevtestlabs.TransportProtocolTCP), + // }}, + // }, + // }, + // Notes: to.Ptr("Ubuntu Server 20.10"), + // Size: to.Ptr("Standard_B1ms"), + // StorageType: to.Ptr("Standard"), + // UserName: to.Ptr("user"), + // }, + // }, + // OSType: to.Ptr("Linux"), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("7a7d20ab-8a50-46fb-8dc6-7c6c1443a01b"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_Get.json +func ExampleFormulasClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFormulasClient().Get(ctx, "resourceGroupName", "{labName}", "{formulaName}", &armdevtestlabs.FormulasClientGetOptions{Expand: 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.Formula = armdevtestlabs.Formula{ + // Name: to.Ptr("{formulaName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/formulas"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/formulas/{formulaName}"), + // Properties: &armdevtestlabs.FormulaProperties{ + // Description: to.Ptr("Formula used to create a Linux VM"), + // Author: to.Ptr("user@contoso.com"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-12-22T19:13:35.9922091+00:00"); return t}()), + // FormulaContent: &armdevtestlabs.LabVirtualMachineCreationParameter{ + // Location: to.Ptr("{location}"), + // Properties: &armdevtestlabs.LabVirtualMachineCreationParameterProperties{ + // AllowClaim: to.Ptr(false), + // Artifacts: []*armdevtestlabs.ArtifactInstallProperties{ + // { + // ArtifactID: to.Ptr("/artifactsources/{artifactSourceName}/artifacts/linux-install-nodejs"), + // Parameters: []*armdevtestlabs.ArtifactParameterProperties{ + // }, + // }}, + // DisallowPublicIPAddress: to.Ptr(true), + // GalleryImageReference: &armdevtestlabs.GalleryImageReference{ + // Offer: to.Ptr("0001-com-ubuntu-server-groovy"), + // OSType: to.Ptr("Linux"), + // Publisher: to.Ptr("canonical"), + // SKU: to.Ptr("20_10"), + // Version: to.Ptr("latest"), + // }, + // IsAuthenticationWithSSHKey: to.Ptr(false), + // LabSubnetName: to.Ptr("Dtl{labName}Subnet"), + // LabVirtualNetworkID: to.Ptr("/virtualnetworks/dtl{labName}"), + // NetworkInterface: &armdevtestlabs.NetworkInterfaceProperties{ + // SharedPublicIPAddressConfiguration: &armdevtestlabs.SharedPublicIPAddressConfiguration{ + // InboundNatRules: []*armdevtestlabs.InboundNatRule{ + // { + // BackendPort: to.Ptr[int32](22), + // TransportProtocol: to.Ptr(armdevtestlabs.TransportProtocolTCP), + // }}, + // }, + // }, + // Notes: to.Ptr("Ubuntu Server 20.10"), + // Size: to.Ptr("Standard_B1ms"), + // StorageType: to.Ptr("Standard"), + // UserName: to.Ptr("user"), + // }, + // }, + // OSType: to.Ptr("Linux"), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("7a7d20ab-8a50-46fb-8dc6-7c6c1443a01b"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_CreateOrUpdate.json +func ExampleFormulasClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFormulasClient().BeginCreateOrUpdate(ctx, "resourceGroupName", "{labName}", "{formulaName}", armdevtestlabs.Formula{ + Location: to.Ptr("{location}"), + Properties: &armdevtestlabs.FormulaProperties{ + Description: to.Ptr("Formula using a Linux base"), + FormulaContent: &armdevtestlabs.LabVirtualMachineCreationParameter{ + Location: to.Ptr("{location}"), + Properties: &armdevtestlabs.LabVirtualMachineCreationParameterProperties{ + AllowClaim: to.Ptr(false), + Artifacts: []*armdevtestlabs.ArtifactInstallProperties{ + { + ArtifactID: to.Ptr("/artifactsources/{artifactSourceName}/artifacts/linux-install-nodejs"), + Parameters: []*armdevtestlabs.ArtifactParameterProperties{}, + }}, + DisallowPublicIPAddress: to.Ptr(true), + GalleryImageReference: &armdevtestlabs.GalleryImageReference{ + Offer: to.Ptr("0001-com-ubuntu-server-groovy"), + OSType: to.Ptr("Linux"), + Publisher: to.Ptr("canonical"), + SKU: to.Ptr("20_10"), + Version: to.Ptr("latest"), + }, + IsAuthenticationWithSSHKey: to.Ptr(false), + LabSubnetName: to.Ptr("Dtl{labName}Subnet"), + LabVirtualNetworkID: to.Ptr("/virtualnetworks/dtl{labName}"), + NetworkInterface: &armdevtestlabs.NetworkInterfaceProperties{ + SharedPublicIPAddressConfiguration: &armdevtestlabs.SharedPublicIPAddressConfiguration{ + InboundNatRules: []*armdevtestlabs.InboundNatRule{ + { + BackendPort: to.Ptr[int32](22), + TransportProtocol: to.Ptr(armdevtestlabs.TransportProtocolTCP), + }}, + }, + }, + Notes: to.Ptr("Ubuntu Server 20.10"), + Size: to.Ptr("Standard_B1ms"), + StorageType: to.Ptr("Standard"), + UserName: to.Ptr("user"), + }, + }, + }, + }, 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.Formula = armdevtestlabs.Formula{ + // Name: to.Ptr("{formulaName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/formulas"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/formulas/{formulaName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.FormulaProperties{ + // Description: to.Ptr("Formula using a Linux base"), + // Author: to.Ptr("username@contoso.com"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-12-22T21:25:42.9254696+00:00"); return t}()), + // FormulaContent: &armdevtestlabs.LabVirtualMachineCreationParameter{ + // Location: to.Ptr("{location}"), + // Properties: &armdevtestlabs.LabVirtualMachineCreationParameterProperties{ + // AllowClaim: to.Ptr(false), + // Artifacts: []*armdevtestlabs.ArtifactInstallProperties{ + // { + // ArtifactID: to.Ptr("/artifactsources/{artifactSourceName}/artifacts/linux-install-nodejs"), + // Parameters: []*armdevtestlabs.ArtifactParameterProperties{ + // }, + // }}, + // DisallowPublicIPAddress: to.Ptr(true), + // GalleryImageReference: &armdevtestlabs.GalleryImageReference{ + // Offer: to.Ptr("0001-com-ubuntu-server-groovy"), + // OSType: to.Ptr("Linux"), + // Publisher: to.Ptr("canonical"), + // SKU: to.Ptr("20_10"), + // Version: to.Ptr("latest"), + // }, + // IsAuthenticationWithSSHKey: to.Ptr(false), + // LabSubnetName: to.Ptr("Dtl{labName}Subnet"), + // LabVirtualNetworkID: to.Ptr("/virtualnetworks/dtl{labName}"), + // NetworkInterface: &armdevtestlabs.NetworkInterfaceProperties{ + // SharedPublicIPAddressConfiguration: &armdevtestlabs.SharedPublicIPAddressConfiguration{ + // InboundNatRules: []*armdevtestlabs.InboundNatRule{ + // { + // BackendPort: to.Ptr[int32](22), + // TransportProtocol: to.Ptr(armdevtestlabs.TransportProtocolTCP), + // }}, + // }, + // }, + // Notes: to.Ptr("Ubuntu Server 20.10"), + // Size: to.Ptr("Standard_B1ms"), + // StorageType: to.Ptr("Standard"), + // UserName: to.Ptr("user"), + // }, + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_Delete.json +func ExampleFormulasClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewFormulasClient().Delete(ctx, "resourceGroupName", "{labName}", "{formulaName}", 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_Update.json +func ExampleFormulasClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFormulasClient().Update(ctx, "resourceGroupName", "{labName}", "{formulaName}", armdevtestlabs.FormulaFragment{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + }, 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.Formula = armdevtestlabs.Formula{ + // Name: to.Ptr("{formulaName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/formulas"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/formulas/{formulaName}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.FormulaProperties{ + // Description: to.Ptr("Formula using a Linux base"), + // Author: to.Ptr("username@contoso.com"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-12-22T21:25:42.9254696+00:00"); return t}()), + // FormulaContent: &armdevtestlabs.LabVirtualMachineCreationParameter{ + // Location: to.Ptr("{location}"), + // Properties: &armdevtestlabs.LabVirtualMachineCreationParameterProperties{ + // AllowClaim: to.Ptr(false), + // Artifacts: []*armdevtestlabs.ArtifactInstallProperties{ + // { + // ArtifactID: to.Ptr("/artifactsources/{artifactSourceName}/artifacts/linux-install-nodejs"), + // Parameters: []*armdevtestlabs.ArtifactParameterProperties{ + // }, + // }}, + // DisallowPublicIPAddress: to.Ptr(true), + // GalleryImageReference: &armdevtestlabs.GalleryImageReference{ + // Offer: to.Ptr("0001-com-ubuntu-server-groovy"), + // OSType: to.Ptr("Linux"), + // Publisher: to.Ptr("canonical"), + // SKU: to.Ptr("20_10"), + // Version: to.Ptr("latest"), + // }, + // IsAuthenticationWithSSHKey: to.Ptr(false), + // LabSubnetName: to.Ptr("Dtl{labName}Subnet"), + // LabVirtualNetworkID: to.Ptr("/virtualnetworks/dtl{labName}"), + // NetworkInterface: &armdevtestlabs.NetworkInterfaceProperties{ + // SharedPublicIPAddressConfiguration: &armdevtestlabs.SharedPublicIPAddressConfiguration{ + // InboundNatRules: []*armdevtestlabs.InboundNatRule{ + // { + // BackendPort: to.Ptr[int32](22), + // TransportProtocol: to.Ptr(armdevtestlabs.TransportProtocolTCP), + // }}, + // }, + // }, + // Notes: to.Ptr("Ubuntu Server 20.10"), + // Size: to.Ptr("Standard_B1ms"), + // StorageType: to.Ptr("Standard"), + // UserName: to.Ptr("user"), + // }, + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_galleryimages_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/galleryimages_client.go similarity index 80% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_galleryimages_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/galleryimages_client.go index 380172754219..41912040c038 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_galleryimages_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/galleryimages_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 armdevtestlabs @@ -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" @@ -26,41 +25,32 @@ import ( // GalleryImagesClient contains the methods for the GalleryImages group. // Don't use this type directly, use NewGalleryImagesClient() instead. type GalleryImagesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewGalleryImagesClient creates a new instance of GalleryImagesClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewGalleryImagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GalleryImagesClient, 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+".GalleryImagesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &GalleryImagesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - List gallery images in a given lab. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// options - GalleryImagesClientListOptions contains the optional parameters for the GalleryImagesClient.List method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - options - GalleryImagesClientListOptions contains the optional parameters for the GalleryImagesClient.NewListPager method. func (client *GalleryImagesClient) NewListPager(resourceGroupName string, labName string, options *GalleryImagesClientListOptions) *runtime.Pager[GalleryImagesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[GalleryImagesClientListResponse]{ More: func(page GalleryImagesClientListResponse) bool { @@ -77,7 +67,7 @@ func (client *GalleryImagesClient) NewListPager(resourceGroupName string, labNam if err != nil { return GalleryImagesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GalleryImagesClientListResponse{}, err } @@ -104,7 +94,7 @@ func (client *GalleryImagesClient) listCreateRequest(ctx context.Context, resour return nil, errors.New("parameter labName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) - 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/devtestlabs/armdevtestlabs/galleryimages_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/galleryimages_client_example_test.go new file mode 100644 index 000000000000..73e41f7cad25 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/galleryimages_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 armdevtestlabs_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GalleryImages_List.json +func ExampleGalleryImagesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewGalleryImagesClient().NewListPager("resourceGroupName", "{labName}", &armdevtestlabs.GalleryImagesClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.GalleryImageList = armdevtestlabs.GalleryImageList{ + // Value: []*armdevtestlabs.GalleryImage{ + // { + // Name: to.Ptr("Ubuntu Server 20.04 LTS"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/galleryImages"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/galleryimages/ubuntu server 20.04 lts"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.GalleryImageProperties{ + // Description: to.Ptr("Ubuntu Server is the world's most popular Linux for cloud environments. Updates and patches for Ubuntu Server 20.04 LTS will be available until April 2025. Ubuntu Server is the perfect virtual machine (VM) platform for all workloads from web applications to NoSQL databases and Hadoop. For more information see Ubuntu on Azure and using Juju to deploy your workloads.

Legal Terms

By clicking the Create button, I acknowledge that I am getting this software from Canonical and that the legal terms of Canonical apply to it. Microsoft does not provide rights for third-party software. Also see the privacy statement from Canonical.

"), + // Author: to.Ptr("Canonical"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T23:43:43.7643542+00:00"); return t}()), + // Enabled: to.Ptr(true), + // Icon: to.Ptr("https://106c4.wpc.azureedge.net/80106C4/Gallery-Prod/cdn/2015-02-24/prod20161101-microsoft-windowsazure-gallery/canonical.0001-com-ubuntu-server-focal20_04-lts-ARM.1.0.22/Icons/Small.png"), + // ImageReference: &armdevtestlabs.GalleryImageReference{ + // Offer: to.Ptr("0001-com-ubuntu-server-focal"), + // OSType: to.Ptr("Linux"), + // Publisher: to.Ptr("canonical"), + // SKU: to.Ptr("20_04-lts"), + // Version: to.Ptr("latest"), + // }, + // }, + // }, + // { + // Name: to.Ptr("Windows 10 Enterprise, Version 20H2"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/galleryImages"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/galleryimages/windows 10 enterprise, version 20h2"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.GalleryImageProperties{ + // Description: to.Ptr("

This software is provided by Microsoft. Use of this software in Microsoft Azure is not permitted except under a volume licensing agreement with Microsoft. By clicking Create, I acknowledge that I or the company I work for is licensed to use this software under a volume licensing agreement with Microsoft and that the right to use it will be subject to that agreement.

Legal Terms

By clicking the Create button, I acknowledge that I am getting this software from Microsoft and that the legal terms of Microsoft apply to it. Microsoft does not provide rights for third-party software. Also see the privacy statement from Microsoft.

"), + // Author: to.Ptr("Microsoft"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:33:33.2464999+00:00"); return t}()), + // Enabled: to.Ptr(true), + // Icon: to.Ptr("https://106c4.wpc.azureedge.net/80106C4/Gallery-Prod/cdn/2015-02-24/prod20161101-microsoft-windowsazure-gallery/microsoftwindowsdesktop.windows-1020h2-ent.1.0.238/Icons/Small.png"), + // ImageReference: &armdevtestlabs.GalleryImageReference{ + // Offer: to.Ptr("Windows-10"), + // OSType: to.Ptr("Windows"), + // Publisher: to.Ptr("MicrosoftWindowsDesktop"), + // SKU: to.Ptr("20h2-ent"), + // Version: to.Ptr("latest"), + // }, + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_globalschedules_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/globalschedules_client.go similarity index 87% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_globalschedules_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/globalschedules_client.go index 75af4797f0d5..04f7d8f76a49 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_globalschedules_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/globalschedules_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 armdevtestlabs @@ -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" @@ -26,49 +25,41 @@ import ( // GlobalSchedulesClient contains the methods for the GlobalSchedules group. // Don't use this type directly, use NewGlobalSchedulesClient() instead. type GlobalSchedulesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewGlobalSchedulesClient creates a new instance of GlobalSchedulesClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewGlobalSchedulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GlobalSchedulesClient, 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+".GlobalSchedulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &GlobalSchedulesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or replace an existing schedule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the schedule. -// schedule - A schedule. -// options - GlobalSchedulesClientCreateOrUpdateOptions contains the optional parameters for the GlobalSchedulesClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the schedule. +// - schedule - A schedule. +// - options - GlobalSchedulesClientCreateOrUpdateOptions contains the optional parameters for the GlobalSchedulesClient.CreateOrUpdate +// method. func (client *GlobalSchedulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, name string, schedule Schedule, options *GlobalSchedulesClientCreateOrUpdateOptions) (GlobalSchedulesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, name, schedule, options) if err != nil { return GlobalSchedulesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GlobalSchedulesClientCreateOrUpdateResponse{}, err } @@ -93,7 +84,7 @@ func (client *GlobalSchedulesClient) createOrUpdateCreateRequest(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.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 } @@ -115,16 +106,17 @@ func (client *GlobalSchedulesClient) createOrUpdateHandleResponse(resp *http.Res // Delete - Delete schedule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the schedule. -// options - GlobalSchedulesClientDeleteOptions contains the optional parameters for the GlobalSchedulesClient.Delete method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the schedule. +// - options - GlobalSchedulesClientDeleteOptions contains the optional parameters for the GlobalSchedulesClient.Delete method. func (client *GlobalSchedulesClient) Delete(ctx context.Context, resourceGroupName string, name string, options *GlobalSchedulesClientDeleteOptions) (GlobalSchedulesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, name, options) if err != nil { return GlobalSchedulesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GlobalSchedulesClientDeleteResponse{}, err } @@ -149,7 +141,7 @@ func (client *GlobalSchedulesClient) deleteCreateRequest(ctx context.Context, re 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 } @@ -162,32 +154,34 @@ func (client *GlobalSchedulesClient) deleteCreateRequest(ctx context.Context, re // BeginExecute - Execute a schedule. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the schedule. -// options - GlobalSchedulesClientBeginExecuteOptions contains the optional parameters for the GlobalSchedulesClient.BeginExecute -// method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the schedule. +// - options - GlobalSchedulesClientBeginExecuteOptions contains the optional parameters for the GlobalSchedulesClient.BeginExecute +// method. func (client *GlobalSchedulesClient) BeginExecute(ctx context.Context, resourceGroupName string, name string, options *GlobalSchedulesClientBeginExecuteOptions) (*runtime.Poller[GlobalSchedulesClientExecuteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.execute(ctx, resourceGroupName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[GlobalSchedulesClientExecuteResponse](resp, client.pl, nil) + return runtime.NewPoller[GlobalSchedulesClientExecuteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[GlobalSchedulesClientExecuteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[GlobalSchedulesClientExecuteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Execute - Execute a schedule. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *GlobalSchedulesClient) execute(ctx context.Context, resourceGroupName string, name string, options *GlobalSchedulesClientBeginExecuteOptions) (*http.Response, error) { req, err := client.executeCreateRequest(ctx, resourceGroupName, name, 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 } @@ -212,7 +206,7 @@ func (client *GlobalSchedulesClient) executeCreateRequest(ctx context.Context, r return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -225,16 +219,17 @@ func (client *GlobalSchedulesClient) executeCreateRequest(ctx context.Context, r // Get - Get schedule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the schedule. -// options - GlobalSchedulesClientGetOptions contains the optional parameters for the GlobalSchedulesClient.Get method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the schedule. +// - options - GlobalSchedulesClientGetOptions contains the optional parameters for the GlobalSchedulesClient.Get method. func (client *GlobalSchedulesClient) Get(ctx context.Context, resourceGroupName string, name string, options *GlobalSchedulesClientGetOptions) (GlobalSchedulesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, name, options) if err != nil { return GlobalSchedulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GlobalSchedulesClientGetResponse{}, err } @@ -259,7 +254,7 @@ func (client *GlobalSchedulesClient) getCreateRequest(ctx context.Context, resou 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 } @@ -283,11 +278,11 @@ func (client *GlobalSchedulesClient) getHandleResponse(resp *http.Response) (Glo } // NewListByResourceGroupPager - List schedules in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// options - GlobalSchedulesClientListByResourceGroupOptions contains the optional parameters for the GlobalSchedulesClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. +// - options - GlobalSchedulesClientListByResourceGroupOptions contains the optional parameters for the GlobalSchedulesClient.NewListByResourceGroupPager +// method. func (client *GlobalSchedulesClient) NewListByResourceGroupPager(resourceGroupName string, options *GlobalSchedulesClientListByResourceGroupOptions) *runtime.Pager[GlobalSchedulesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[GlobalSchedulesClientListByResourceGroupResponse]{ More: func(page GlobalSchedulesClientListByResourceGroupResponse) bool { @@ -304,7 +299,7 @@ func (client *GlobalSchedulesClient) NewListByResourceGroupPager(resourceGroupNa if err != nil { return GlobalSchedulesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GlobalSchedulesClientListByResourceGroupResponse{}, err } @@ -327,7 +322,7 @@ func (client *GlobalSchedulesClient) listByResourceGroupCreateRequest(ctx 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 } @@ -360,10 +355,10 @@ func (client *GlobalSchedulesClient) listByResourceGroupHandleResponse(resp *htt } // NewListBySubscriptionPager - List schedules in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// options - GlobalSchedulesClientListBySubscriptionOptions contains the optional parameters for the GlobalSchedulesClient.ListBySubscription -// method. +// - options - GlobalSchedulesClientListBySubscriptionOptions contains the optional parameters for the GlobalSchedulesClient.NewListBySubscriptionPager +// method. func (client *GlobalSchedulesClient) NewListBySubscriptionPager(options *GlobalSchedulesClientListBySubscriptionOptions) *runtime.Pager[GlobalSchedulesClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[GlobalSchedulesClientListBySubscriptionResponse]{ More: func(page GlobalSchedulesClientListBySubscriptionResponse) bool { @@ -380,7 +375,7 @@ func (client *GlobalSchedulesClient) NewListBySubscriptionPager(options *GlobalS if err != nil { return GlobalSchedulesClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GlobalSchedulesClientListBySubscriptionResponse{}, err } @@ -399,7 +394,7 @@ func (client *GlobalSchedulesClient) 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 } @@ -433,33 +428,35 @@ func (client *GlobalSchedulesClient) listBySubscriptionHandleResponse(resp *http // BeginRetarget - Updates a schedule's target resource Id. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the schedule. -// retargetScheduleProperties - Properties for retargeting a virtual machine schedule. -// options - GlobalSchedulesClientBeginRetargetOptions contains the optional parameters for the GlobalSchedulesClient.BeginRetarget -// method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the schedule. +// - retargetScheduleProperties - Properties for retargeting a virtual machine schedule. +// - options - GlobalSchedulesClientBeginRetargetOptions contains the optional parameters for the GlobalSchedulesClient.BeginRetarget +// method. func (client *GlobalSchedulesClient) BeginRetarget(ctx context.Context, resourceGroupName string, name string, retargetScheduleProperties RetargetScheduleProperties, options *GlobalSchedulesClientBeginRetargetOptions) (*runtime.Poller[GlobalSchedulesClientRetargetResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.retarget(ctx, resourceGroupName, name, retargetScheduleProperties, options) if err != nil { return nil, err } - return runtime.NewPoller[GlobalSchedulesClientRetargetResponse](resp, client.pl, nil) + return runtime.NewPoller[GlobalSchedulesClientRetargetResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[GlobalSchedulesClientRetargetResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[GlobalSchedulesClientRetargetResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Retarget - Updates a schedule's target resource Id. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *GlobalSchedulesClient) retarget(ctx context.Context, resourceGroupName string, name string, retargetScheduleProperties RetargetScheduleProperties, options *GlobalSchedulesClientBeginRetargetOptions) (*http.Response, error) { req, err := client.retargetCreateRequest(ctx, resourceGroupName, name, retargetScheduleProperties, 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 } @@ -484,7 +481,7 @@ func (client *GlobalSchedulesClient) retargetCreateRequest(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.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,17 +494,18 @@ func (client *GlobalSchedulesClient) retargetCreateRequest(ctx context.Context, // Update - Allows modifying tags of schedules. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the schedule. -// schedule - A schedule. -// options - GlobalSchedulesClientUpdateOptions contains the optional parameters for the GlobalSchedulesClient.Update method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the schedule. +// - schedule - A schedule. +// - options - GlobalSchedulesClientUpdateOptions contains the optional parameters for the GlobalSchedulesClient.Update method. func (client *GlobalSchedulesClient) Update(ctx context.Context, resourceGroupName string, name string, schedule ScheduleFragment, options *GlobalSchedulesClientUpdateOptions) (GlobalSchedulesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, name, schedule, options) if err != nil { return GlobalSchedulesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GlobalSchedulesClientUpdateResponse{}, err } @@ -532,7 +530,7 @@ func (client *GlobalSchedulesClient) updateCreateRequest(ctx context.Context, re return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/globalschedules_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/globalschedules_client_example_test.go new file mode 100644 index 000000000000..b24cb2071112 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/globalschedules_client_example_test.go @@ -0,0 +1,341 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_ListBySubscription.json +func ExampleGlobalSchedulesClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewGlobalSchedulesClient().NewListBySubscriptionPager(&armdevtestlabs.GlobalSchedulesClientListBySubscriptionOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.ScheduleList = armdevtestlabs.ScheduleList{ + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_ListByResourceGroup.json +func ExampleGlobalSchedulesClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewGlobalSchedulesClient().NewListByResourceGroupPager("resourceGroupName", &armdevtestlabs.GlobalSchedulesClientListByResourceGroupOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.ScheduleList = armdevtestlabs.ScheduleList{ + // Value: []*armdevtestlabs.Schedule{ + // { + // Name: to.Ptr("LabVmAutoStart"), + // Type: to.Ptr("microsoft.devtestlab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/labvmautostart"), + // Location: to.Ptr("{location}"), + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-29T22:54:54.9335182+00:00"); return t}()), + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // Status: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // TimeInMinutes: to.Ptr[int32](0), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TaskType: to.Ptr("LabVmsStartupTask"), + // TimeZoneID: to.Ptr("Hawaiian Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("0700"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Tuesday"), + // to.Ptr("Wednesday"), + // to.Ptr("Thursday"), + // to.Ptr("Friday")}, + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_Get.json +func ExampleGlobalSchedulesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewGlobalSchedulesClient().Get(ctx, "resourceGroupName", "labvmautostart", &armdevtestlabs.GlobalSchedulesClientGetOptions{Expand: 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.Schedule = armdevtestlabs.Schedule{ + // Name: to.Ptr("LabVmAutoStart"), + // Type: to.Ptr("microsoft.devtestlab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/labvmautostart"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-29T22:54:54.9335182+00:00"); return t}()), + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // Status: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // TimeInMinutes: to.Ptr[int32](0), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TaskType: to.Ptr("LabVmsStartupTask"), + // TimeZoneID: to.Ptr("Hawaiian Standard Time"), + // UniqueIdentifier: to.Ptr("{id}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("0700"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Tuesday"), + // to.Ptr("Wednesday"), + // to.Ptr("Thursday"), + // to.Ptr("Friday")}, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_CreateOrUpdate.json +func ExampleGlobalSchedulesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewGlobalSchedulesClient().CreateOrUpdate(ctx, "resourceGroupName", "labvmautostart", armdevtestlabs.Schedule{ + Properties: &armdevtestlabs.ScheduleProperties{ + Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + TaskType: to.Ptr("LabVmsStartupTask"), + TimeZoneID: to.Ptr("Hawaiian Standard Time"), + WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + Time: to.Ptr("0700"), + Weekdays: []*string{ + to.Ptr("Monday"), + to.Ptr("Tuesday"), + to.Ptr("Wednesday"), + to.Ptr("Thursday"), + to.Ptr("Friday"), + to.Ptr("Saturday")}, + }, + }, + }, 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.Schedule = armdevtestlabs.Schedule{ + // Name: to.Ptr("LabVmAutoStart"), + // Type: to.Ptr("microsoft.devtestlab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/labvmautostart"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-29T22:54:54.9335182+00:00"); return t}()), + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // Status: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // TimeInMinutes: to.Ptr[int32](0), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TaskType: to.Ptr("LabVmsStartupTask"), + // TimeZoneID: to.Ptr("Hawaiian Standard Time"), + // UniqueIdentifier: to.Ptr("{id}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("0700"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Tuesday"), + // to.Ptr("Wednesday"), + // to.Ptr("Thursday"), + // to.Ptr("Friday")}, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_Delete.json +func ExampleGlobalSchedulesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewGlobalSchedulesClient().Delete(ctx, "resourceGroupName", "labvmautostart", 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_Update.json +func ExampleGlobalSchedulesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewGlobalSchedulesClient().Update(ctx, "resourceGroupName", "labvmautostart", armdevtestlabs.ScheduleFragment{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + }, 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.Schedule = armdevtestlabs.Schedule{ + // Name: to.Ptr("LabVmAutoStart"), + // Type: to.Ptr("microsoft.devtestlab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/labvmautostart"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-29T22:54:54.9335182+00:00"); return t}()), + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // Status: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // TimeInMinutes: to.Ptr[int32](0), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TaskType: to.Ptr("LabVmsStartupTask"), + // TimeZoneID: to.Ptr("Hawaiian Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("0700"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Tuesday"), + // to.Ptr("Wednesday"), + // to.Ptr("Thursday"), + // to.Ptr("Friday")}, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_Execute.json +func ExampleGlobalSchedulesClient_BeginExecute() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewGlobalSchedulesClient().BeginExecute(ctx, "resourceGroupName", "labvmautostart", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_Retarget.json +func ExampleGlobalSchedulesClient_BeginRetarget() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewGlobalSchedulesClient().BeginRetarget(ctx, "resourceGroupName", "{scheduleName}", armdevtestlabs.RetargetScheduleProperties{ + CurrentResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{targetLab}"), + TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{currentLab}"), + }, 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/devtestlabs/armdevtestlabs/go.mod b/sdk/resourcemanager/devtestlabs/armdevtestlabs/go.mod index ba8d7dd4c3ce..0f411fd933c2 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/go.mod +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devtestlabs/armdevt 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/devtestlabs/armdevtestlabs/go.sum b/sdk/resourcemanager/devtestlabs/armdevtestlabs/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/go.sum +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/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/devtestlabs/armdevtestlabs/zz_generated_labs_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/labs_client.go similarity index 86% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_labs_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/labs_client.go index be2c62ab9c03..64da07b2ee98 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_labs_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/labs_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 armdevtestlabs @@ -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" @@ -26,62 +25,55 @@ import ( // LabsClient contains the methods for the Labs group. // Don't use this type directly, use NewLabsClient() instead. type LabsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewLabsClient creates a new instance of LabsClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewLabsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LabsClient, 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+".LabsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LabsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginClaimAnyVM - Claim a random claimable virtual machine in the lab. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the lab. -// options - LabsClientBeginClaimAnyVMOptions contains the optional parameters for the LabsClient.BeginClaimAnyVM method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the lab. +// - options - LabsClientBeginClaimAnyVMOptions contains the optional parameters for the LabsClient.BeginClaimAnyVM method. func (client *LabsClient) BeginClaimAnyVM(ctx context.Context, resourceGroupName string, name string, options *LabsClientBeginClaimAnyVMOptions) (*runtime.Poller[LabsClientClaimAnyVMResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.claimAnyVM(ctx, resourceGroupName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[LabsClientClaimAnyVMResponse](resp, client.pl, nil) + return runtime.NewPoller[LabsClientClaimAnyVMResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LabsClientClaimAnyVMResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LabsClientClaimAnyVMResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // ClaimAnyVM - Claim a random claimable virtual machine in the lab. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *LabsClient) claimAnyVM(ctx context.Context, resourceGroupName string, name string, options *LabsClientBeginClaimAnyVMOptions) (*http.Response, error) { req, err := client.claimAnyVMCreateRequest(ctx, resourceGroupName, name, 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 *LabsClient) claimAnyVMCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -119,33 +111,35 @@ func (client *LabsClient) claimAnyVMCreateRequest(ctx context.Context, resourceG // BeginCreateEnvironment - Create virtual machines in a lab. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the lab. -// labVirtualMachineCreationParameter - Properties for creating a virtual machine. -// options - LabsClientBeginCreateEnvironmentOptions contains the optional parameters for the LabsClient.BeginCreateEnvironment -// method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the lab. +// - labVirtualMachineCreationParameter - Properties for creating a virtual machine. +// - options - LabsClientBeginCreateEnvironmentOptions contains the optional parameters for the LabsClient.BeginCreateEnvironment +// method. func (client *LabsClient) BeginCreateEnvironment(ctx context.Context, resourceGroupName string, name string, labVirtualMachineCreationParameter LabVirtualMachineCreationParameter, options *LabsClientBeginCreateEnvironmentOptions) (*runtime.Poller[LabsClientCreateEnvironmentResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createEnvironment(ctx, resourceGroupName, name, labVirtualMachineCreationParameter, options) if err != nil { return nil, err } - return runtime.NewPoller[LabsClientCreateEnvironmentResponse](resp, client.pl, nil) + return runtime.NewPoller[LabsClientCreateEnvironmentResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LabsClientCreateEnvironmentResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LabsClientCreateEnvironmentResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateEnvironment - Create virtual machines in a lab. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *LabsClient) createEnvironment(ctx context.Context, resourceGroupName string, name string, labVirtualMachineCreationParameter LabVirtualMachineCreationParameter, options *LabsClientBeginCreateEnvironmentOptions) (*http.Response, error) { req, err := client.createEnvironmentCreateRequest(ctx, resourceGroupName, name, labVirtualMachineCreationParameter, 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 } @@ -170,7 +164,7 @@ func (client *LabsClient) createEnvironmentCreateRequest(ctx context.Context, re return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -183,33 +177,35 @@ func (client *LabsClient) createEnvironmentCreateRequest(ctx context.Context, re // BeginCreateOrUpdate - Create or replace an existing lab. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the lab. -// lab - A lab. -// options - LabsClientBeginCreateOrUpdateOptions contains the optional parameters for the LabsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the lab. +// - lab - A lab. +// - options - LabsClientBeginCreateOrUpdateOptions contains the optional parameters for the LabsClient.BeginCreateOrUpdate +// method. func (client *LabsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, name string, lab Lab, options *LabsClientBeginCreateOrUpdateOptions) (*runtime.Poller[LabsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, name, lab, options) if err != nil { return nil, err } - return runtime.NewPoller[LabsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[LabsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LabsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LabsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or replace an existing lab. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *LabsClient) createOrUpdate(ctx context.Context, resourceGroupName string, name string, lab Lab, options *LabsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, name, lab, 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 } @@ -234,7 +230,7 @@ func (client *LabsClient) createOrUpdateCreateRequest(ctx context.Context, resou 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 } @@ -247,31 +243,33 @@ func (client *LabsClient) createOrUpdateCreateRequest(ctx context.Context, resou // BeginDelete - Delete lab. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the lab. -// options - LabsClientBeginDeleteOptions contains the optional parameters for the LabsClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the lab. +// - options - LabsClientBeginDeleteOptions contains the optional parameters for the LabsClient.BeginDelete method. func (client *LabsClient) BeginDelete(ctx context.Context, resourceGroupName string, name string, options *LabsClientBeginDeleteOptions) (*runtime.Poller[LabsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[LabsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[LabsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LabsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LabsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete lab. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *LabsClient) deleteOperation(ctx context.Context, resourceGroupName string, name string, options *LabsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, name, 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 } @@ -296,7 +294,7 @@ func (client *LabsClient) deleteCreateRequest(ctx context.Context, resourceGroup 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 } @@ -309,33 +307,35 @@ func (client *LabsClient) deleteCreateRequest(ctx context.Context, resourceGroup // BeginExportResourceUsage - Exports the lab resource usage into a storage account This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the lab. -// exportResourceUsageParameters - The parameters of the export operation. -// options - LabsClientBeginExportResourceUsageOptions contains the optional parameters for the LabsClient.BeginExportResourceUsage -// method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the lab. +// - exportResourceUsageParameters - The parameters of the export operation. +// - options - LabsClientBeginExportResourceUsageOptions contains the optional parameters for the LabsClient.BeginExportResourceUsage +// method. func (client *LabsClient) BeginExportResourceUsage(ctx context.Context, resourceGroupName string, name string, exportResourceUsageParameters ExportResourceUsageParameters, options *LabsClientBeginExportResourceUsageOptions) (*runtime.Poller[LabsClientExportResourceUsageResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.exportResourceUsage(ctx, resourceGroupName, name, exportResourceUsageParameters, options) if err != nil { return nil, err } - return runtime.NewPoller[LabsClientExportResourceUsageResponse](resp, client.pl, nil) + return runtime.NewPoller[LabsClientExportResourceUsageResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LabsClientExportResourceUsageResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LabsClientExportResourceUsageResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // ExportResourceUsage - Exports the lab resource usage into a storage account This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *LabsClient) exportResourceUsage(ctx context.Context, resourceGroupName string, name string, exportResourceUsageParameters ExportResourceUsageParameters, options *LabsClientBeginExportResourceUsageOptions) (*http.Response, error) { req, err := client.exportResourceUsageCreateRequest(ctx, resourceGroupName, name, exportResourceUsageParameters, 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 } @@ -360,7 +360,7 @@ func (client *LabsClient) exportResourceUsageCreateRequest(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.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 } @@ -373,17 +373,18 @@ func (client *LabsClient) exportResourceUsageCreateRequest(ctx context.Context, // GenerateUploadURI - Generate a URI for uploading custom disk images to a Lab. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the lab. -// generateUploadURIParameter - Properties for generating an upload URI. -// options - LabsClientGenerateUploadURIOptions contains the optional parameters for the LabsClient.GenerateUploadURI method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the lab. +// - generateUploadURIParameter - Properties for generating an upload URI. +// - options - LabsClientGenerateUploadURIOptions contains the optional parameters for the LabsClient.GenerateUploadURI method. func (client *LabsClient) GenerateUploadURI(ctx context.Context, resourceGroupName string, name string, generateUploadURIParameter GenerateUploadURIParameter, options *LabsClientGenerateUploadURIOptions) (LabsClientGenerateUploadURIResponse, error) { req, err := client.generateUploadURICreateRequest(ctx, resourceGroupName, name, generateUploadURIParameter, options) if err != nil { return LabsClientGenerateUploadURIResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LabsClientGenerateUploadURIResponse{}, err } @@ -408,7 +409,7 @@ func (client *LabsClient) generateUploadURICreateRequest(ctx context.Context, re return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -430,16 +431,17 @@ func (client *LabsClient) generateUploadURIHandleResponse(resp *http.Response) ( // Get - Get lab. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the lab. -// options - LabsClientGetOptions contains the optional parameters for the LabsClient.Get method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the lab. +// - options - LabsClientGetOptions contains the optional parameters for the LabsClient.Get method. func (client *LabsClient) Get(ctx context.Context, resourceGroupName string, name string, options *LabsClientGetOptions) (LabsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, name, options) if err != nil { return LabsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LabsClientGetResponse{}, err } @@ -464,7 +466,7 @@ func (client *LabsClient) getCreateRequest(ctx context.Context, resourceGroupNam 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 } @@ -489,34 +491,36 @@ func (client *LabsClient) getHandleResponse(resp *http.Response) (LabsClientGetR // BeginImportVirtualMachine - Import a virtual machine into a different lab. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the lab. -// importLabVirtualMachineRequest - This represents the payload required to import a virtual machine from a different lab -// into the current one -// options - LabsClientBeginImportVirtualMachineOptions contains the optional parameters for the LabsClient.BeginImportVirtualMachine -// method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the lab. +// - importLabVirtualMachineRequest - This represents the payload required to import a virtual machine from a different lab +// into the current one +// - options - LabsClientBeginImportVirtualMachineOptions contains the optional parameters for the LabsClient.BeginImportVirtualMachine +// method. func (client *LabsClient) BeginImportVirtualMachine(ctx context.Context, resourceGroupName string, name string, importLabVirtualMachineRequest ImportLabVirtualMachineRequest, options *LabsClientBeginImportVirtualMachineOptions) (*runtime.Poller[LabsClientImportVirtualMachineResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.importVirtualMachine(ctx, resourceGroupName, name, importLabVirtualMachineRequest, options) if err != nil { return nil, err } - return runtime.NewPoller[LabsClientImportVirtualMachineResponse](resp, client.pl, nil) + return runtime.NewPoller[LabsClientImportVirtualMachineResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LabsClientImportVirtualMachineResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LabsClientImportVirtualMachineResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // ImportVirtualMachine - Import a virtual machine into a different lab. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *LabsClient) importVirtualMachine(ctx context.Context, resourceGroupName string, name string, importLabVirtualMachineRequest ImportLabVirtualMachineRequest, options *LabsClientBeginImportVirtualMachineOptions) (*http.Response, error) { req, err := client.importVirtualMachineCreateRequest(ctx, resourceGroupName, name, importLabVirtualMachineRequest, 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 } @@ -541,7 +545,7 @@ func (client *LabsClient) importVirtualMachineCreateRequest(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.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 } @@ -553,11 +557,11 @@ func (client *LabsClient) importVirtualMachineCreateRequest(ctx context.Context, } // NewListByResourceGroupPager - List labs in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// options - LabsClientListByResourceGroupOptions contains the optional parameters for the LabsClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. +// - options - LabsClientListByResourceGroupOptions contains the optional parameters for the LabsClient.NewListByResourceGroupPager +// method. func (client *LabsClient) NewListByResourceGroupPager(resourceGroupName string, options *LabsClientListByResourceGroupOptions) *runtime.Pager[LabsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[LabsClientListByResourceGroupResponse]{ More: func(page LabsClientListByResourceGroupResponse) bool { @@ -574,7 +578,7 @@ func (client *LabsClient) NewListByResourceGroupPager(resourceGroupName string, if err != nil { return LabsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LabsClientListByResourceGroupResponse{}, err } @@ -597,7 +601,7 @@ func (client *LabsClient) listByResourceGroupCreateRequest(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.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 } @@ -630,9 +634,10 @@ func (client *LabsClient) listByResourceGroupHandleResponse(resp *http.Response) } // NewListBySubscriptionPager - List labs in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// options - LabsClientListBySubscriptionOptions contains the optional parameters for the LabsClient.ListBySubscription method. +// - options - LabsClientListBySubscriptionOptions contains the optional parameters for the LabsClient.NewListBySubscriptionPager +// method. func (client *LabsClient) NewListBySubscriptionPager(options *LabsClientListBySubscriptionOptions) *runtime.Pager[LabsClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[LabsClientListBySubscriptionResponse]{ More: func(page LabsClientListBySubscriptionResponse) bool { @@ -649,7 +654,7 @@ func (client *LabsClient) NewListBySubscriptionPager(options *LabsClientListBySu if err != nil { return LabsClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LabsClientListBySubscriptionResponse{}, err } @@ -668,7 +673,7 @@ func (client *LabsClient) listBySubscriptionCreateRequest(ctx context.Context, o 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 } @@ -701,11 +706,11 @@ func (client *LabsClient) listBySubscriptionHandleResponse(resp *http.Response) } // NewListVhdsPager - List disk images available for custom image creation. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the lab. -// options - LabsClientListVhdsOptions contains the optional parameters for the LabsClient.ListVhds method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the lab. +// - options - LabsClientListVhdsOptions contains the optional parameters for the LabsClient.NewListVhdsPager method. func (client *LabsClient) NewListVhdsPager(resourceGroupName string, name string, options *LabsClientListVhdsOptions) *runtime.Pager[LabsClientListVhdsResponse] { return runtime.NewPager(runtime.PagingHandler[LabsClientListVhdsResponse]{ More: func(page LabsClientListVhdsResponse) bool { @@ -722,7 +727,7 @@ func (client *LabsClient) NewListVhdsPager(resourceGroupName string, name string if err != nil { return LabsClientListVhdsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LabsClientListVhdsResponse{}, err } @@ -749,7 +754,7 @@ func (client *LabsClient) listVhdsCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -771,17 +776,18 @@ func (client *LabsClient) listVhdsHandleResponse(resp *http.Response) (LabsClien // Update - Allows modifying tags of labs. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// name - The name of the lab. -// lab - A lab. -// options - LabsClientUpdateOptions contains the optional parameters for the LabsClient.Update method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the lab. +// - lab - A lab. +// - options - LabsClientUpdateOptions contains the optional parameters for the LabsClient.Update method. func (client *LabsClient) Update(ctx context.Context, resourceGroupName string, name string, lab LabFragment, options *LabsClientUpdateOptions) (LabsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, name, lab, options) if err != nil { return LabsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LabsClientUpdateResponse{}, err } @@ -806,7 +812,7 @@ func (client *LabsClient) updateCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/labs_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/labs_client_example_test.go new file mode 100644 index 000000000000..f38660e49959 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/labs_client_example_test.go @@ -0,0 +1,553 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_ListBySubscription.json +func ExampleLabsClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLabsClient().NewListBySubscriptionPager(&armdevtestlabs.LabsClientListBySubscriptionOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.LabList = armdevtestlabs.LabList{ + // Value: []*armdevtestlabs.Lab{ + // { + // Name: to.Ptr("{labName1}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName1}"), + // Location: to.Ptr("westcentralus"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.LabProperties{ + // Announcement: &armdevtestlabs.LabAnnouncementProperties{ + // Enabled: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // Expired: to.Ptr(false), + // Markdown: to.Ptr(""), + // Title: to.Ptr(""), + // }, + // ArtifactsStorageAccount: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/{storageAccountName}"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-30T08:38:13.1973609-07:00"); return t}()), + // DefaultPremiumStorageAccount: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/{storageAccountName}"), + // DefaultStorageAccount: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/{storageAccountName}"), + // EnvironmentPermission: to.Ptr(armdevtestlabs.EnvironmentPermissionReader), + // LabStorageType: to.Ptr(armdevtestlabs.StorageTypePremium), + // MandatoryArtifactsResourceIDsLinux: []*string{ + // }, + // MandatoryArtifactsResourceIDsWindows: []*string{ + // }, + // PremiumDataDiskStorageAccount: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/{storageAccountName}"), + // PremiumDataDisks: to.Ptr(armdevtestlabs.PremiumDataDiskDisabled), + // ProvisioningState: to.Ptr("Succeeded"), + // Support: &armdevtestlabs.LabSupportProperties{ + // Enabled: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // Markdown: to.Ptr(""), + // }, + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // VaultName: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.KeyVault/vaults/{keyVaultName}"), + // }, + // }, + // { + // Name: to.Ptr("{labName2}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName2}/providers/microsoft.devtestlab/labs/{labName2}"), + // Location: to.Ptr("japaneast"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.LabProperties{ + // Announcement: &armdevtestlabs.LabAnnouncementProperties{ + // Enabled: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // Expired: to.Ptr(false), + // Markdown: to.Ptr(""), + // Title: to.Ptr(""), + // }, + // ArtifactsStorageAccount: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName2}/providers/Microsoft.Storage/storageAccounts/{storageAccountName2}"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-30T09:37:52.9675083-07:00"); return t}()), + // DefaultPremiumStorageAccount: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName2}/providers/Microsoft.Storage/storageAccounts/{storageAccountName2}"), + // DefaultStorageAccount: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName2}/providers/Microsoft.Storage/storageAccounts/{storageAccountName2}"), + // EnvironmentPermission: to.Ptr(armdevtestlabs.EnvironmentPermissionReader), + // LabStorageType: to.Ptr(armdevtestlabs.StorageTypePremium), + // MandatoryArtifactsResourceIDsLinux: []*string{ + // }, + // MandatoryArtifactsResourceIDsWindows: []*string{ + // }, + // PremiumDataDiskStorageAccount: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName2}/providers/Microsoft.Storage/storageAccounts/{storageAccountName2}"), + // PremiumDataDisks: to.Ptr(armdevtestlabs.PremiumDataDiskDisabled), + // ProvisioningState: to.Ptr("Succeeded"), + // Support: &armdevtestlabs.LabSupportProperties{ + // Enabled: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // Markdown: to.Ptr(""), + // }, + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // VaultName: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName2}/providers/Microsoft.KeyVault/vaults/{keyVaultName2}"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_ListByResourceGroup.json +func ExampleLabsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLabsClient().NewListByResourceGroupPager("resourceGroupName", &armdevtestlabs.LabsClientListByResourceGroupOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.LabList = armdevtestlabs.LabList{ + // Value: []*armdevtestlabs.Lab{ + // { + // Name: to.Ptr("{labName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.LabProperties{ + // Announcement: &armdevtestlabs.LabAnnouncementProperties{ + // Enabled: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // Expired: to.Ptr(false), + // Markdown: to.Ptr(""), + // Title: to.Ptr(""), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-02T10:23:20.9573599-07:00"); return t}()), + // EnvironmentPermission: to.Ptr(armdevtestlabs.EnvironmentPermissionReader), + // LabStorageType: to.Ptr(armdevtestlabs.StorageTypeStandard), + // MandatoryArtifactsResourceIDsLinux: []*string{ + // }, + // MandatoryArtifactsResourceIDsWindows: []*string{ + // }, + // PremiumDataDisks: to.Ptr(armdevtestlabs.PremiumDataDiskDisabled), + // ProvisioningState: to.Ptr("Succeeded"), + // Support: &armdevtestlabs.LabSupportProperties{ + // Enabled: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // Markdown: to.Ptr(""), + // }, + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // VaultName: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.KeyVault/vaults/{keyVaultName}"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_Get.json +func ExampleLabsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewLabsClient().Get(ctx, "resourceGroupName", "{labName}", &armdevtestlabs.LabsClientGetOptions{Expand: 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.Lab = armdevtestlabs.Lab{ + // Name: to.Ptr("{labName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.LabProperties{ + // Announcement: &armdevtestlabs.LabAnnouncementProperties{ + // Enabled: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // Expired: to.Ptr(false), + // Markdown: to.Ptr(""), + // Title: to.Ptr(""), + // }, + // ArtifactsStorageAccount: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/{storageAccountName}"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DefaultPremiumStorageAccount: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/{storageAccountName}"), + // DefaultStorageAccount: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/{storageAccountName}"), + // EnvironmentPermission: to.Ptr(armdevtestlabs.EnvironmentPermissionReader), + // LabStorageType: to.Ptr(armdevtestlabs.StorageTypeStandard), + // MandatoryArtifactsResourceIDsLinux: []*string{ + // }, + // MandatoryArtifactsResourceIDsWindows: []*string{ + // }, + // PremiumDataDiskStorageAccount: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/{storageAccountName}"), + // PremiumDataDisks: to.Ptr(armdevtestlabs.PremiumDataDiskDisabled), + // ProvisioningState: to.Ptr("Succeeded"), + // Support: &armdevtestlabs.LabSupportProperties{ + // Enabled: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // Markdown: to.Ptr(""), + // }, + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // VaultName: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.KeyVault/vaults/{keyVaultName}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_CreateOrUpdate.json +func ExampleLabsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewLabsClient().BeginCreateOrUpdate(ctx, "resourceGroupName", "{labName}", armdevtestlabs.Lab{ + Location: to.Ptr("{location}"), + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + Properties: &armdevtestlabs.LabProperties{ + LabStorageType: to.Ptr(armdevtestlabs.StorageType("{Standard|Premium}")), + }, + }, 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.Lab = armdevtestlabs.Lab{ + // Name: to.Ptr("{labName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.LabProperties{ + // Announcement: &armdevtestlabs.LabAnnouncementProperties{ + // Enabled: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // Expired: to.Ptr(false), + // Markdown: to.Ptr(""), + // Title: to.Ptr(""), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // EnvironmentPermission: to.Ptr(armdevtestlabs.EnvironmentPermissionReader), + // LabStorageType: to.Ptr(armdevtestlabs.StorageTypeStandard), + // MandatoryArtifactsResourceIDsLinux: []*string{ + // }, + // MandatoryArtifactsResourceIDsWindows: []*string{ + // }, + // PremiumDataDisks: to.Ptr(armdevtestlabs.PremiumDataDiskDisabled), + // ProvisioningState: to.Ptr("Succeeded"), + // Support: &armdevtestlabs.LabSupportProperties{ + // Enabled: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // Markdown: to.Ptr(""), + // }, + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_Delete.json +func ExampleLabsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewLabsClient().BeginDelete(ctx, "resourceGroupName", "{labName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_Update.json +func ExampleLabsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewLabsClient().Update(ctx, "resourceGroupName", "{labName}", armdevtestlabs.LabFragment{}, 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.Lab = armdevtestlabs.Lab{ + // Name: to.Ptr("{labName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.LabProperties{ + // Announcement: &armdevtestlabs.LabAnnouncementProperties{ + // Enabled: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // Expired: to.Ptr(false), + // Markdown: to.Ptr(""), + // Title: to.Ptr(""), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // EnvironmentPermission: to.Ptr(armdevtestlabs.EnvironmentPermissionReader), + // LabStorageType: to.Ptr(armdevtestlabs.StorageTypeStandard), + // MandatoryArtifactsResourceIDsLinux: []*string{ + // }, + // MandatoryArtifactsResourceIDsWindows: []*string{ + // }, + // PremiumDataDisks: to.Ptr(armdevtestlabs.PremiumDataDiskDisabled), + // ProvisioningState: to.Ptr("Succeeded"), + // Support: &armdevtestlabs.LabSupportProperties{ + // Enabled: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // Markdown: to.Ptr(""), + // }, + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // VaultName: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.KeyVault/vaults/{keyVaultName}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_ClaimAnyVm.json +func ExampleLabsClient_BeginClaimAnyVM() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewLabsClient().BeginClaimAnyVM(ctx, "resourceGroupName", "{labName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_CreateEnvironment.json +func ExampleLabsClient_BeginCreateEnvironment() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewLabsClient().BeginCreateEnvironment(ctx, "resourceGroupName", "{labName}", armdevtestlabs.LabVirtualMachineCreationParameter{ + Name: to.Ptr("{vmName}"), + Location: to.Ptr("{location}"), + Properties: &armdevtestlabs.LabVirtualMachineCreationParameterProperties{ + AllowClaim: to.Ptr(true), + DisallowPublicIPAddress: to.Ptr(true), + GalleryImageReference: &armdevtestlabs.GalleryImageReference{ + Offer: to.Ptr("UbuntuServer"), + OSType: to.Ptr("Linux"), + Publisher: to.Ptr("Canonical"), + SKU: to.Ptr("16.04-LTS"), + Version: to.Ptr("Latest"), + }, + LabSubnetName: to.Ptr("{virtualnetwork-subnet-name}"), + LabVirtualNetworkID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualnetworks/{virtualNetworkName}"), + Password: to.Ptr("{userPassword}"), + Size: to.Ptr("Standard_A2_v2"), + StorageType: to.Ptr("Standard"), + UserName: to.Ptr("{userName}"), + }, + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + }, 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_ExportResourceUsage.json +func ExampleLabsClient_BeginExportResourceUsage() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewLabsClient().BeginExportResourceUsage(ctx, "resourceGroupName", "{labName}", armdevtestlabs.ExportResourceUsageParameters{ + BlobStorageAbsoluteSasURI: to.Ptr("https://invalid.blob.core.windows.net/export.blob?sv=2015-07-08&sig={sas}&sp=rcw"), + UsageStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T00:00:00Z"); return t }()), + }, 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_GenerateUploadUri.json +func ExampleLabsClient_GenerateUploadURI() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewLabsClient().GenerateUploadURI(ctx, "resourceGroupName", "{labName}", armdevtestlabs.GenerateUploadURIParameter{ + BlobName: to.Ptr("{blob-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.GenerateUploadURIResponse = armdevtestlabs.GenerateUploadURIResponse{ + // UploadURI: to.Ptr("https://{storageName}.blob.core.windows.net/uploads/{blobName}?sv=2017-04-17&sr=b&sig={signature}&st=2018-10-02T01:55:24Z&se=2018-10-03T02:10:23Z&sp=rcw"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_ImportVirtualMachine.json +func ExampleLabsClient_BeginImportVirtualMachine() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewLabsClient().BeginImportVirtualMachine(ctx, "resourceGroupName", "{labName}", armdevtestlabs.ImportLabVirtualMachineRequest{ + DestinationVirtualMachineName: to.Ptr("{vmName}"), + SourceVirtualMachineResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{otherResourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"), + }, 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_ListVhds.json +func ExampleLabsClient_NewListVhdsPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLabsClient().NewListVhdsPager("resourceGroupName", "{labName}", 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.LabVhdList = armdevtestlabs.LabVhdList{ + // Value: []*armdevtestlabs.LabVhd{ + // { + // ID: to.Ptr("https://{labStorageAccountName}.blob.core.windows.net/vhds/vhd1"), + // }, + // { + // ID: to.Ptr("https://{labStorageAccountName}.blob.core.windows.net/vhds/vhd2"), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_models.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/models.go similarity index 98% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_models.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/models.go index 1b6ae15e1876..4005881dc29f 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_models.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/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 armdevtestlabs @@ -77,10 +78,10 @@ type ArmTemplate struct { // ArmTemplateInfo - Information about a generated ARM template. type ArmTemplateInfo struct { // The parameters of the ARM template. - Parameters interface{} `json:"parameters,omitempty"` + Parameters any `json:"parameters,omitempty"` // The template's contents. - Template interface{} `json:"template,omitempty"` + Template any `json:"template,omitempty"` } // ArmTemplateList - The response of a list operation. @@ -104,7 +105,7 @@ type ArmTemplateParameterProperties struct { // ArmTemplateProperties - Properties of an Azure Resource Manager template. type ArmTemplateProperties struct { // READ-ONLY; The contents of the ARM template. - Contents interface{} `json:"contents,omitempty" azure:"ro"` + Contents any `json:"contents,omitempty" azure:"ro"` // READ-ONLY; The creation date of the armTemplate. CreatedDate *time.Time `json:"createdDate,omitempty" azure:"ro"` @@ -134,7 +135,7 @@ type ArmTemplatesClientGetOptions struct { Expand *string } -// ArmTemplatesClientListOptions contains the optional parameters for the ArmTemplatesClient.List method. +// ArmTemplatesClientListOptions contains the optional parameters for the ArmTemplatesClient.NewListPager method. type ArmTemplatesClientListOptions struct { // Specify the $expand query. Example: 'properties($select=displayName)' Expand *string @@ -236,7 +237,7 @@ type ArtifactProperties struct { Icon *string `json:"icon,omitempty" azure:"ro"` // READ-ONLY; The artifact's parameters. - Parameters interface{} `json:"parameters,omitempty" azure:"ro"` + Parameters any `json:"parameters,omitempty" azure:"ro"` // READ-ONLY; The artifact's publisher. Publisher *string `json:"publisher,omitempty" azure:"ro"` @@ -337,7 +338,7 @@ type ArtifactSourcesClientGetOptions struct { Expand *string } -// ArtifactSourcesClientListOptions contains the optional parameters for the ArtifactSourcesClient.List method. +// ArtifactSourcesClientListOptions contains the optional parameters for the ArtifactSourcesClient.NewListPager method. type ArtifactSourcesClientListOptions struct { // Specify the $expand query. Example: 'properties($select=displayName)' Expand *string @@ -366,7 +367,7 @@ type ArtifactsClientGetOptions struct { Expand *string } -// ArtifactsClientListOptions contains the optional parameters for the ArtifactsClient.List method. +// ArtifactsClientListOptions contains the optional parameters for the ArtifactsClient.NewListPager method. type ArtifactsClientListOptions struct { // Specify the $expand query. Example: 'properties($select=title)' Expand *string @@ -402,27 +403,6 @@ type BulkCreationParameters struct { InstanceCount *int32 `json:"instanceCount,omitempty"` } -// CloudError - Error from a REST request. -type CloudError struct { - // The cloud error that occurred - Error *CloudErrorBody `json:"error,omitempty"` -} - -// CloudErrorBody - Body of an error from a REST request. -type CloudErrorBody struct { - // The error code. - Code *string `json:"code,omitempty"` - - // Inner errors. - Details []*CloudErrorBody `json:"details,omitempty"` - - // The error message. - Message *string `json:"message,omitempty"` - - // The error target. - Target *string `json:"target,omitempty"` -} - // ComputeDataDisk - A data disks attached to a virtual machine. type ComputeDataDisk struct { // Gets data disk size in GiB. @@ -633,7 +613,7 @@ type CustomImagesClientGetOptions struct { Expand *string } -// CustomImagesClientListOptions contains the optional parameters for the CustomImagesClient.List method. +// CustomImagesClientListOptions contains the optional parameters for the CustomImagesClient.NewListPager method. type CustomImagesClientListOptions struct { // Specify the $expand query. Example: 'properties($select=vm)' Expand *string @@ -791,7 +771,7 @@ type DisksClientGetOptions struct { Expand *string } -// DisksClientListOptions contains the optional parameters for the DisksClient.List method. +// DisksClientListOptions contains the optional parameters for the DisksClient.NewListPager method. type DisksClientListOptions struct { // Specify the $expand query. Example: 'properties($select=diskType)' Expand *string @@ -893,7 +873,7 @@ type EnvironmentsClientGetOptions struct { Expand *string } -// EnvironmentsClientListOptions contains the optional parameters for the EnvironmentsClient.List method. +// EnvironmentsClientListOptions contains the optional parameters for the EnvironmentsClient.NewListPager method. type EnvironmentsClientListOptions struct { // Specify the $expand query. Example: 'properties($select=deploymentProperties)' Expand *string @@ -1047,7 +1027,7 @@ type FormulasClientGetOptions struct { Expand *string } -// FormulasClientListOptions contains the optional parameters for the FormulasClient.List method. +// FormulasClientListOptions contains the optional parameters for the FormulasClient.NewListPager method. type FormulasClientListOptions struct { // Specify the $expand query. Example: 'properties($select=description)' Expand *string @@ -1139,7 +1119,7 @@ type GalleryImageReference struct { Version *string `json:"version,omitempty"` } -// GalleryImagesClientListOptions contains the optional parameters for the GalleryImagesClient.List method. +// GalleryImagesClientListOptions contains the optional parameters for the GalleryImagesClient.NewListPager method. type GalleryImagesClientListOptions struct { // Specify the $expand query. Example: 'properties($select=author)' Expand *string @@ -1208,7 +1188,7 @@ type GlobalSchedulesClientGetOptions struct { Expand *string } -// GlobalSchedulesClientListByResourceGroupOptions contains the optional parameters for the GlobalSchedulesClient.ListByResourceGroup +// GlobalSchedulesClientListByResourceGroupOptions contains the optional parameters for the GlobalSchedulesClient.NewListByResourceGroupPager // method. type GlobalSchedulesClientListByResourceGroupOptions struct { // Specify the $expand query. Example: 'properties($select=status)' @@ -1221,7 +1201,7 @@ type GlobalSchedulesClientListByResourceGroupOptions struct { Top *int32 } -// GlobalSchedulesClientListBySubscriptionOptions contains the optional parameters for the GlobalSchedulesClient.ListBySubscription +// GlobalSchedulesClientListBySubscriptionOptions contains the optional parameters for the GlobalSchedulesClient.NewListBySubscriptionPager // method. type GlobalSchedulesClientListBySubscriptionOptions struct { // Specify the $expand query. Example: 'properties($select=status)' @@ -1820,7 +1800,7 @@ type LabsClientGetOptions struct { Expand *string } -// LabsClientListByResourceGroupOptions contains the optional parameters for the LabsClient.ListByResourceGroup method. +// LabsClientListByResourceGroupOptions contains the optional parameters for the LabsClient.NewListByResourceGroupPager method. type LabsClientListByResourceGroupOptions struct { // Specify the $expand query. Example: 'properties($select=defaultStorageAccount)' Expand *string @@ -1832,7 +1812,7 @@ type LabsClientListByResourceGroupOptions struct { Top *int32 } -// LabsClientListBySubscriptionOptions contains the optional parameters for the LabsClient.ListBySubscription method. +// LabsClientListBySubscriptionOptions contains the optional parameters for the LabsClient.NewListBySubscriptionPager method. type LabsClientListBySubscriptionOptions struct { // Specify the $expand query. Example: 'properties($select=defaultStorageAccount)' Expand *string @@ -1844,7 +1824,7 @@ type LabsClientListBySubscriptionOptions struct { Top *int32 } -// LabsClientListVhdsOptions contains the optional parameters for the LabsClient.ListVhds method. +// LabsClientListVhdsOptions contains the optional parameters for the LabsClient.NewListVhdsPager method. type LabsClientListVhdsOptions struct { // placeholder for future optional parameters } @@ -1971,7 +1951,8 @@ type NotificationChannelsClientGetOptions struct { Expand *string } -// NotificationChannelsClientListOptions contains the optional parameters for the NotificationChannelsClient.List method. +// NotificationChannelsClientListOptions contains the optional parameters for the NotificationChannelsClient.NewListPager +// method. type NotificationChannelsClientListOptions struct { // Specify the $expand query. Example: 'properties($select=webHookUrl)' Expand *string @@ -2085,7 +2066,7 @@ type ParametersValueFileInfo struct { FileName *string `json:"fileName,omitempty"` // Contents of the file. - ParametersValueInfo interface{} `json:"parametersValueInfo,omitempty"` + ParametersValueInfo any `json:"parametersValueInfo,omitempty"` } // PercentageCostThresholdProperties - Properties of a percentage cost threshold. @@ -2110,7 +2091,7 @@ type PoliciesClientGetOptions struct { Expand *string } -// PoliciesClientListOptions contains the optional parameters for the PoliciesClient.List method. +// PoliciesClientListOptions contains the optional parameters for the PoliciesClient.NewListPager method. type PoliciesClientListOptions struct { // Specify the $expand query. Example: 'properties($select=description)' Expand *string @@ -2234,7 +2215,7 @@ type ProviderOperationResult struct { NextLink *string `json:"nextLink,omitempty" azure:"ro"` } -// ProviderOperationsClientListOptions contains the optional parameters for the ProviderOperationsClient.List method. +// ProviderOperationsClientListOptions contains the optional parameters for the ProviderOperationsClient.NewListPager method. type ProviderOperationsClientListOptions struct { // placeholder for future optional parameters } @@ -2414,12 +2395,12 @@ type SchedulesClientGetOptions struct { Expand *string } -// SchedulesClientListApplicableOptions contains the optional parameters for the SchedulesClient.ListApplicable method. +// SchedulesClientListApplicableOptions contains the optional parameters for the SchedulesClient.NewListApplicablePager method. type SchedulesClientListApplicableOptions struct { // placeholder for future optional parameters } -// SchedulesClientListOptions contains the optional parameters for the SchedulesClient.List method. +// SchedulesClientListOptions contains the optional parameters for the SchedulesClient.NewListPager method. type SchedulesClientListOptions struct { // Specify the $expand query. Example: 'properties($select=status)' Expand *string @@ -2501,7 +2482,7 @@ type SecretsClientGetOptions struct { Expand *string } -// SecretsClientListOptions contains the optional parameters for the SecretsClient.List method. +// SecretsClientListOptions contains the optional parameters for the SecretsClient.NewListPager method. type SecretsClientListOptions struct { // Specify the $expand query. Example: 'properties($select=value)' Expand *string @@ -2597,7 +2578,8 @@ type ServiceFabricSchedulesClientGetOptions struct { Expand *string } -// ServiceFabricSchedulesClientListOptions contains the optional parameters for the ServiceFabricSchedulesClient.List method. +// ServiceFabricSchedulesClientListOptions contains the optional parameters for the ServiceFabricSchedulesClient.NewListPager +// method. type ServiceFabricSchedulesClientListOptions struct { // Specify the $expand query. Example: 'properties($select=status)' Expand *string @@ -2652,7 +2634,7 @@ type ServiceFabricsClientListApplicableSchedulesOptions struct { // placeholder for future optional parameters } -// ServiceFabricsClientListOptions contains the optional parameters for the ServiceFabricsClient.List method. +// ServiceFabricsClientListOptions contains the optional parameters for the ServiceFabricsClient.NewListPager method. type ServiceFabricsClientListOptions struct { // Specify the $expand query. Example: 'properties($expand=applicableSchedule)' Expand *string @@ -2930,7 +2912,7 @@ type UsersClientGetOptions struct { Expand *string } -// UsersClientListOptions contains the optional parameters for the UsersClient.List method. +// UsersClientListOptions contains the optional parameters for the UsersClient.NewListPager method. type UsersClientListOptions struct { // Specify the $expand query. Example: 'properties($select=identity)' Expand *string @@ -2972,7 +2954,8 @@ type VirtualMachineSchedulesClientGetOptions struct { Expand *string } -// VirtualMachineSchedulesClientListOptions contains the optional parameters for the VirtualMachineSchedulesClient.List method. +// VirtualMachineSchedulesClientListOptions contains the optional parameters for the VirtualMachineSchedulesClient.NewListPager +// method. type VirtualMachineSchedulesClientListOptions struct { // Specify the $expand query. Example: 'properties($select=status)' Expand *string @@ -3092,7 +3075,7 @@ type VirtualMachinesClientListApplicableSchedulesOptions struct { // placeholder for future optional parameters } -// VirtualMachinesClientListOptions contains the optional parameters for the VirtualMachinesClient.List method. +// VirtualMachinesClientListOptions contains the optional parameters for the VirtualMachinesClient.NewListPager method. type VirtualMachinesClientListOptions struct { // Specify the $expand query. Example: 'properties($expand=artifacts,computeVm,networkInterface,applicableSchedule)' Expand *string @@ -3191,7 +3174,7 @@ type VirtualNetworksClientGetOptions struct { Expand *string } -// VirtualNetworksClientListOptions contains the optional parameters for the VirtualNetworksClient.List method. +// VirtualNetworksClientListOptions contains the optional parameters for the VirtualNetworksClient.NewListPager method. type VirtualNetworksClientListOptions struct { // Specify the $expand query. Example: 'properties($expand=externalSubnets)' Expand *string diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/models_serde.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/models_serde.go new file mode 100644 index 000000000000..037cbe4f428e --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/models_serde.go @@ -0,0 +1,5919 @@ +//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 armdevtestlabs + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ApplicableSchedule. +func (a ApplicableSchedule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicableSchedule. +func (a *ApplicableSchedule) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + 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 ApplicableScheduleFragment. +func (a ApplicableScheduleFragment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicableScheduleFragment. +func (a *ApplicableScheduleFragment) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &a.Tags) + 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 ApplicableScheduleProperties. +func (a ApplicableScheduleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "labVmsShutdown", a.LabVMsShutdown) + populate(objectMap, "labVmsStartup", a.LabVMsStartup) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicableScheduleProperties. +func (a *ApplicableScheduleProperties) UnmarshalJSON(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 "labVmsShutdown": + err = unpopulate(val, "LabVMsShutdown", &a.LabVMsShutdown) + delete(rawMsg, key) + case "labVmsStartup": + err = unpopulate(val, "LabVMsStartup", &a.LabVMsStartup) + 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 ApplyArtifactsRequest. +func (a ApplyArtifactsRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "artifacts", a.Artifacts) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplyArtifactsRequest. +func (a *ApplyArtifactsRequest) UnmarshalJSON(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 "artifacts": + err = unpopulate(val, "Artifacts", &a.Artifacts) + 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 ArmTemplate. +func (a ArmTemplate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ArmTemplate. +func (a *ArmTemplate) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + 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 ArmTemplateInfo. +func (a ArmTemplateInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "parameters", &a.Parameters) + populate(objectMap, "template", &a.Template) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ArmTemplateInfo. +func (a *ArmTemplateInfo) UnmarshalJSON(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 "parameters": + err = unpopulate(val, "Parameters", &a.Parameters) + delete(rawMsg, key) + case "template": + err = unpopulate(val, "Template", &a.Template) + 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 ArmTemplateList. +func (a ArmTemplateList) 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 ArmTemplateList. +func (a *ArmTemplateList) UnmarshalJSON(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 ArmTemplateParameterProperties. +func (a ArmTemplateParameterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", a.Name) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ArmTemplateParameterProperties. +func (a *ArmTemplateParameterProperties) UnmarshalJSON(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 "name": + err = unpopulate(val, "Name", &a.Name) + 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 ArmTemplateProperties. +func (a ArmTemplateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contents", &a.Contents) + populateTimeRFC3339(objectMap, "createdDate", a.CreatedDate) + populate(objectMap, "description", a.Description) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "enabled", a.Enabled) + populate(objectMap, "icon", a.Icon) + populate(objectMap, "parametersValueFilesInfo", a.ParametersValueFilesInfo) + populate(objectMap, "publisher", a.Publisher) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ArmTemplateProperties. +func (a *ArmTemplateProperties) UnmarshalJSON(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 "contents": + err = unpopulate(val, "Contents", &a.Contents) + delete(rawMsg, key) + case "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &a.CreatedDate) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &a.DisplayName) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, "Enabled", &a.Enabled) + delete(rawMsg, key) + case "icon": + err = unpopulate(val, "Icon", &a.Icon) + delete(rawMsg, key) + case "parametersValueFilesInfo": + err = unpopulate(val, "ParametersValueFilesInfo", &a.ParametersValueFilesInfo) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &a.Publisher) + 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 Artifact. +func (a Artifact) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Artifact. +func (a *Artifact) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + 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 ArtifactDeploymentStatusProperties. +func (a ArtifactDeploymentStatusProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "artifactsApplied", a.ArtifactsApplied) + populate(objectMap, "deploymentStatus", a.DeploymentStatus) + populate(objectMap, "totalArtifacts", a.TotalArtifacts) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ArtifactDeploymentStatusProperties. +func (a *ArtifactDeploymentStatusProperties) UnmarshalJSON(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 "artifactsApplied": + err = unpopulate(val, "ArtifactsApplied", &a.ArtifactsApplied) + delete(rawMsg, key) + case "deploymentStatus": + err = unpopulate(val, "DeploymentStatus", &a.DeploymentStatus) + delete(rawMsg, key) + case "totalArtifacts": + err = unpopulate(val, "TotalArtifacts", &a.TotalArtifacts) + 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 ArtifactInstallProperties. +func (a ArtifactInstallProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "artifactId", a.ArtifactID) + populate(objectMap, "artifactTitle", a.ArtifactTitle) + populate(objectMap, "deploymentStatusMessage", a.DeploymentStatusMessage) + populateTimeRFC3339(objectMap, "installTime", a.InstallTime) + populate(objectMap, "parameters", a.Parameters) + populate(objectMap, "status", a.Status) + populate(objectMap, "vmExtensionStatusMessage", a.VMExtensionStatusMessage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ArtifactInstallProperties. +func (a *ArtifactInstallProperties) UnmarshalJSON(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 "artifactId": + err = unpopulate(val, "ArtifactID", &a.ArtifactID) + delete(rawMsg, key) + case "artifactTitle": + err = unpopulate(val, "ArtifactTitle", &a.ArtifactTitle) + delete(rawMsg, key) + case "deploymentStatusMessage": + err = unpopulate(val, "DeploymentStatusMessage", &a.DeploymentStatusMessage) + delete(rawMsg, key) + case "installTime": + err = unpopulateTimeRFC3339(val, "InstallTime", &a.InstallTime) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &a.Parameters) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + case "vmExtensionStatusMessage": + err = unpopulate(val, "VMExtensionStatusMessage", &a.VMExtensionStatusMessage) + 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 ArtifactList. +func (a ArtifactList) 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 ArtifactList. +func (a *ArtifactList) UnmarshalJSON(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 ArtifactParameterProperties. +func (a ArtifactParameterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", a.Name) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ArtifactParameterProperties. +func (a *ArtifactParameterProperties) UnmarshalJSON(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 "name": + err = unpopulate(val, "Name", &a.Name) + 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 ArtifactProperties. +func (a ArtifactProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdDate", a.CreatedDate) + populate(objectMap, "description", a.Description) + populate(objectMap, "filePath", a.FilePath) + populate(objectMap, "icon", a.Icon) + populate(objectMap, "parameters", &a.Parameters) + populate(objectMap, "publisher", a.Publisher) + populate(objectMap, "targetOsType", a.TargetOsType) + populate(objectMap, "title", a.Title) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ArtifactProperties. +func (a *ArtifactProperties) UnmarshalJSON(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 "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &a.CreatedDate) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "filePath": + err = unpopulate(val, "FilePath", &a.FilePath) + delete(rawMsg, key) + case "icon": + err = unpopulate(val, "Icon", &a.Icon) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &a.Parameters) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &a.Publisher) + delete(rawMsg, key) + case "targetOsType": + err = unpopulate(val, "TargetOsType", &a.TargetOsType) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &a.Title) + 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 ArtifactSource. +func (a ArtifactSource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ArtifactSource. +func (a *ArtifactSource) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + 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 ArtifactSourceFragment. +func (a ArtifactSourceFragment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ArtifactSourceFragment. +func (a *ArtifactSourceFragment) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &a.Tags) + 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 ArtifactSourceList. +func (a ArtifactSourceList) 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 ArtifactSourceList. +func (a *ArtifactSourceList) UnmarshalJSON(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 ArtifactSourceProperties. +func (a ArtifactSourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "armTemplateFolderPath", a.ArmTemplateFolderPath) + populate(objectMap, "branchRef", a.BranchRef) + populateTimeRFC3339(objectMap, "createdDate", a.CreatedDate) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "folderPath", a.FolderPath) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "securityToken", a.SecurityToken) + populate(objectMap, "sourceType", a.SourceType) + populate(objectMap, "status", a.Status) + populate(objectMap, "uri", a.URI) + populate(objectMap, "uniqueIdentifier", a.UniqueIdentifier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ArtifactSourceProperties. +func (a *ArtifactSourceProperties) UnmarshalJSON(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 "armTemplateFolderPath": + err = unpopulate(val, "ArmTemplateFolderPath", &a.ArmTemplateFolderPath) + delete(rawMsg, key) + case "branchRef": + err = unpopulate(val, "BranchRef", &a.BranchRef) + delete(rawMsg, key) + case "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &a.CreatedDate) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &a.DisplayName) + delete(rawMsg, key) + case "folderPath": + err = unpopulate(val, "FolderPath", &a.FolderPath) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "securityToken": + err = unpopulate(val, "SecurityToken", &a.SecurityToken) + delete(rawMsg, key) + case "sourceType": + err = unpopulate(val, "SourceType", &a.SourceType) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + case "uri": + err = unpopulate(val, "URI", &a.URI) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &a.UniqueIdentifier) + 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 AttachDiskProperties. +func (a AttachDiskProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "leasedByLabVmId", a.LeasedByLabVMID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AttachDiskProperties. +func (a *AttachDiskProperties) UnmarshalJSON(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 "leasedByLabVmId": + err = unpopulate(val, "LeasedByLabVMID", &a.LeasedByLabVMID) + 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 AttachNewDataDiskOptions. +func (a AttachNewDataDiskOptions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "diskName", a.DiskName) + populate(objectMap, "diskSizeGiB", a.DiskSizeGiB) + populate(objectMap, "diskType", a.DiskType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AttachNewDataDiskOptions. +func (a *AttachNewDataDiskOptions) UnmarshalJSON(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 "diskName": + err = unpopulate(val, "DiskName", &a.DiskName) + delete(rawMsg, key) + case "diskSizeGiB": + err = unpopulate(val, "DiskSizeGiB", &a.DiskSizeGiB) + delete(rawMsg, key) + case "diskType": + err = unpopulate(val, "DiskType", &a.DiskType) + 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 BulkCreationParameters. +func (b BulkCreationParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "instanceCount", b.InstanceCount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BulkCreationParameters. +func (b *BulkCreationParameters) UnmarshalJSON(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 "instanceCount": + err = unpopulate(val, "InstanceCount", &b.InstanceCount) + 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 ComputeDataDisk. +func (c ComputeDataDisk) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "diskSizeGiB", c.DiskSizeGiB) + populate(objectMap, "diskUri", c.DiskURI) + populate(objectMap, "managedDiskId", c.ManagedDiskID) + populate(objectMap, "name", c.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ComputeDataDisk. +func (c *ComputeDataDisk) UnmarshalJSON(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 "diskSizeGiB": + err = unpopulate(val, "DiskSizeGiB", &c.DiskSizeGiB) + delete(rawMsg, key) + case "diskUri": + err = unpopulate(val, "DiskURI", &c.DiskURI) + delete(rawMsg, key) + case "managedDiskId": + err = unpopulate(val, "ManagedDiskID", &c.ManagedDiskID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + 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 ComputeVMInstanceViewStatus. +func (c ComputeVMInstanceViewStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", c.Code) + populate(objectMap, "displayStatus", c.DisplayStatus) + populate(objectMap, "message", c.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ComputeVMInstanceViewStatus. +func (c *ComputeVMInstanceViewStatus) UnmarshalJSON(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 "code": + err = unpopulate(val, "Code", &c.Code) + delete(rawMsg, key) + case "displayStatus": + err = unpopulate(val, "DisplayStatus", &c.DisplayStatus) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &c.Message) + 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 ComputeVMProperties. +func (c ComputeVMProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dataDiskIds", c.DataDiskIDs) + populate(objectMap, "dataDisks", c.DataDisks) + populate(objectMap, "networkInterfaceId", c.NetworkInterfaceID) + populate(objectMap, "osDiskId", c.OSDiskID) + populate(objectMap, "osType", c.OSType) + populate(objectMap, "statuses", c.Statuses) + populate(objectMap, "vmSize", c.VMSize) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ComputeVMProperties. +func (c *ComputeVMProperties) UnmarshalJSON(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 "dataDiskIds": + err = unpopulate(val, "DataDiskIDs", &c.DataDiskIDs) + delete(rawMsg, key) + case "dataDisks": + err = unpopulate(val, "DataDisks", &c.DataDisks) + delete(rawMsg, key) + case "networkInterfaceId": + err = unpopulate(val, "NetworkInterfaceID", &c.NetworkInterfaceID) + delete(rawMsg, key) + case "osDiskId": + err = unpopulate(val, "OSDiskID", &c.OSDiskID) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, "OSType", &c.OSType) + delete(rawMsg, key) + case "statuses": + err = unpopulate(val, "Statuses", &c.Statuses) + delete(rawMsg, key) + case "vmSize": + err = unpopulate(val, "VMSize", &c.VMSize) + 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 CostThresholdProperties. +func (c CostThresholdProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayOnChart", c.DisplayOnChart) + populate(objectMap, "notificationSent", c.NotificationSent) + populate(objectMap, "percentageThreshold", c.PercentageThreshold) + populate(objectMap, "sendNotificationWhenExceeded", c.SendNotificationWhenExceeded) + populate(objectMap, "thresholdId", c.ThresholdID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CostThresholdProperties. +func (c *CostThresholdProperties) UnmarshalJSON(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 "displayOnChart": + err = unpopulate(val, "DisplayOnChart", &c.DisplayOnChart) + delete(rawMsg, key) + case "notificationSent": + err = unpopulate(val, "NotificationSent", &c.NotificationSent) + delete(rawMsg, key) + case "percentageThreshold": + err = unpopulate(val, "PercentageThreshold", &c.PercentageThreshold) + delete(rawMsg, key) + case "sendNotificationWhenExceeded": + err = unpopulate(val, "SendNotificationWhenExceeded", &c.SendNotificationWhenExceeded) + delete(rawMsg, key) + case "thresholdId": + err = unpopulate(val, "ThresholdID", &c.ThresholdID) + 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 CustomImage. +func (c CustomImage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomImage. +func (c *CustomImage) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &c.Location) + 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 "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 CustomImageFragment. +func (c CustomImageFragment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomImageFragment. +func (c *CustomImageFragment) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &c.Tags) + 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 CustomImageList. +func (c CustomImageList) 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 CustomImageList. +func (c *CustomImageList) UnmarshalJSON(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 CustomImageProperties. +func (c CustomImageProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "author", c.Author) + populateTimeRFC3339(objectMap, "creationDate", c.CreationDate) + populate(objectMap, "customImagePlan", c.CustomImagePlan) + populate(objectMap, "dataDiskStorageInfo", c.DataDiskStorageInfo) + populate(objectMap, "description", c.Description) + populate(objectMap, "isPlanAuthorized", c.IsPlanAuthorized) + populate(objectMap, "managedImageId", c.ManagedImageID) + populate(objectMap, "managedSnapshotId", c.ManagedSnapshotID) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "uniqueIdentifier", c.UniqueIdentifier) + populate(objectMap, "vm", c.VM) + populate(objectMap, "vhd", c.Vhd) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomImageProperties. +func (c *CustomImageProperties) UnmarshalJSON(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 "author": + err = unpopulate(val, "Author", &c.Author) + delete(rawMsg, key) + case "creationDate": + err = unpopulateTimeRFC3339(val, "CreationDate", &c.CreationDate) + delete(rawMsg, key) + case "customImagePlan": + err = unpopulate(val, "CustomImagePlan", &c.CustomImagePlan) + delete(rawMsg, key) + case "dataDiskStorageInfo": + err = unpopulate(val, "DataDiskStorageInfo", &c.DataDiskStorageInfo) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &c.Description) + delete(rawMsg, key) + case "isPlanAuthorized": + err = unpopulate(val, "IsPlanAuthorized", &c.IsPlanAuthorized) + delete(rawMsg, key) + case "managedImageId": + err = unpopulate(val, "ManagedImageID", &c.ManagedImageID) + delete(rawMsg, key) + case "managedSnapshotId": + err = unpopulate(val, "ManagedSnapshotID", &c.ManagedSnapshotID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &c.UniqueIdentifier) + delete(rawMsg, key) + case "vm": + err = unpopulate(val, "VM", &c.VM) + delete(rawMsg, key) + case "vhd": + err = unpopulate(val, "Vhd", &c.Vhd) + 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 CustomImagePropertiesCustom. +func (c CustomImagePropertiesCustom) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "imageName", c.ImageName) + populate(objectMap, "osType", c.OSType) + populate(objectMap, "sysPrep", c.SysPrep) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomImagePropertiesCustom. +func (c *CustomImagePropertiesCustom) UnmarshalJSON(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 "imageName": + err = unpopulate(val, "ImageName", &c.ImageName) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, "OSType", &c.OSType) + delete(rawMsg, key) + case "sysPrep": + err = unpopulate(val, "SysPrep", &c.SysPrep) + 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 CustomImagePropertiesFromPlan. +func (c CustomImagePropertiesFromPlan) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "offer", c.Offer) + populate(objectMap, "publisher", c.Publisher) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomImagePropertiesFromPlan. +func (c *CustomImagePropertiesFromPlan) UnmarshalJSON(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 "offer": + err = unpopulate(val, "Offer", &c.Offer) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &c.Publisher) + 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 CustomImagePropertiesFromVM. +func (c CustomImagePropertiesFromVM) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "linuxOsInfo", c.LinuxOsInfo) + populate(objectMap, "sourceVmId", c.SourceVMID) + populate(objectMap, "windowsOsInfo", c.WindowsOsInfo) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomImagePropertiesFromVM. +func (c *CustomImagePropertiesFromVM) UnmarshalJSON(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 "linuxOsInfo": + err = unpopulate(val, "LinuxOsInfo", &c.LinuxOsInfo) + delete(rawMsg, key) + case "sourceVmId": + err = unpopulate(val, "SourceVMID", &c.SourceVMID) + delete(rawMsg, key) + case "windowsOsInfo": + err = unpopulate(val, "WindowsOsInfo", &c.WindowsOsInfo) + 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 DataDiskProperties. +func (d DataDiskProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "attachNewDataDiskOptions", d.AttachNewDataDiskOptions) + populate(objectMap, "existingLabDiskId", d.ExistingLabDiskID) + populate(objectMap, "hostCaching", d.HostCaching) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataDiskProperties. +func (d *DataDiskProperties) UnmarshalJSON(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 "attachNewDataDiskOptions": + err = unpopulate(val, "AttachNewDataDiskOptions", &d.AttachNewDataDiskOptions) + delete(rawMsg, key) + case "existingLabDiskId": + err = unpopulate(val, "ExistingLabDiskID", &d.ExistingLabDiskID) + delete(rawMsg, key) + case "hostCaching": + err = unpopulate(val, "HostCaching", &d.HostCaching) + 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 DataDiskStorageTypeInfo. +func (d DataDiskStorageTypeInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "lun", d.Lun) + populate(objectMap, "storageType", d.StorageType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataDiskStorageTypeInfo. +func (d *DataDiskStorageTypeInfo) UnmarshalJSON(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 "lun": + err = unpopulate(val, "Lun", &d.Lun) + delete(rawMsg, key) + case "storageType": + err = unpopulate(val, "StorageType", &d.StorageType) + 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 DayDetails. +func (d DayDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "time", d.Time) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DayDetails. +func (d *DayDetails) UnmarshalJSON(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 "time": + err = unpopulate(val, "Time", &d.Time) + 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 DetachDataDiskProperties. +func (d DetachDataDiskProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "existingLabDiskId", d.ExistingLabDiskID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DetachDataDiskProperties. +func (d *DetachDataDiskProperties) UnmarshalJSON(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 "existingLabDiskId": + err = unpopulate(val, "ExistingLabDiskID", &d.ExistingLabDiskID) + 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 DetachDiskProperties. +func (d DetachDiskProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "leasedByLabVmId", d.LeasedByLabVMID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DetachDiskProperties. +func (d *DetachDiskProperties) UnmarshalJSON(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 "leasedByLabVmId": + err = unpopulate(val, "LeasedByLabVMID", &d.LeasedByLabVMID) + 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 Disk. +func (d Disk) 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, "tags", d.Tags) + populate(objectMap, "type", d.Type) + 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 "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 "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 DiskFragment. +func (d DiskFragment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", d.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiskFragment. +func (d *DiskFragment) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &d.Tags) + 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 DiskList. +func (d DiskList) 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 DiskList. +func (d *DiskList) UnmarshalJSON(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 DiskProperties. +func (d DiskProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdDate", d.CreatedDate) + populate(objectMap, "diskBlobName", d.DiskBlobName) + populate(objectMap, "diskSizeGiB", d.DiskSizeGiB) + populate(objectMap, "diskType", d.DiskType) + populate(objectMap, "diskUri", d.DiskURI) + populate(objectMap, "hostCaching", d.HostCaching) + populate(objectMap, "leasedByLabVmId", d.LeasedByLabVMID) + populate(objectMap, "managedDiskId", d.ManagedDiskID) + populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "storageAccountId", d.StorageAccountID) + populate(objectMap, "uniqueIdentifier", d.UniqueIdentifier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiskProperties. +func (d *DiskProperties) UnmarshalJSON(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 "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &d.CreatedDate) + delete(rawMsg, key) + case "diskBlobName": + err = unpopulate(val, "DiskBlobName", &d.DiskBlobName) + delete(rawMsg, key) + case "diskSizeGiB": + err = unpopulate(val, "DiskSizeGiB", &d.DiskSizeGiB) + delete(rawMsg, key) + case "diskType": + err = unpopulate(val, "DiskType", &d.DiskType) + delete(rawMsg, key) + case "diskUri": + err = unpopulate(val, "DiskURI", &d.DiskURI) + delete(rawMsg, key) + case "hostCaching": + err = unpopulate(val, "HostCaching", &d.HostCaching) + delete(rawMsg, key) + case "leasedByLabVmId": + err = unpopulate(val, "LeasedByLabVMID", &d.LeasedByLabVMID) + delete(rawMsg, key) + case "managedDiskId": + err = unpopulate(val, "ManagedDiskID", &d.ManagedDiskID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + case "storageAccountId": + err = unpopulate(val, "StorageAccountID", &d.StorageAccountID) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &d.UniqueIdentifier) + 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 DtlEnvironment. +func (d DtlEnvironment) 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, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DtlEnvironment. +func (d *DtlEnvironment) UnmarshalJSON(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 "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 DtlEnvironmentFragment. +func (d DtlEnvironmentFragment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", d.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DtlEnvironmentFragment. +func (d *DtlEnvironmentFragment) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &d.Tags) + 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 DtlEnvironmentList. +func (d DtlEnvironmentList) 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 DtlEnvironmentList. +func (d *DtlEnvironmentList) UnmarshalJSON(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 EnvironmentDeploymentProperties. +func (e EnvironmentDeploymentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "armTemplateId", e.ArmTemplateID) + populate(objectMap, "parameters", e.Parameters) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentDeploymentProperties. +func (e *EnvironmentDeploymentProperties) UnmarshalJSON(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 "armTemplateId": + err = unpopulate(val, "ArmTemplateID", &e.ArmTemplateID) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &e.Parameters) + 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 EnvironmentProperties. +func (e EnvironmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "armTemplateDisplayName", e.ArmTemplateDisplayName) + populate(objectMap, "createdByUser", e.CreatedByUser) + populate(objectMap, "deploymentProperties", e.DeploymentProperties) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "resourceGroupId", e.ResourceGroupID) + populate(objectMap, "uniqueIdentifier", e.UniqueIdentifier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentProperties. +func (e *EnvironmentProperties) UnmarshalJSON(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 "armTemplateDisplayName": + err = unpopulate(val, "ArmTemplateDisplayName", &e.ArmTemplateDisplayName) + delete(rawMsg, key) + case "createdByUser": + err = unpopulate(val, "CreatedByUser", &e.CreatedByUser) + delete(rawMsg, key) + case "deploymentProperties": + err = unpopulate(val, "DeploymentProperties", &e.DeploymentProperties) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + case "resourceGroupId": + err = unpopulate(val, "ResourceGroupID", &e.ResourceGroupID) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &e.UniqueIdentifier) + 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 EvaluatePoliciesProperties. +func (e EvaluatePoliciesProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "factData", e.FactData) + populate(objectMap, "factName", e.FactName) + populate(objectMap, "userObjectId", e.UserObjectID) + populate(objectMap, "valueOffset", e.ValueOffset) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EvaluatePoliciesProperties. +func (e *EvaluatePoliciesProperties) UnmarshalJSON(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 "factData": + err = unpopulate(val, "FactData", &e.FactData) + delete(rawMsg, key) + case "factName": + err = unpopulate(val, "FactName", &e.FactName) + delete(rawMsg, key) + case "userObjectId": + err = unpopulate(val, "UserObjectID", &e.UserObjectID) + delete(rawMsg, key) + case "valueOffset": + err = unpopulate(val, "ValueOffset", &e.ValueOffset) + 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 EvaluatePoliciesRequest. +func (e EvaluatePoliciesRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "policies", e.Policies) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EvaluatePoliciesRequest. +func (e *EvaluatePoliciesRequest) UnmarshalJSON(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 "policies": + err = unpopulate(val, "Policies", &e.Policies) + 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 EvaluatePoliciesResponse. +func (e EvaluatePoliciesResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "results", e.Results) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EvaluatePoliciesResponse. +func (e *EvaluatePoliciesResponse) UnmarshalJSON(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 "results": + err = unpopulate(val, "Results", &e.Results) + 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 Event. +func (e Event) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eventName", e.EventName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Event. +func (e *Event) UnmarshalJSON(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 "eventName": + err = unpopulate(val, "EventName", &e.EventName) + 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 ExportResourceUsageParameters. +func (e ExportResourceUsageParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "blobStorageAbsoluteSasUri", e.BlobStorageAbsoluteSasURI) + populateTimeRFC3339(objectMap, "usageStartDate", e.UsageStartDate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportResourceUsageParameters. +func (e *ExportResourceUsageParameters) UnmarshalJSON(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 "blobStorageAbsoluteSasUri": + err = unpopulate(val, "BlobStorageAbsoluteSasURI", &e.BlobStorageAbsoluteSasURI) + delete(rawMsg, key) + case "usageStartDate": + err = unpopulateTimeRFC3339(val, "UsageStartDate", &e.UsageStartDate) + 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 ExternalSubnet. +func (e ExternalSubnet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExternalSubnet. +func (e *ExternalSubnet) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Formula. +func (f Formula) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + populate(objectMap, "location", f.Location) + populate(objectMap, "name", f.Name) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "tags", f.Tags) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Formula. +func (f *Formula) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &f.Location) + 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 "tags": + err = unpopulate(val, "Tags", &f.Tags) + 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 FormulaFragment. +func (f FormulaFragment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", f.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FormulaFragment. +func (f *FormulaFragment) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &f.Tags) + 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 FormulaList. +func (f FormulaList) 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 FormulaList. +func (f *FormulaList) UnmarshalJSON(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 FormulaProperties. +func (f FormulaProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "author", f.Author) + populateTimeRFC3339(objectMap, "creationDate", f.CreationDate) + populate(objectMap, "description", f.Description) + populate(objectMap, "formulaContent", f.FormulaContent) + populate(objectMap, "osType", f.OSType) + populate(objectMap, "provisioningState", f.ProvisioningState) + populate(objectMap, "uniqueIdentifier", f.UniqueIdentifier) + populate(objectMap, "vm", f.VM) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FormulaProperties. +func (f *FormulaProperties) UnmarshalJSON(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 "author": + err = unpopulate(val, "Author", &f.Author) + delete(rawMsg, key) + case "creationDate": + err = unpopulateTimeRFC3339(val, "CreationDate", &f.CreationDate) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &f.Description) + delete(rawMsg, key) + case "formulaContent": + err = unpopulate(val, "FormulaContent", &f.FormulaContent) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, "OSType", &f.OSType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &f.ProvisioningState) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &f.UniqueIdentifier) + delete(rawMsg, key) + case "vm": + err = unpopulate(val, "VM", &f.VM) + 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 FormulaPropertiesFromVM. +func (f FormulaPropertiesFromVM) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "labVmId", f.LabVMID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FormulaPropertiesFromVM. +func (f *FormulaPropertiesFromVM) UnmarshalJSON(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 "labVmId": + err = unpopulate(val, "LabVMID", &f.LabVMID) + 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 GalleryImage. +func (g GalleryImage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", g.ID) + populate(objectMap, "location", g.Location) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "tags", g.Tags) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GalleryImage. +func (g *GalleryImage) UnmarshalJSON(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 "id": + err = unpopulate(val, "ID", &g.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &g.Location) + 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 "tags": + err = unpopulate(val, "Tags", &g.Tags) + 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 GalleryImageList. +func (g GalleryImageList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GalleryImageList. +func (g *GalleryImageList) UnmarshalJSON(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 "nextLink": + err = unpopulate(val, "NextLink", &g.NextLink) + delete(rawMsg, 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 GalleryImageProperties. +func (g GalleryImageProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "author", g.Author) + populateTimeRFC3339(objectMap, "createdDate", g.CreatedDate) + populate(objectMap, "description", g.Description) + populate(objectMap, "enabled", g.Enabled) + populate(objectMap, "icon", g.Icon) + populate(objectMap, "imageReference", g.ImageReference) + populate(objectMap, "isPlanAuthorized", g.IsPlanAuthorized) + populate(objectMap, "planId", g.PlanID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GalleryImageProperties. +func (g *GalleryImageProperties) UnmarshalJSON(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 "author": + err = unpopulate(val, "Author", &g.Author) + delete(rawMsg, key) + case "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &g.CreatedDate) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &g.Description) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, "Enabled", &g.Enabled) + delete(rawMsg, key) + case "icon": + err = unpopulate(val, "Icon", &g.Icon) + delete(rawMsg, key) + case "imageReference": + err = unpopulate(val, "ImageReference", &g.ImageReference) + delete(rawMsg, key) + case "isPlanAuthorized": + err = unpopulate(val, "IsPlanAuthorized", &g.IsPlanAuthorized) + delete(rawMsg, key) + case "planId": + err = unpopulate(val, "PlanID", &g.PlanID) + 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 GalleryImageReference. +func (g GalleryImageReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "osType", g.OSType) + populate(objectMap, "offer", g.Offer) + populate(objectMap, "publisher", g.Publisher) + populate(objectMap, "sku", g.SKU) + populate(objectMap, "version", g.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GalleryImageReference. +func (g *GalleryImageReference) UnmarshalJSON(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 "osType": + err = unpopulate(val, "OSType", &g.OSType) + delete(rawMsg, key) + case "offer": + err = unpopulate(val, "Offer", &g.Offer) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &g.Publisher) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &g.SKU) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &g.Version) + 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 GenerateArmTemplateRequest. +func (g GenerateArmTemplateRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "fileUploadOptions", g.FileUploadOptions) + populate(objectMap, "location", g.Location) + populate(objectMap, "parameters", g.Parameters) + populate(objectMap, "virtualMachineName", g.VirtualMachineName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenerateArmTemplateRequest. +func (g *GenerateArmTemplateRequest) UnmarshalJSON(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 "fileUploadOptions": + err = unpopulate(val, "FileUploadOptions", &g.FileUploadOptions) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &g.Location) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &g.Parameters) + delete(rawMsg, key) + case "virtualMachineName": + err = unpopulate(val, "VirtualMachineName", &g.VirtualMachineName) + 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 GenerateUploadURIParameter. +func (g GenerateUploadURIParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "blobName", g.BlobName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenerateUploadURIParameter. +func (g *GenerateUploadURIParameter) UnmarshalJSON(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 "blobName": + err = unpopulate(val, "BlobName", &g.BlobName) + 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 GenerateUploadURIResponse. +func (g GenerateUploadURIResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "uploadUri", g.UploadURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenerateUploadURIResponse. +func (g *GenerateUploadURIResponse) UnmarshalJSON(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 "uploadUri": + err = unpopulate(val, "UploadURI", &g.UploadURI) + 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 HourDetails. +func (h HourDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "minute", h.Minute) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HourDetails. +func (h *HourDetails) UnmarshalJSON(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 "minute": + err = unpopulate(val, "Minute", &h.Minute) + 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 IdentityProperties. +func (i IdentityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientSecretUrl", i.ClientSecretURL) + populate(objectMap, "principalId", i.PrincipalID) + populate(objectMap, "tenantId", i.TenantID) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IdentityProperties. +func (i *IdentityProperties) UnmarshalJSON(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 "clientSecretUrl": + err = unpopulate(val, "ClientSecretURL", &i.ClientSecretURL) + delete(rawMsg, 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 ImportLabVirtualMachineRequest. +func (i ImportLabVirtualMachineRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "destinationVirtualMachineName", i.DestinationVirtualMachineName) + populate(objectMap, "sourceVirtualMachineResourceId", i.SourceVirtualMachineResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImportLabVirtualMachineRequest. +func (i *ImportLabVirtualMachineRequest) UnmarshalJSON(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 "destinationVirtualMachineName": + err = unpopulate(val, "DestinationVirtualMachineName", &i.DestinationVirtualMachineName) + delete(rawMsg, key) + case "sourceVirtualMachineResourceId": + err = unpopulate(val, "SourceVirtualMachineResourceID", &i.SourceVirtualMachineResourceID) + 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 InboundNatRule. +func (i InboundNatRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backendPort", i.BackendPort) + populate(objectMap, "frontendPort", i.FrontendPort) + populate(objectMap, "transportProtocol", i.TransportProtocol) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InboundNatRule. +func (i *InboundNatRule) UnmarshalJSON(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 "backendPort": + err = unpopulate(val, "BackendPort", &i.BackendPort) + delete(rawMsg, key) + case "frontendPort": + err = unpopulate(val, "FrontendPort", &i.FrontendPort) + delete(rawMsg, key) + case "transportProtocol": + err = unpopulate(val, "TransportProtocol", &i.TransportProtocol) + 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 Lab. +func (l Lab) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", l.ID) + populate(objectMap, "location", l.Location) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "tags", l.Tags) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Lab. +func (l *Lab) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &l.Location) + 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 "tags": + err = unpopulate(val, "Tags", &l.Tags) + 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 LabAnnouncementProperties. +func (l LabAnnouncementProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enabled", l.Enabled) + populateTimeRFC3339(objectMap, "expirationDate", l.ExpirationDate) + populate(objectMap, "expired", l.Expired) + populate(objectMap, "markdown", l.Markdown) + populate(objectMap, "provisioningState", l.ProvisioningState) + populate(objectMap, "title", l.Title) + populate(objectMap, "uniqueIdentifier", l.UniqueIdentifier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabAnnouncementProperties. +func (l *LabAnnouncementProperties) UnmarshalJSON(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 "enabled": + err = unpopulate(val, "Enabled", &l.Enabled) + delete(rawMsg, key) + case "expirationDate": + err = unpopulateTimeRFC3339(val, "ExpirationDate", &l.ExpirationDate) + delete(rawMsg, key) + case "expired": + err = unpopulate(val, "Expired", &l.Expired) + delete(rawMsg, key) + case "markdown": + err = unpopulate(val, "Markdown", &l.Markdown) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &l.ProvisioningState) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &l.Title) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &l.UniqueIdentifier) + 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 LabCost. +func (l LabCost) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", l.ID) + populate(objectMap, "location", l.Location) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "tags", l.Tags) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabCost. +func (l *LabCost) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &l.Location) + 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 "tags": + err = unpopulate(val, "Tags", &l.Tags) + 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 LabCostDetailsProperties. +func (l LabCostDetailsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cost", l.Cost) + populate(objectMap, "costType", l.CostType) + populateTimeRFC3339(objectMap, "date", l.Date) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabCostDetailsProperties. +func (l *LabCostDetailsProperties) UnmarshalJSON(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 "cost": + err = unpopulate(val, "Cost", &l.Cost) + delete(rawMsg, key) + case "costType": + err = unpopulate(val, "CostType", &l.CostType) + delete(rawMsg, key) + case "date": + err = unpopulateTimeRFC3339(val, "Date", &l.Date) + 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 LabCostProperties. +func (l LabCostProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdDate", l.CreatedDate) + populate(objectMap, "currencyCode", l.CurrencyCode) + populateTimeRFC3339(objectMap, "endDateTime", l.EndDateTime) + populate(objectMap, "labCostDetails", l.LabCostDetails) + populate(objectMap, "labCostSummary", l.LabCostSummary) + populate(objectMap, "provisioningState", l.ProvisioningState) + populate(objectMap, "resourceCosts", l.ResourceCosts) + populateTimeRFC3339(objectMap, "startDateTime", l.StartDateTime) + populate(objectMap, "targetCost", l.TargetCost) + populate(objectMap, "uniqueIdentifier", l.UniqueIdentifier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabCostProperties. +func (l *LabCostProperties) UnmarshalJSON(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 "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &l.CreatedDate) + delete(rawMsg, key) + case "currencyCode": + err = unpopulate(val, "CurrencyCode", &l.CurrencyCode) + delete(rawMsg, key) + case "endDateTime": + err = unpopulateTimeRFC3339(val, "EndDateTime", &l.EndDateTime) + delete(rawMsg, key) + case "labCostDetails": + err = unpopulate(val, "LabCostDetails", &l.LabCostDetails) + delete(rawMsg, key) + case "labCostSummary": + err = unpopulate(val, "LabCostSummary", &l.LabCostSummary) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &l.ProvisioningState) + delete(rawMsg, key) + case "resourceCosts": + err = unpopulate(val, "ResourceCosts", &l.ResourceCosts) + delete(rawMsg, key) + case "startDateTime": + err = unpopulateTimeRFC3339(val, "StartDateTime", &l.StartDateTime) + delete(rawMsg, key) + case "targetCost": + err = unpopulate(val, "TargetCost", &l.TargetCost) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &l.UniqueIdentifier) + 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 LabCostSummaryProperties. +func (l LabCostSummaryProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "estimatedLabCost", l.EstimatedLabCost) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabCostSummaryProperties. +func (l *LabCostSummaryProperties) UnmarshalJSON(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 "estimatedLabCost": + err = unpopulate(val, "EstimatedLabCost", &l.EstimatedLabCost) + 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 LabFragment. +func (l LabFragment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", l.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabFragment. +func (l *LabFragment) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &l.Tags) + 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 LabList. +func (l LabList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabList. +func (l *LabList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LabProperties. +func (l LabProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "announcement", l.Announcement) + populate(objectMap, "artifactsStorageAccount", l.ArtifactsStorageAccount) + populateTimeRFC3339(objectMap, "createdDate", l.CreatedDate) + populate(objectMap, "defaultPremiumStorageAccount", l.DefaultPremiumStorageAccount) + populate(objectMap, "defaultStorageAccount", l.DefaultStorageAccount) + populate(objectMap, "environmentPermission", l.EnvironmentPermission) + populate(objectMap, "extendedProperties", l.ExtendedProperties) + populate(objectMap, "labStorageType", l.LabStorageType) + populate(objectMap, "loadBalancerId", l.LoadBalancerID) + populate(objectMap, "mandatoryArtifactsResourceIdsLinux", l.MandatoryArtifactsResourceIDsLinux) + populate(objectMap, "mandatoryArtifactsResourceIdsWindows", l.MandatoryArtifactsResourceIDsWindows) + populate(objectMap, "networkSecurityGroupId", l.NetworkSecurityGroupID) + populate(objectMap, "premiumDataDiskStorageAccount", l.PremiumDataDiskStorageAccount) + populate(objectMap, "premiumDataDisks", l.PremiumDataDisks) + populate(objectMap, "provisioningState", l.ProvisioningState) + populate(objectMap, "publicIpId", l.PublicIPID) + populate(objectMap, "support", l.Support) + populate(objectMap, "uniqueIdentifier", l.UniqueIdentifier) + populate(objectMap, "vmCreationResourceGroup", l.VMCreationResourceGroup) + populate(objectMap, "vaultName", l.VaultName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabProperties. +func (l *LabProperties) UnmarshalJSON(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 "announcement": + err = unpopulate(val, "Announcement", &l.Announcement) + delete(rawMsg, key) + case "artifactsStorageAccount": + err = unpopulate(val, "ArtifactsStorageAccount", &l.ArtifactsStorageAccount) + delete(rawMsg, key) + case "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &l.CreatedDate) + delete(rawMsg, key) + case "defaultPremiumStorageAccount": + err = unpopulate(val, "DefaultPremiumStorageAccount", &l.DefaultPremiumStorageAccount) + delete(rawMsg, key) + case "defaultStorageAccount": + err = unpopulate(val, "DefaultStorageAccount", &l.DefaultStorageAccount) + delete(rawMsg, key) + case "environmentPermission": + err = unpopulate(val, "EnvironmentPermission", &l.EnvironmentPermission) + delete(rawMsg, key) + case "extendedProperties": + err = unpopulate(val, "ExtendedProperties", &l.ExtendedProperties) + delete(rawMsg, key) + case "labStorageType": + err = unpopulate(val, "LabStorageType", &l.LabStorageType) + delete(rawMsg, key) + case "loadBalancerId": + err = unpopulate(val, "LoadBalancerID", &l.LoadBalancerID) + delete(rawMsg, key) + case "mandatoryArtifactsResourceIdsLinux": + err = unpopulate(val, "MandatoryArtifactsResourceIDsLinux", &l.MandatoryArtifactsResourceIDsLinux) + delete(rawMsg, key) + case "mandatoryArtifactsResourceIdsWindows": + err = unpopulate(val, "MandatoryArtifactsResourceIDsWindows", &l.MandatoryArtifactsResourceIDsWindows) + delete(rawMsg, key) + case "networkSecurityGroupId": + err = unpopulate(val, "NetworkSecurityGroupID", &l.NetworkSecurityGroupID) + delete(rawMsg, key) + case "premiumDataDiskStorageAccount": + err = unpopulate(val, "PremiumDataDiskStorageAccount", &l.PremiumDataDiskStorageAccount) + delete(rawMsg, key) + case "premiumDataDisks": + err = unpopulate(val, "PremiumDataDisks", &l.PremiumDataDisks) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &l.ProvisioningState) + delete(rawMsg, key) + case "publicIpId": + err = unpopulate(val, "PublicIPID", &l.PublicIPID) + delete(rawMsg, key) + case "support": + err = unpopulate(val, "Support", &l.Support) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &l.UniqueIdentifier) + delete(rawMsg, key) + case "vmCreationResourceGroup": + err = unpopulate(val, "VMCreationResourceGroup", &l.VMCreationResourceGroup) + delete(rawMsg, key) + case "vaultName": + err = unpopulate(val, "VaultName", &l.VaultName) + 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 LabResourceCostProperties. +func (l LabResourceCostProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "externalResourceId", l.ExternalResourceID) + populate(objectMap, "resourceCost", l.ResourceCost) + populate(objectMap, "resourceId", l.ResourceID) + populate(objectMap, "resourceOwner", l.ResourceOwner) + populate(objectMap, "resourcePricingTier", l.ResourcePricingTier) + populate(objectMap, "resourceStatus", l.ResourceStatus) + populate(objectMap, "resourceType", l.ResourceType) + populate(objectMap, "resourceUId", l.ResourceUID) + populate(objectMap, "resourcename", l.Resourcename) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabResourceCostProperties. +func (l *LabResourceCostProperties) UnmarshalJSON(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 "externalResourceId": + err = unpopulate(val, "ExternalResourceID", &l.ExternalResourceID) + delete(rawMsg, key) + case "resourceCost": + err = unpopulate(val, "ResourceCost", &l.ResourceCost) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &l.ResourceID) + delete(rawMsg, key) + case "resourceOwner": + err = unpopulate(val, "ResourceOwner", &l.ResourceOwner) + delete(rawMsg, key) + case "resourcePricingTier": + err = unpopulate(val, "ResourcePricingTier", &l.ResourcePricingTier) + delete(rawMsg, key) + case "resourceStatus": + err = unpopulate(val, "ResourceStatus", &l.ResourceStatus) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &l.ResourceType) + delete(rawMsg, key) + case "resourceUId": + err = unpopulate(val, "ResourceUID", &l.ResourceUID) + delete(rawMsg, key) + case "resourcename": + err = unpopulate(val, "Resourcename", &l.Resourcename) + 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 LabSupportProperties. +func (l LabSupportProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enabled", l.Enabled) + populate(objectMap, "markdown", l.Markdown) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabSupportProperties. +func (l *LabSupportProperties) UnmarshalJSON(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 "enabled": + err = unpopulate(val, "Enabled", &l.Enabled) + delete(rawMsg, key) + case "markdown": + err = unpopulate(val, "Markdown", &l.Markdown) + 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 LabVhd. +func (l LabVhd) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", l.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabVhd. +func (l *LabVhd) UnmarshalJSON(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) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LabVhdList. +func (l LabVhdList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabVhdList. +func (l *LabVhdList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LabVirtualMachine. +func (l LabVirtualMachine) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", l.ID) + populate(objectMap, "location", l.Location) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "tags", l.Tags) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabVirtualMachine. +func (l *LabVirtualMachine) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &l.Location) + 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 "tags": + err = unpopulate(val, "Tags", &l.Tags) + 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 LabVirtualMachineCreationParameter. +func (l LabVirtualMachineCreationParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "location", l.Location) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "tags", l.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabVirtualMachineCreationParameter. +func (l *LabVirtualMachineCreationParameter) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &l.Location) + 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 "tags": + err = unpopulate(val, "Tags", &l.Tags) + 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 LabVirtualMachineCreationParameterProperties. +func (l LabVirtualMachineCreationParameterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allowClaim", l.AllowClaim) + populate(objectMap, "artifacts", l.Artifacts) + populate(objectMap, "bulkCreationParameters", l.BulkCreationParameters) + populateTimeRFC3339(objectMap, "createdDate", l.CreatedDate) + populate(objectMap, "customImageId", l.CustomImageID) + populate(objectMap, "dataDiskParameters", l.DataDiskParameters) + populate(objectMap, "disallowPublicIpAddress", l.DisallowPublicIPAddress) + populate(objectMap, "environmentId", l.EnvironmentID) + populateTimeRFC3339(objectMap, "expirationDate", l.ExpirationDate) + populate(objectMap, "galleryImageReference", l.GalleryImageReference) + populate(objectMap, "isAuthenticationWithSshKey", l.IsAuthenticationWithSSHKey) + populate(objectMap, "labSubnetName", l.LabSubnetName) + populate(objectMap, "labVirtualNetworkId", l.LabVirtualNetworkID) + populate(objectMap, "networkInterface", l.NetworkInterface) + populate(objectMap, "notes", l.Notes) + populate(objectMap, "ownerObjectId", l.OwnerObjectID) + populate(objectMap, "ownerUserPrincipalName", l.OwnerUserPrincipalName) + populate(objectMap, "password", l.Password) + populate(objectMap, "planId", l.PlanID) + populate(objectMap, "sshKey", l.SSHKey) + populate(objectMap, "scheduleParameters", l.ScheduleParameters) + populate(objectMap, "size", l.Size) + populate(objectMap, "storageType", l.StorageType) + populate(objectMap, "userName", l.UserName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabVirtualMachineCreationParameterProperties. +func (l *LabVirtualMachineCreationParameterProperties) UnmarshalJSON(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 "allowClaim": + err = unpopulate(val, "AllowClaim", &l.AllowClaim) + delete(rawMsg, key) + case "artifacts": + err = unpopulate(val, "Artifacts", &l.Artifacts) + delete(rawMsg, key) + case "bulkCreationParameters": + err = unpopulate(val, "BulkCreationParameters", &l.BulkCreationParameters) + delete(rawMsg, key) + case "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &l.CreatedDate) + delete(rawMsg, key) + case "customImageId": + err = unpopulate(val, "CustomImageID", &l.CustomImageID) + delete(rawMsg, key) + case "dataDiskParameters": + err = unpopulate(val, "DataDiskParameters", &l.DataDiskParameters) + delete(rawMsg, key) + case "disallowPublicIpAddress": + err = unpopulate(val, "DisallowPublicIPAddress", &l.DisallowPublicIPAddress) + delete(rawMsg, key) + case "environmentId": + err = unpopulate(val, "EnvironmentID", &l.EnvironmentID) + delete(rawMsg, key) + case "expirationDate": + err = unpopulateTimeRFC3339(val, "ExpirationDate", &l.ExpirationDate) + delete(rawMsg, key) + case "galleryImageReference": + err = unpopulate(val, "GalleryImageReference", &l.GalleryImageReference) + delete(rawMsg, key) + case "isAuthenticationWithSshKey": + err = unpopulate(val, "IsAuthenticationWithSSHKey", &l.IsAuthenticationWithSSHKey) + delete(rawMsg, key) + case "labSubnetName": + err = unpopulate(val, "LabSubnetName", &l.LabSubnetName) + delete(rawMsg, key) + case "labVirtualNetworkId": + err = unpopulate(val, "LabVirtualNetworkID", &l.LabVirtualNetworkID) + delete(rawMsg, key) + case "networkInterface": + err = unpopulate(val, "NetworkInterface", &l.NetworkInterface) + delete(rawMsg, key) + case "notes": + err = unpopulate(val, "Notes", &l.Notes) + delete(rawMsg, key) + case "ownerObjectId": + err = unpopulate(val, "OwnerObjectID", &l.OwnerObjectID) + delete(rawMsg, key) + case "ownerUserPrincipalName": + err = unpopulate(val, "OwnerUserPrincipalName", &l.OwnerUserPrincipalName) + delete(rawMsg, key) + case "password": + err = unpopulate(val, "Password", &l.Password) + delete(rawMsg, key) + case "planId": + err = unpopulate(val, "PlanID", &l.PlanID) + delete(rawMsg, key) + case "sshKey": + err = unpopulate(val, "SSHKey", &l.SSHKey) + delete(rawMsg, key) + case "scheduleParameters": + err = unpopulate(val, "ScheduleParameters", &l.ScheduleParameters) + delete(rawMsg, key) + case "size": + err = unpopulate(val, "Size", &l.Size) + delete(rawMsg, key) + case "storageType": + err = unpopulate(val, "StorageType", &l.StorageType) + delete(rawMsg, key) + case "userName": + err = unpopulate(val, "UserName", &l.UserName) + 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 LabVirtualMachineFragment. +func (l LabVirtualMachineFragment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", l.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabVirtualMachineFragment. +func (l *LabVirtualMachineFragment) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &l.Tags) + 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 LabVirtualMachineList. +func (l LabVirtualMachineList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabVirtualMachineList. +func (l *LabVirtualMachineList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LabVirtualMachineProperties. +func (l LabVirtualMachineProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allowClaim", l.AllowClaim) + populate(objectMap, "applicableSchedule", l.ApplicableSchedule) + populate(objectMap, "artifactDeploymentStatus", l.ArtifactDeploymentStatus) + populate(objectMap, "artifacts", l.Artifacts) + populate(objectMap, "computeId", l.ComputeID) + populate(objectMap, "computeVm", l.ComputeVM) + populate(objectMap, "createdByUser", l.CreatedByUser) + populate(objectMap, "createdByUserId", l.CreatedByUserID) + populateTimeRFC3339(objectMap, "createdDate", l.CreatedDate) + populate(objectMap, "customImageId", l.CustomImageID) + populate(objectMap, "dataDiskParameters", l.DataDiskParameters) + populate(objectMap, "disallowPublicIpAddress", l.DisallowPublicIPAddress) + populate(objectMap, "environmentId", l.EnvironmentID) + populateTimeRFC3339(objectMap, "expirationDate", l.ExpirationDate) + populate(objectMap, "fqdn", l.Fqdn) + populate(objectMap, "galleryImageReference", l.GalleryImageReference) + populate(objectMap, "isAuthenticationWithSshKey", l.IsAuthenticationWithSSHKey) + populate(objectMap, "labSubnetName", l.LabSubnetName) + populate(objectMap, "labVirtualNetworkId", l.LabVirtualNetworkID) + populate(objectMap, "lastKnownPowerState", l.LastKnownPowerState) + populate(objectMap, "networkInterface", l.NetworkInterface) + populate(objectMap, "notes", l.Notes) + populate(objectMap, "osType", l.OSType) + populate(objectMap, "ownerObjectId", l.OwnerObjectID) + populate(objectMap, "ownerUserPrincipalName", l.OwnerUserPrincipalName) + populate(objectMap, "password", l.Password) + populate(objectMap, "planId", l.PlanID) + populate(objectMap, "provisioningState", l.ProvisioningState) + populate(objectMap, "sshKey", l.SSHKey) + populate(objectMap, "scheduleParameters", l.ScheduleParameters) + populate(objectMap, "size", l.Size) + populate(objectMap, "storageType", l.StorageType) + populate(objectMap, "uniqueIdentifier", l.UniqueIdentifier) + populate(objectMap, "userName", l.UserName) + populate(objectMap, "virtualMachineCreationSource", l.VirtualMachineCreationSource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LabVirtualMachineProperties. +func (l *LabVirtualMachineProperties) UnmarshalJSON(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 "allowClaim": + err = unpopulate(val, "AllowClaim", &l.AllowClaim) + delete(rawMsg, key) + case "applicableSchedule": + err = unpopulate(val, "ApplicableSchedule", &l.ApplicableSchedule) + delete(rawMsg, key) + case "artifactDeploymentStatus": + err = unpopulate(val, "ArtifactDeploymentStatus", &l.ArtifactDeploymentStatus) + delete(rawMsg, key) + case "artifacts": + err = unpopulate(val, "Artifacts", &l.Artifacts) + delete(rawMsg, key) + case "computeId": + err = unpopulate(val, "ComputeID", &l.ComputeID) + delete(rawMsg, key) + case "computeVm": + err = unpopulate(val, "ComputeVM", &l.ComputeVM) + delete(rawMsg, key) + case "createdByUser": + err = unpopulate(val, "CreatedByUser", &l.CreatedByUser) + delete(rawMsg, key) + case "createdByUserId": + err = unpopulate(val, "CreatedByUserID", &l.CreatedByUserID) + delete(rawMsg, key) + case "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &l.CreatedDate) + delete(rawMsg, key) + case "customImageId": + err = unpopulate(val, "CustomImageID", &l.CustomImageID) + delete(rawMsg, key) + case "dataDiskParameters": + err = unpopulate(val, "DataDiskParameters", &l.DataDiskParameters) + delete(rawMsg, key) + case "disallowPublicIpAddress": + err = unpopulate(val, "DisallowPublicIPAddress", &l.DisallowPublicIPAddress) + delete(rawMsg, key) + case "environmentId": + err = unpopulate(val, "EnvironmentID", &l.EnvironmentID) + delete(rawMsg, key) + case "expirationDate": + err = unpopulateTimeRFC3339(val, "ExpirationDate", &l.ExpirationDate) + delete(rawMsg, key) + case "fqdn": + err = unpopulate(val, "Fqdn", &l.Fqdn) + delete(rawMsg, key) + case "galleryImageReference": + err = unpopulate(val, "GalleryImageReference", &l.GalleryImageReference) + delete(rawMsg, key) + case "isAuthenticationWithSshKey": + err = unpopulate(val, "IsAuthenticationWithSSHKey", &l.IsAuthenticationWithSSHKey) + delete(rawMsg, key) + case "labSubnetName": + err = unpopulate(val, "LabSubnetName", &l.LabSubnetName) + delete(rawMsg, key) + case "labVirtualNetworkId": + err = unpopulate(val, "LabVirtualNetworkID", &l.LabVirtualNetworkID) + delete(rawMsg, key) + case "lastKnownPowerState": + err = unpopulate(val, "LastKnownPowerState", &l.LastKnownPowerState) + delete(rawMsg, key) + case "networkInterface": + err = unpopulate(val, "NetworkInterface", &l.NetworkInterface) + delete(rawMsg, key) + case "notes": + err = unpopulate(val, "Notes", &l.Notes) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, "OSType", &l.OSType) + delete(rawMsg, key) + case "ownerObjectId": + err = unpopulate(val, "OwnerObjectID", &l.OwnerObjectID) + delete(rawMsg, key) + case "ownerUserPrincipalName": + err = unpopulate(val, "OwnerUserPrincipalName", &l.OwnerUserPrincipalName) + delete(rawMsg, key) + case "password": + err = unpopulate(val, "Password", &l.Password) + delete(rawMsg, key) + case "planId": + err = unpopulate(val, "PlanID", &l.PlanID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &l.ProvisioningState) + delete(rawMsg, key) + case "sshKey": + err = unpopulate(val, "SSHKey", &l.SSHKey) + delete(rawMsg, key) + case "scheduleParameters": + err = unpopulate(val, "ScheduleParameters", &l.ScheduleParameters) + delete(rawMsg, key) + case "size": + err = unpopulate(val, "Size", &l.Size) + delete(rawMsg, key) + case "storageType": + err = unpopulate(val, "StorageType", &l.StorageType) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &l.UniqueIdentifier) + delete(rawMsg, key) + case "userName": + err = unpopulate(val, "UserName", &l.UserName) + delete(rawMsg, key) + case "virtualMachineCreationSource": + err = unpopulate(val, "VirtualMachineCreationSource", &l.VirtualMachineCreationSource) + 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 LinuxOsInfo. +func (l LinuxOsInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "linuxOsState", l.LinuxOsState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LinuxOsInfo. +func (l *LinuxOsInfo) UnmarshalJSON(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 "linuxOsState": + err = unpopulate(val, "LinuxOsState", &l.LinuxOsState) + 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 NetworkInterfaceProperties. +func (n NetworkInterfaceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dnsName", n.DNSName) + populate(objectMap, "privateIpAddress", n.PrivateIPAddress) + populate(objectMap, "publicIpAddress", n.PublicIPAddress) + populate(objectMap, "publicIpAddressId", n.PublicIPAddressID) + populate(objectMap, "rdpAuthority", n.RdpAuthority) + populate(objectMap, "sshAuthority", n.SSHAuthority) + populate(objectMap, "sharedPublicIpAddressConfiguration", n.SharedPublicIPAddressConfiguration) + populate(objectMap, "subnetId", n.SubnetID) + populate(objectMap, "virtualNetworkId", n.VirtualNetworkID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkInterfaceProperties. +func (n *NetworkInterfaceProperties) UnmarshalJSON(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 "dnsName": + err = unpopulate(val, "DNSName", &n.DNSName) + delete(rawMsg, key) + case "privateIpAddress": + err = unpopulate(val, "PrivateIPAddress", &n.PrivateIPAddress) + delete(rawMsg, key) + case "publicIpAddress": + err = unpopulate(val, "PublicIPAddress", &n.PublicIPAddress) + delete(rawMsg, key) + case "publicIpAddressId": + err = unpopulate(val, "PublicIPAddressID", &n.PublicIPAddressID) + delete(rawMsg, key) + case "rdpAuthority": + err = unpopulate(val, "RdpAuthority", &n.RdpAuthority) + delete(rawMsg, key) + case "sshAuthority": + err = unpopulate(val, "SSHAuthority", &n.SSHAuthority) + delete(rawMsg, key) + case "sharedPublicIpAddressConfiguration": + err = unpopulate(val, "SharedPublicIPAddressConfiguration", &n.SharedPublicIPAddressConfiguration) + delete(rawMsg, key) + case "subnetId": + err = unpopulate(val, "SubnetID", &n.SubnetID) + delete(rawMsg, key) + case "virtualNetworkId": + err = unpopulate(val, "VirtualNetworkID", &n.VirtualNetworkID) + 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 NotificationChannel. +func (n NotificationChannel) 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, "tags", n.Tags) + populate(objectMap, "type", n.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NotificationChannel. +func (n *NotificationChannel) UnmarshalJSON(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 "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 NotificationChannelFragment. +func (n NotificationChannelFragment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", n.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NotificationChannelFragment. +func (n *NotificationChannelFragment) UnmarshalJSON(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 "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 NotificationChannelList. +func (n NotificationChannelList) 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 NotificationChannelList. +func (n *NotificationChannelList) UnmarshalJSON(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 NotificationChannelProperties. +func (n NotificationChannelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdDate", n.CreatedDate) + populate(objectMap, "description", n.Description) + populate(objectMap, "emailRecipient", n.EmailRecipient) + populate(objectMap, "events", n.Events) + populate(objectMap, "notificationLocale", n.NotificationLocale) + populate(objectMap, "provisioningState", n.ProvisioningState) + populate(objectMap, "uniqueIdentifier", n.UniqueIdentifier) + populate(objectMap, "webHookUrl", n.WebHookURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NotificationChannelProperties. +func (n *NotificationChannelProperties) UnmarshalJSON(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 "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &n.CreatedDate) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &n.Description) + delete(rawMsg, key) + case "emailRecipient": + err = unpopulate(val, "EmailRecipient", &n.EmailRecipient) + delete(rawMsg, key) + case "events": + err = unpopulate(val, "Events", &n.Events) + delete(rawMsg, key) + case "notificationLocale": + err = unpopulate(val, "NotificationLocale", &n.NotificationLocale) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &n.ProvisioningState) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &n.UniqueIdentifier) + delete(rawMsg, key) + case "webHookUrl": + err = unpopulate(val, "WebHookURL", &n.WebHookURL) + 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 NotificationSettings. +func (n NotificationSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "emailRecipient", n.EmailRecipient) + populate(objectMap, "notificationLocale", n.NotificationLocale) + populate(objectMap, "status", n.Status) + populate(objectMap, "timeInMinutes", n.TimeInMinutes) + populate(objectMap, "webhookUrl", n.WebhookURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NotificationSettings. +func (n *NotificationSettings) UnmarshalJSON(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 "emailRecipient": + err = unpopulate(val, "EmailRecipient", &n.EmailRecipient) + delete(rawMsg, key) + case "notificationLocale": + err = unpopulate(val, "NotificationLocale", &n.NotificationLocale) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &n.Status) + delete(rawMsg, key) + case "timeInMinutes": + err = unpopulate(val, "TimeInMinutes", &n.TimeInMinutes) + delete(rawMsg, key) + case "webhookUrl": + err = unpopulate(val, "WebhookURL", &n.WebhookURL) + 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 NotifyParameters. +func (n NotifyParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eventName", n.EventName) + populate(objectMap, "jsonPayload", n.JSONPayload) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NotifyParameters. +func (n *NotifyParameters) UnmarshalJSON(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 "eventName": + err = unpopulate(val, "EventName", &n.EventName) + delete(rawMsg, key) + case "jsonPayload": + err = unpopulate(val, "JSONPayload", &n.JSONPayload) + 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 OperationError. +func (o OperationError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", o.Code) + populate(objectMap, "message", o.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationError. +func (o *OperationError) UnmarshalJSON(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 "code": + err = unpopulate(val, "Code", &o.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &o.Message) + 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 OperationMetadata. +func (o OperationMetadata) 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 OperationMetadata. +func (o *OperationMetadata) UnmarshalJSON(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 OperationMetadataDisplay. +func (o OperationMetadataDisplay) 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 OperationMetadataDisplay. +func (o *OperationMetadataDisplay) UnmarshalJSON(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 OperationResult. +func (o OperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", o.Error) + populate(objectMap, "status", o.Status) + populate(objectMap, "statusCode", o.StatusCode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationResult. +func (o *OperationResult) UnmarshalJSON(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 "error": + err = unpopulate(val, "Error", &o.Error) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &o.Status) + delete(rawMsg, key) + case "statusCode": + err = unpopulate(val, "StatusCode", &o.StatusCode) + 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 ParameterInfo. +func (p ParameterInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", p.Name) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ParameterInfo. +func (p *ParameterInfo) UnmarshalJSON(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 "name": + err = unpopulate(val, "Name", &p.Name) + 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 ParametersValueFileInfo. +func (p ParametersValueFileInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "fileName", p.FileName) + populate(objectMap, "parametersValueInfo", &p.ParametersValueInfo) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ParametersValueFileInfo. +func (p *ParametersValueFileInfo) UnmarshalJSON(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 "fileName": + err = unpopulate(val, "FileName", &p.FileName) + delete(rawMsg, key) + case "parametersValueInfo": + err = unpopulate(val, "ParametersValueInfo", &p.ParametersValueInfo) + 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 PercentageCostThresholdProperties. +func (p PercentageCostThresholdProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "thresholdValue", p.ThresholdValue) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PercentageCostThresholdProperties. +func (p *PercentageCostThresholdProperties) UnmarshalJSON(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 "thresholdValue": + err = unpopulate(val, "ThresholdValue", &p.ThresholdValue) + 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 Policy. +func (p Policy) 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, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Policy. +func (p *Policy) UnmarshalJSON(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 "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 PolicyFragment. +func (p PolicyFragment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyFragment. +func (p *PolicyFragment) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &p.Tags) + 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 PolicyList. +func (p PolicyList) 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 PolicyList. +func (p *PolicyList) UnmarshalJSON(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 PolicyProperties. +func (p PolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdDate", p.CreatedDate) + populate(objectMap, "description", p.Description) + populate(objectMap, "evaluatorType", p.EvaluatorType) + populate(objectMap, "factData", p.FactData) + populate(objectMap, "factName", p.FactName) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "status", p.Status) + populate(objectMap, "threshold", p.Threshold) + populate(objectMap, "uniqueIdentifier", p.UniqueIdentifier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyProperties. +func (p *PolicyProperties) UnmarshalJSON(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 "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &p.CreatedDate) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "evaluatorType": + err = unpopulate(val, "EvaluatorType", &p.EvaluatorType) + delete(rawMsg, key) + case "factData": + err = unpopulate(val, "FactData", &p.FactData) + delete(rawMsg, key) + case "factName": + err = unpopulate(val, "FactName", &p.FactName) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "threshold": + err = unpopulate(val, "Threshold", &p.Threshold) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &p.UniqueIdentifier) + 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 PolicySetResult. +func (p PolicySetResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "hasError", p.HasError) + populate(objectMap, "policyViolations", p.PolicyViolations) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicySetResult. +func (p *PolicySetResult) UnmarshalJSON(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 "hasError": + err = unpopulate(val, "HasError", &p.HasError) + delete(rawMsg, key) + case "policyViolations": + err = unpopulate(val, "PolicyViolations", &p.PolicyViolations) + 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 PolicyViolation. +func (p PolicyViolation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", p.Code) + populate(objectMap, "message", p.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyViolation. +func (p *PolicyViolation) UnmarshalJSON(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 "code": + err = unpopulate(val, "Code", &p.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &p.Message) + 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 Port. +func (p Port) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backendPort", p.BackendPort) + populate(objectMap, "transportProtocol", p.TransportProtocol) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Port. +func (p *Port) UnmarshalJSON(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 "backendPort": + err = unpopulate(val, "BackendPort", &p.BackendPort) + delete(rawMsg, key) + case "transportProtocol": + err = unpopulate(val, "TransportProtocol", &p.TransportProtocol) + 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 ProviderOperationResult. +func (p ProviderOperationResult) 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 ProviderOperationResult. +func (p *ProviderOperationResult) UnmarshalJSON(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 RdpConnection. +func (r RdpConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contents", r.Contents) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RdpConnection. +func (r *RdpConnection) UnmarshalJSON(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 "contents": + err = unpopulate(val, "Contents", &r.Contents) + 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 ResizeLabVirtualMachineProperties. +func (r ResizeLabVirtualMachineProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "size", r.Size) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResizeLabVirtualMachineProperties. +func (r *ResizeLabVirtualMachineProperties) UnmarshalJSON(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 "size": + err = unpopulate(val, "Size", &r.Size) + 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, "location", r.Location) + populate(objectMap, "name", r.Name) + 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 "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 RetargetScheduleProperties. +func (r RetargetScheduleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currentResourceId", r.CurrentResourceID) + populate(objectMap, "targetResourceId", r.TargetResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RetargetScheduleProperties. +func (r *RetargetScheduleProperties) UnmarshalJSON(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 "currentResourceId": + err = unpopulate(val, "CurrentResourceID", &r.CurrentResourceID) + delete(rawMsg, key) + case "targetResourceId": + err = unpopulate(val, "TargetResourceID", &r.TargetResourceID) + 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 Schedule. +func (s Schedule) 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, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Schedule. +func (s *Schedule) UnmarshalJSON(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 "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 ScheduleCreationParameter. +func (s ScheduleCreationParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "location", s.Location) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScheduleCreationParameter. +func (s *ScheduleCreationParameter) UnmarshalJSON(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 "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 "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 ScheduleCreationParameterProperties. +func (s ScheduleCreationParameterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dailyRecurrence", s.DailyRecurrence) + populate(objectMap, "hourlyRecurrence", s.HourlyRecurrence) + populate(objectMap, "notificationSettings", s.NotificationSettings) + populate(objectMap, "status", s.Status) + populate(objectMap, "targetResourceId", s.TargetResourceID) + populate(objectMap, "taskType", s.TaskType) + populate(objectMap, "timeZoneId", s.TimeZoneID) + populate(objectMap, "weeklyRecurrence", s.WeeklyRecurrence) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScheduleCreationParameterProperties. +func (s *ScheduleCreationParameterProperties) UnmarshalJSON(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 "dailyRecurrence": + err = unpopulate(val, "DailyRecurrence", &s.DailyRecurrence) + delete(rawMsg, key) + case "hourlyRecurrence": + err = unpopulate(val, "HourlyRecurrence", &s.HourlyRecurrence) + delete(rawMsg, key) + case "notificationSettings": + err = unpopulate(val, "NotificationSettings", &s.NotificationSettings) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + delete(rawMsg, key) + case "targetResourceId": + err = unpopulate(val, "TargetResourceID", &s.TargetResourceID) + delete(rawMsg, key) + case "taskType": + err = unpopulate(val, "TaskType", &s.TaskType) + delete(rawMsg, key) + case "timeZoneId": + err = unpopulate(val, "TimeZoneID", &s.TimeZoneID) + delete(rawMsg, key) + case "weeklyRecurrence": + err = unpopulate(val, "WeeklyRecurrence", &s.WeeklyRecurrence) + 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 ScheduleFragment. +func (s ScheduleFragment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScheduleFragment. +func (s *ScheduleFragment) UnmarshalJSON(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 "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 ScheduleList. +func (s ScheduleList) 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 ScheduleList. +func (s *ScheduleList) UnmarshalJSON(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 ScheduleProperties. +func (s ScheduleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdDate", s.CreatedDate) + populate(objectMap, "dailyRecurrence", s.DailyRecurrence) + populate(objectMap, "hourlyRecurrence", s.HourlyRecurrence) + populate(objectMap, "notificationSettings", s.NotificationSettings) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "status", s.Status) + populate(objectMap, "targetResourceId", s.TargetResourceID) + populate(objectMap, "taskType", s.TaskType) + populate(objectMap, "timeZoneId", s.TimeZoneID) + populate(objectMap, "uniqueIdentifier", s.UniqueIdentifier) + populate(objectMap, "weeklyRecurrence", s.WeeklyRecurrence) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScheduleProperties. +func (s *ScheduleProperties) UnmarshalJSON(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 "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &s.CreatedDate) + delete(rawMsg, key) + case "dailyRecurrence": + err = unpopulate(val, "DailyRecurrence", &s.DailyRecurrence) + delete(rawMsg, key) + case "hourlyRecurrence": + err = unpopulate(val, "HourlyRecurrence", &s.HourlyRecurrence) + delete(rawMsg, key) + case "notificationSettings": + err = unpopulate(val, "NotificationSettings", &s.NotificationSettings) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + delete(rawMsg, key) + case "targetResourceId": + err = unpopulate(val, "TargetResourceID", &s.TargetResourceID) + delete(rawMsg, key) + case "taskType": + err = unpopulate(val, "TaskType", &s.TaskType) + delete(rawMsg, key) + case "timeZoneId": + err = unpopulate(val, "TimeZoneID", &s.TimeZoneID) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &s.UniqueIdentifier) + delete(rawMsg, key) + case "weeklyRecurrence": + err = unpopulate(val, "WeeklyRecurrence", &s.WeeklyRecurrence) + 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 Secret. +func (s Secret) 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, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Secret. +func (s *Secret) UnmarshalJSON(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 "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 SecretFragment. +func (s SecretFragment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecretFragment. +func (s *SecretFragment) UnmarshalJSON(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 "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 SecretList. +func (s SecretList) 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 SecretList. +func (s *SecretList) UnmarshalJSON(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 SecretProperties. +func (s SecretProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "uniqueIdentifier", s.UniqueIdentifier) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecretProperties. +func (s *SecretProperties) UnmarshalJSON(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 "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &s.UniqueIdentifier) + 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 ServiceFabric. +func (s ServiceFabric) 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, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceFabric. +func (s *ServiceFabric) UnmarshalJSON(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 "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 ServiceFabricFragment. +func (s ServiceFabricFragment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceFabricFragment. +func (s *ServiceFabricFragment) UnmarshalJSON(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 "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 ServiceFabricList. +func (s ServiceFabricList) 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 ServiceFabricList. +func (s *ServiceFabricList) UnmarshalJSON(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 ServiceFabricProperties. +func (s ServiceFabricProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applicableSchedule", s.ApplicableSchedule) + populate(objectMap, "environmentId", s.EnvironmentID) + populate(objectMap, "externalServiceFabricId", s.ExternalServiceFabricID) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "uniqueIdentifier", s.UniqueIdentifier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceFabricProperties. +func (s *ServiceFabricProperties) UnmarshalJSON(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 "applicableSchedule": + err = unpopulate(val, "ApplicableSchedule", &s.ApplicableSchedule) + delete(rawMsg, key) + case "environmentId": + err = unpopulate(val, "EnvironmentID", &s.EnvironmentID) + delete(rawMsg, key) + case "externalServiceFabricId": + err = unpopulate(val, "ExternalServiceFabricID", &s.ExternalServiceFabricID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &s.UniqueIdentifier) + 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 ServiceRunner. +func (s ServiceRunner) 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, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceRunner. +func (s *ServiceRunner) UnmarshalJSON(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 "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 ServiceRunnerList. +func (s ServiceRunnerList) 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 ServiceRunnerList. +func (s *ServiceRunnerList) UnmarshalJSON(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 SharedPublicIPAddressConfiguration. +func (s SharedPublicIPAddressConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "inboundNatRules", s.InboundNatRules) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SharedPublicIPAddressConfiguration. +func (s *SharedPublicIPAddressConfiguration) UnmarshalJSON(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 "inboundNatRules": + err = unpopulate(val, "InboundNatRules", &s.InboundNatRules) + 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 ShutdownNotificationContent. +func (s ShutdownNotificationContent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "delayUrl120", s.DelayUrl120) + populate(objectMap, "delayUrl60", s.DelayUrl60) + populate(objectMap, "eventType", s.EventType) + populate(objectMap, "guid", s.GUID) + populate(objectMap, "labName", s.LabName) + populate(objectMap, "minutesUntilShutdown", s.MinutesUntilShutdown) + populate(objectMap, "owner", s.Owner) + populate(objectMap, "resourceGroupName", s.ResourceGroupName) + populate(objectMap, "skipUrl", s.SkipURL) + populate(objectMap, "subscriptionId", s.SubscriptionID) + populate(objectMap, "text", s.Text) + populate(objectMap, "vmName", s.VMName) + populate(objectMap, "vmUrl", s.VMURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ShutdownNotificationContent. +func (s *ShutdownNotificationContent) UnmarshalJSON(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 "delayUrl120": + err = unpopulate(val, "DelayUrl120", &s.DelayUrl120) + delete(rawMsg, key) + case "delayUrl60": + err = unpopulate(val, "DelayUrl60", &s.DelayUrl60) + delete(rawMsg, key) + case "eventType": + err = unpopulate(val, "EventType", &s.EventType) + delete(rawMsg, key) + case "guid": + err = unpopulate(val, "GUID", &s.GUID) + delete(rawMsg, key) + case "labName": + err = unpopulate(val, "LabName", &s.LabName) + delete(rawMsg, key) + case "minutesUntilShutdown": + err = unpopulate(val, "MinutesUntilShutdown", &s.MinutesUntilShutdown) + delete(rawMsg, key) + case "owner": + err = unpopulate(val, "Owner", &s.Owner) + delete(rawMsg, key) + case "resourceGroupName": + err = unpopulate(val, "ResourceGroupName", &s.ResourceGroupName) + delete(rawMsg, key) + case "skipUrl": + err = unpopulate(val, "SkipURL", &s.SkipURL) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &s.SubscriptionID) + delete(rawMsg, key) + case "text": + err = unpopulate(val, "Text", &s.Text) + delete(rawMsg, key) + case "vmName": + err = unpopulate(val, "VMName", &s.VMName) + delete(rawMsg, key) + case "vmUrl": + err = unpopulate(val, "VMURL", &s.VMURL) + 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 Subnet. +func (s Subnet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allowPublicIp", s.AllowPublicIP) + populate(objectMap, "labSubnetName", s.LabSubnetName) + populate(objectMap, "resourceId", s.ResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Subnet. +func (s *Subnet) UnmarshalJSON(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 "allowPublicIp": + err = unpopulate(val, "AllowPublicIP", &s.AllowPublicIP) + delete(rawMsg, key) + case "labSubnetName": + err = unpopulate(val, "LabSubnetName", &s.LabSubnetName) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &s.ResourceID) + 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 SubnetOverride. +func (s SubnetOverride) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "labSubnetName", s.LabSubnetName) + populate(objectMap, "resourceId", s.ResourceID) + populate(objectMap, "sharedPublicIpAddressConfiguration", s.SharedPublicIPAddressConfiguration) + populate(objectMap, "useInVmCreationPermission", s.UseInVMCreationPermission) + populate(objectMap, "usePublicIpAddressPermission", s.UsePublicIPAddressPermission) + populate(objectMap, "virtualNetworkPoolName", s.VirtualNetworkPoolName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubnetOverride. +func (s *SubnetOverride) UnmarshalJSON(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 "labSubnetName": + err = unpopulate(val, "LabSubnetName", &s.LabSubnetName) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &s.ResourceID) + delete(rawMsg, key) + case "sharedPublicIpAddressConfiguration": + err = unpopulate(val, "SharedPublicIPAddressConfiguration", &s.SharedPublicIPAddressConfiguration) + delete(rawMsg, key) + case "useInVmCreationPermission": + err = unpopulate(val, "UseInVMCreationPermission", &s.UseInVMCreationPermission) + delete(rawMsg, key) + case "usePublicIpAddressPermission": + err = unpopulate(val, "UsePublicIPAddressPermission", &s.UsePublicIPAddressPermission) + delete(rawMsg, key) + case "virtualNetworkPoolName": + err = unpopulate(val, "VirtualNetworkPoolName", &s.VirtualNetworkPoolName) + 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 SubnetSharedPublicIPAddressConfiguration. +func (s SubnetSharedPublicIPAddressConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allowedPorts", s.AllowedPorts) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubnetSharedPublicIPAddressConfiguration. +func (s *SubnetSharedPublicIPAddressConfiguration) UnmarshalJSON(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 "allowedPorts": + err = unpopulate(val, "AllowedPorts", &s.AllowedPorts) + 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 TargetCostProperties. +func (t TargetCostProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "costThresholds", t.CostThresholds) + populateTimeRFC3339(objectMap, "cycleEndDateTime", t.CycleEndDateTime) + populateTimeRFC3339(objectMap, "cycleStartDateTime", t.CycleStartDateTime) + populate(objectMap, "cycleType", t.CycleType) + populate(objectMap, "status", t.Status) + populate(objectMap, "target", t.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetCostProperties. +func (t *TargetCostProperties) UnmarshalJSON(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 "costThresholds": + err = unpopulate(val, "CostThresholds", &t.CostThresholds) + delete(rawMsg, key) + case "cycleEndDateTime": + err = unpopulateTimeRFC3339(val, "CycleEndDateTime", &t.CycleEndDateTime) + delete(rawMsg, key) + case "cycleStartDateTime": + err = unpopulateTimeRFC3339(val, "CycleStartDateTime", &t.CycleStartDateTime) + delete(rawMsg, key) + case "cycleType": + err = unpopulate(val, "CycleType", &t.CycleType) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &t.Status) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &t.Target) + 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 UpdateResource. +func (u UpdateResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", u.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateResource. +func (u *UpdateResource) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &u.Tags) + 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 User. +func (u User) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", u.ID) + populate(objectMap, "location", u.Location) + populate(objectMap, "name", u.Name) + populate(objectMap, "properties", u.Properties) + populate(objectMap, "tags", u.Tags) + populate(objectMap, "type", u.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type User. +func (u *User) UnmarshalJSON(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 "id": + err = unpopulate(val, "ID", &u.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &u.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &u.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &u.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &u.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &u.Type) + 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 UserFragment. +func (u UserFragment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", u.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserFragment. +func (u *UserFragment) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &u.Tags) + 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 UserIdentity. +func (u UserIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "appId", u.AppID) + populate(objectMap, "objectId", u.ObjectID) + populate(objectMap, "principalId", u.PrincipalID) + populate(objectMap, "principalName", u.PrincipalName) + populate(objectMap, "tenantId", u.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserIdentity. +func (u *UserIdentity) UnmarshalJSON(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 "appId": + err = unpopulate(val, "AppID", &u.AppID) + delete(rawMsg, key) + case "objectId": + err = unpopulate(val, "ObjectID", &u.ObjectID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) + delete(rawMsg, key) + case "principalName": + err = unpopulate(val, "PrincipalName", &u.PrincipalName) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &u.TenantID) + 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 UserList. +func (u UserList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", u.NextLink) + populate(objectMap, "value", u.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserList. +func (u *UserList) UnmarshalJSON(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 "nextLink": + err = unpopulate(val, "NextLink", &u.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &u.Value) + 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 UserProperties. +func (u UserProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdDate", u.CreatedDate) + populate(objectMap, "identity", u.Identity) + populate(objectMap, "provisioningState", u.ProvisioningState) + populate(objectMap, "secretStore", u.SecretStore) + populate(objectMap, "uniqueIdentifier", u.UniqueIdentifier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserProperties. +func (u *UserProperties) UnmarshalJSON(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 "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &u.CreatedDate) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &u.Identity) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &u.ProvisioningState) + delete(rawMsg, key) + case "secretStore": + err = unpopulate(val, "SecretStore", &u.SecretStore) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &u.UniqueIdentifier) + 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 UserSecretStore. +func (u UserSecretStore) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "keyVaultId", u.KeyVaultID) + populate(objectMap, "keyVaultUri", u.KeyVaultURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserSecretStore. +func (u *UserSecretStore) UnmarshalJSON(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 "keyVaultId": + err = unpopulate(val, "KeyVaultID", &u.KeyVaultID) + delete(rawMsg, key) + case "keyVaultUri": + err = unpopulate(val, "KeyVaultURI", &u.KeyVaultURI) + 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 VirtualNetwork. +func (v VirtualNetwork) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", v.ID) + populate(objectMap, "location", v.Location) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "tags", v.Tags) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetwork. +func (v *VirtualNetwork) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &v.Location) + 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 "tags": + err = unpopulate(val, "Tags", &v.Tags) + 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 VirtualNetworkFragment. +func (v VirtualNetworkFragment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", v.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworkFragment. +func (v *VirtualNetworkFragment) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &v.Tags) + 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 VirtualNetworkList. +func (v VirtualNetworkList) 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 VirtualNetworkList. +func (v *VirtualNetworkList) UnmarshalJSON(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 VirtualNetworkProperties. +func (v VirtualNetworkProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allowedSubnets", v.AllowedSubnets) + populateTimeRFC3339(objectMap, "createdDate", v.CreatedDate) + populate(objectMap, "description", v.Description) + populate(objectMap, "externalProviderResourceId", v.ExternalProviderResourceID) + populate(objectMap, "externalSubnets", v.ExternalSubnets) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "subnetOverrides", v.SubnetOverrides) + populate(objectMap, "uniqueIdentifier", v.UniqueIdentifier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworkProperties. +func (v *VirtualNetworkProperties) UnmarshalJSON(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 "allowedSubnets": + err = unpopulate(val, "AllowedSubnets", &v.AllowedSubnets) + delete(rawMsg, key) + case "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &v.CreatedDate) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &v.Description) + delete(rawMsg, key) + case "externalProviderResourceId": + err = unpopulate(val, "ExternalProviderResourceID", &v.ExternalProviderResourceID) + delete(rawMsg, key) + case "externalSubnets": + err = unpopulate(val, "ExternalSubnets", &v.ExternalSubnets) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) + delete(rawMsg, key) + case "subnetOverrides": + err = unpopulate(val, "SubnetOverrides", &v.SubnetOverrides) + delete(rawMsg, key) + case "uniqueIdentifier": + err = unpopulate(val, "UniqueIdentifier", &v.UniqueIdentifier) + 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 WeekDetails. +func (w WeekDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "time", w.Time) + populate(objectMap, "weekdays", w.Weekdays) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WeekDetails. +func (w *WeekDetails) UnmarshalJSON(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 "time": + err = unpopulate(val, "Time", &w.Time) + delete(rawMsg, key) + case "weekdays": + err = unpopulate(val, "Weekdays", &w.Weekdays) + 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 WindowsOsInfo. +func (w WindowsOsInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "windowsOsState", w.WindowsOsState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WindowsOsInfo. +func (w *WindowsOsInfo) UnmarshalJSON(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 "windowsOsState": + err = unpopulate(val, "WindowsOsState", &w.WindowsOsState) + 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/devtestlabs/armdevtestlabs/zz_generated_notificationchannels_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/notificationchannels_client.go similarity index 85% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_notificationchannels_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/notificationchannels_client.go index 0531470b255f..81bdb973a51a 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_notificationchannels_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/notificationchannels_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 armdevtestlabs @@ -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" @@ -26,50 +25,42 @@ import ( // NotificationChannelsClient contains the methods for the NotificationChannels group. // Don't use this type directly, use NewNotificationChannelsClient() instead. type NotificationChannelsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewNotificationChannelsClient creates a new instance of NotificationChannelsClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewNotificationChannelsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*NotificationChannelsClient, 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+".NotificationChannelsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &NotificationChannelsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or replace an existing notification channel. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the notification channel. -// notificationChannel - A notification. -// options - NotificationChannelsClientCreateOrUpdateOptions contains the optional parameters for the NotificationChannelsClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the notification channel. +// - notificationChannel - A notification. +// - options - NotificationChannelsClientCreateOrUpdateOptions contains the optional parameters for the NotificationChannelsClient.CreateOrUpdate +// method. func (client *NotificationChannelsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, notificationChannel NotificationChannel, options *NotificationChannelsClientCreateOrUpdateOptions) (NotificationChannelsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, name, notificationChannel, options) if err != nil { return NotificationChannelsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NotificationChannelsClientCreateOrUpdateResponse{}, err } @@ -98,7 +89,7 @@ func (client *NotificationChannelsClient) createOrUpdateCreateRequest(ctx contex 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 } @@ -120,18 +111,19 @@ func (client *NotificationChannelsClient) createOrUpdateHandleResponse(resp *htt // Delete - Delete notification channel. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the notification channel. -// options - NotificationChannelsClientDeleteOptions contains the optional parameters for the NotificationChannelsClient.Delete -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the notification channel. +// - options - NotificationChannelsClientDeleteOptions contains the optional parameters for the NotificationChannelsClient.Delete +// method. func (client *NotificationChannelsClient) Delete(ctx context.Context, resourceGroupName string, labName string, name string, options *NotificationChannelsClientDeleteOptions) (NotificationChannelsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return NotificationChannelsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NotificationChannelsClientDeleteResponse{}, err } @@ -160,7 +152,7 @@ func (client *NotificationChannelsClient) deleteCreateRequest(ctx context.Contex 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 } @@ -173,18 +165,19 @@ func (client *NotificationChannelsClient) deleteCreateRequest(ctx context.Contex // Get - Get notification channel. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the notification channel. -// options - NotificationChannelsClientGetOptions contains the optional parameters for the NotificationChannelsClient.Get -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the notification channel. +// - options - NotificationChannelsClientGetOptions contains the optional parameters for the NotificationChannelsClient.Get +// method. func (client *NotificationChannelsClient) Get(ctx context.Context, resourceGroupName string, labName string, name string, options *NotificationChannelsClientGetOptions) (NotificationChannelsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return NotificationChannelsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NotificationChannelsClientGetResponse{}, err } @@ -213,7 +206,7 @@ func (client *NotificationChannelsClient) 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 } @@ -237,12 +230,12 @@ func (client *NotificationChannelsClient) getHandleResponse(resp *http.Response) } // NewListPager - List notification channels in a given lab. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// options - NotificationChannelsClientListOptions contains the optional parameters for the NotificationChannelsClient.List -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - options - NotificationChannelsClientListOptions contains the optional parameters for the NotificationChannelsClient.NewListPager +// method. func (client *NotificationChannelsClient) NewListPager(resourceGroupName string, labName string, options *NotificationChannelsClientListOptions) *runtime.Pager[NotificationChannelsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[NotificationChannelsClientListResponse]{ More: func(page NotificationChannelsClientListResponse) bool { @@ -259,7 +252,7 @@ func (client *NotificationChannelsClient) NewListPager(resourceGroupName string, if err != nil { return NotificationChannelsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NotificationChannelsClientListResponse{}, err } @@ -286,7 +279,7 @@ func (client *NotificationChannelsClient) listCreateRequest(ctx context.Context, return nil, errors.New("parameter labName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) - 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,19 +313,20 @@ func (client *NotificationChannelsClient) listHandleResponse(resp *http.Response // Notify - Send notification to provided channel. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the notification channel. -// notifyParameters - Properties for generating a Notification. -// options - NotificationChannelsClientNotifyOptions contains the optional parameters for the NotificationChannelsClient.Notify -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the notification channel. +// - notifyParameters - Properties for generating a Notification. +// - options - NotificationChannelsClientNotifyOptions contains the optional parameters for the NotificationChannelsClient.Notify +// method. func (client *NotificationChannelsClient) Notify(ctx context.Context, resourceGroupName string, labName string, name string, notifyParameters NotifyParameters, options *NotificationChannelsClientNotifyOptions) (NotificationChannelsClientNotifyResponse, error) { req, err := client.notifyCreateRequest(ctx, resourceGroupName, labName, name, notifyParameters, options) if err != nil { return NotificationChannelsClientNotifyResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NotificationChannelsClientNotifyResponse{}, err } @@ -361,7 +355,7 @@ func (client *NotificationChannelsClient) notifyCreateRequest(ctx context.Contex return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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,19 +368,20 @@ func (client *NotificationChannelsClient) notifyCreateRequest(ctx context.Contex // Update - Allows modifying tags of notification channels. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the notification channel. -// notificationChannel - A notification. -// options - NotificationChannelsClientUpdateOptions contains the optional parameters for the NotificationChannelsClient.Update -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the notification channel. +// - notificationChannel - A notification. +// - options - NotificationChannelsClientUpdateOptions contains the optional parameters for the NotificationChannelsClient.Update +// method. func (client *NotificationChannelsClient) Update(ctx context.Context, resourceGroupName string, labName string, name string, notificationChannel NotificationChannelFragment, options *NotificationChannelsClientUpdateOptions) (NotificationChannelsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, name, notificationChannel, options) if err != nil { return NotificationChannelsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NotificationChannelsClientUpdateResponse{}, err } @@ -415,7 +410,7 @@ func (client *NotificationChannelsClient) updateCreateRequest(ctx context.Contex return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/notificationchannels_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/notificationchannels_client_example_test.go new file mode 100644 index 000000000000..a528996b84a9 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/notificationchannels_client_example_test.go @@ -0,0 +1,268 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_List.json +func ExampleNotificationChannelsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewNotificationChannelsClient().NewListPager("resourceGroupName", "{labName}", &armdevtestlabs.NotificationChannelsClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.NotificationChannelList = armdevtestlabs.NotificationChannelList{ + // Value: []*armdevtestlabs.NotificationChannel{ + // { + // Name: to.Ptr("autoshutdown"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/notificationChannels"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/notificationChannels/{notificationChannelName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.NotificationChannelProperties{ + // Description: to.Ptr("Integration configured for auto-shutdown"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-05T02:12:10.6566371+00:00"); return t}()), + // EmailRecipient: to.Ptr("{email}"), + // Events: []*armdevtestlabs.Event{ + // { + // EventName: to.Ptr(armdevtestlabs.NotificationChannelEventTypeAutoShutdown), + // }}, + // NotificationLocale: to.Ptr("en"), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WebHookURL: to.Ptr("{webhookUrl}"), + // }, + // }, + // { + // Name: to.Ptr("costThreshold"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/notificationChannels"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/notificationChannels/{notificationChannelName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.NotificationChannelProperties{ + // Description: to.Ptr("Integration configured for cost"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-05T02:14:05.2392034+00:00"); return t}()), + // Events: []*armdevtestlabs.Event{ + // { + // EventName: to.Ptr(armdevtestlabs.NotificationChannelEventTypeCost), + // }}, + // NotificationLocale: to.Ptr("en"), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WebHookURL: to.Ptr("{webhookUrl}"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_Get.json +func ExampleNotificationChannelsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNotificationChannelsClient().Get(ctx, "resourceGroupName", "{labName}", "{notificationChannelName}", &armdevtestlabs.NotificationChannelsClientGetOptions{Expand: 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.NotificationChannel = armdevtestlabs.NotificationChannel{ + // Name: to.Ptr("{notificationChannelName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/notificationChannels"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/notificationChannels/{notificationChannelName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.NotificationChannelProperties{ + // Description: to.Ptr("Integration configured for auto-shutdown"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-05T02:14:05.2392034+00:00"); return t}()), + // EmailRecipient: to.Ptr("{email}"), + // Events: []*armdevtestlabs.Event{ + // { + // EventName: to.Ptr(armdevtestlabs.NotificationChannelEventTypeAutoShutdown), + // }}, + // NotificationLocale: to.Ptr("en"), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WebHookURL: to.Ptr("{webhookUrl}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_CreateOrUpdate.json +func ExampleNotificationChannelsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNotificationChannelsClient().CreateOrUpdate(ctx, "resourceGroupName", "{labName}", "{notificationChannelName}", armdevtestlabs.NotificationChannel{ + Properties: &armdevtestlabs.NotificationChannelProperties{ + Description: to.Ptr("Integration configured for auto-shutdown"), + EmailRecipient: to.Ptr("{email}"), + Events: []*armdevtestlabs.Event{ + { + EventName: to.Ptr(armdevtestlabs.NotificationChannelEventTypeAutoShutdown), + }}, + NotificationLocale: to.Ptr("en"), + WebHookURL: to.Ptr("{webhookUrl}"), + }, + }, 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.NotificationChannel = armdevtestlabs.NotificationChannel{ + // Name: to.Ptr("{notificationChannelName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/notificationChannels"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/notificationChannels/{notificationChannelName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.NotificationChannelProperties{ + // Description: to.Ptr("Integration configured for auto-shutdown"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-05T02:14:05.2392034+00:00"); return t}()), + // EmailRecipient: to.Ptr("{email}"), + // Events: []*armdevtestlabs.Event{ + // { + // EventName: to.Ptr(armdevtestlabs.NotificationChannelEventTypeAutoShutdown), + // }}, + // NotificationLocale: to.Ptr("en"), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WebHookURL: to.Ptr("{webhookUrl}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_Delete.json +func ExampleNotificationChannelsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewNotificationChannelsClient().Delete(ctx, "resourceGroupName", "{labName}", "{notificationChannelName}", 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_Update.json +func ExampleNotificationChannelsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNotificationChannelsClient().Update(ctx, "resourceGroupName", "{labName}", "{notificationChannelName}", armdevtestlabs.NotificationChannelFragment{}, 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.NotificationChannel = armdevtestlabs.NotificationChannel{ + // Name: to.Ptr("{notificationChannelName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/notificationChannels"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/notificationChannels/{notificationChannelName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.NotificationChannelProperties{ + // Description: to.Ptr("Integration configured for auto-shutdown"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-05T02:14:05.2392034+00:00"); return t}()), + // EmailRecipient: to.Ptr("{email}"), + // Events: []*armdevtestlabs.Event{ + // { + // EventName: to.Ptr(armdevtestlabs.NotificationChannelEventTypeAutoShutdown), + // }}, + // NotificationLocale: to.Ptr("en"), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WebHookURL: to.Ptr("{webhookUrl}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_Notify.json +func ExampleNotificationChannelsClient_Notify() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewNotificationChannelsClient().Notify(ctx, "resourceGroupName", "{labName}", "{notificationChannelName}", armdevtestlabs.NotifyParameters{ + EventName: to.Ptr(armdevtestlabs.NotificationChannelEventTypeAutoShutdown), + JSONPayload: to.Ptr("{\"eventType\":\"AutoShutdown\",\"subscriptionId\":\"{subscriptionId}\",\"resourceGroupName\":\"resourceGroupName\",\"labName\":\"{labName}\"}"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_operations_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/operations_client.go similarity index 77% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_operations_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/operations_client.go index b7e88ba44750..f1cb6b3e75fa 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_operations_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/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 armdevtestlabs @@ -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 ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(subscriptionID string, 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{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get operation. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// locationName - The name of the location. -// name - The name of the operation. -// options - OperationsClientGetOptions contains the optional parameters for the OperationsClient.Get method. +// - locationName - The name of the location. +// - name - The name of the operation. +// - options - OperationsClientGetOptions contains the optional parameters for the OperationsClient.Get method. func (client *OperationsClient) Get(ctx context.Context, locationName string, name string, options *OperationsClientGetOptions) (OperationsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, locationName, name, options) if err != nil { return OperationsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientGetResponse{}, err } @@ -90,7 +81,7 @@ func (client *OperationsClient) getCreateRequest(ctx context.Context, locationNa 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 } diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/operations_client_example_test.go similarity index 53% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_operations_client_test.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/operations_client_example_test.go index 6f2bec51e69c..ac938a5fcf7f 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_operations_client_test.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/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 armdevtestlabs_test @@ -16,24 +17,26 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devtestlabs/armdevtestlabs" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Operations_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Operations_Get.json func ExampleOperationsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdevtestlabs.NewOperationsClient("{subscriptionId}", cred, nil) + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, - "{locationName}", - "{operationName}", - nil) + res, err := clientFactory.NewOperationsClient().Get(ctx, "{locationName}", "{operationName}", 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.OperationResult = armdevtestlabs.OperationResult{ + // Status: to.Ptr("Running"), + // StatusCode: to.Ptr(armdevtestlabs.HTTPStatusCodeOK), + // } } diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_policies_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/policies_client.go similarity index 86% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_policies_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/policies_client.go index e75774aaf659..7474f84e7423 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_policies_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/policies_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 armdevtestlabs @@ -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" @@ -26,50 +25,42 @@ import ( // PoliciesClient contains the methods for the Policies group. // Don't use this type directly, use NewPoliciesClient() instead. type PoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPoliciesClient creates a new instance of PoliciesClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PoliciesClient, 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+".PoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or replace an existing policy. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// policySetName - The name of the policy set. -// name - The name of the policy. -// policy - A Policy. -// options - PoliciesClientCreateOrUpdateOptions contains the optional parameters for the PoliciesClient.CreateOrUpdate method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - policySetName - The name of the policy set. +// - name - The name of the policy. +// - policy - A Policy. +// - options - PoliciesClientCreateOrUpdateOptions contains the optional parameters for the PoliciesClient.CreateOrUpdate method. func (client *PoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, policySetName string, name string, policy Policy, options *PoliciesClientCreateOrUpdateOptions) (PoliciesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, policySetName, name, policy, options) if err != nil { return PoliciesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PoliciesClientCreateOrUpdateResponse{}, err } @@ -102,7 +93,7 @@ func (client *PoliciesClient) createOrUpdateCreateRequest(ctx context.Context, r 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 } @@ -124,18 +115,19 @@ func (client *PoliciesClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Delete policy. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// policySetName - The name of the policy set. -// name - The name of the policy. -// options - PoliciesClientDeleteOptions contains the optional parameters for the PoliciesClient.Delete method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - policySetName - The name of the policy set. +// - name - The name of the policy. +// - options - PoliciesClientDeleteOptions contains the optional parameters for the PoliciesClient.Delete method. func (client *PoliciesClient) Delete(ctx context.Context, resourceGroupName string, labName string, policySetName string, name string, options *PoliciesClientDeleteOptions) (PoliciesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, policySetName, name, options) if err != nil { return PoliciesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PoliciesClientDeleteResponse{}, err } @@ -168,7 +160,7 @@ func (client *PoliciesClient) deleteCreateRequest(ctx context.Context, resourceG 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 } @@ -181,18 +173,19 @@ func (client *PoliciesClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Get policy. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// policySetName - The name of the policy set. -// name - The name of the policy. -// options - PoliciesClientGetOptions contains the optional parameters for the PoliciesClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - policySetName - The name of the policy set. +// - name - The name of the policy. +// - options - PoliciesClientGetOptions contains the optional parameters for the PoliciesClient.Get method. func (client *PoliciesClient) Get(ctx context.Context, resourceGroupName string, labName string, policySetName string, name string, options *PoliciesClientGetOptions) (PoliciesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, policySetName, name, options) if err != nil { return PoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PoliciesClientGetResponse{}, err } @@ -225,7 +218,7 @@ func (client *PoliciesClient) getCreateRequest(ctx context.Context, resourceGrou 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 } @@ -249,12 +242,12 @@ func (client *PoliciesClient) getHandleResponse(resp *http.Response) (PoliciesCl } // NewListPager - List policies in a given policy set. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// policySetName - The name of the policy set. -// options - PoliciesClientListOptions contains the optional parameters for the PoliciesClient.List method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - policySetName - The name of the policy set. +// - options - PoliciesClientListOptions contains the optional parameters for the PoliciesClient.NewListPager method. func (client *PoliciesClient) NewListPager(resourceGroupName string, labName string, policySetName string, options *PoliciesClientListOptions) *runtime.Pager[PoliciesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[PoliciesClientListResponse]{ More: func(page PoliciesClientListResponse) bool { @@ -271,7 +264,7 @@ func (client *PoliciesClient) NewListPager(resourceGroupName string, labName str if err != nil { return PoliciesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PoliciesClientListResponse{}, err } @@ -302,7 +295,7 @@ func (client *PoliciesClient) listCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter policySetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{policySetName}", url.PathEscape(policySetName)) - 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,19 +329,20 @@ func (client *PoliciesClient) listHandleResponse(resp *http.Response) (PoliciesC // Update - Allows modifying tags of policies. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// policySetName - The name of the policy set. -// name - The name of the policy. -// policy - A Policy. -// options - PoliciesClientUpdateOptions contains the optional parameters for the PoliciesClient.Update method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - policySetName - The name of the policy set. +// - name - The name of the policy. +// - policy - A Policy. +// - options - PoliciesClientUpdateOptions contains the optional parameters for the PoliciesClient.Update method. func (client *PoliciesClient) Update(ctx context.Context, resourceGroupName string, labName string, policySetName string, name string, policy PolicyFragment, options *PoliciesClientUpdateOptions) (PoliciesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, policySetName, name, policy, options) if err != nil { return PoliciesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PoliciesClientUpdateResponse{}, err } @@ -381,7 +375,7 @@ func (client *PoliciesClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/policies_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/policies_client_example_test.go new file mode 100644 index 000000000000..809ff2a1b924 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/policies_client_example_test.go @@ -0,0 +1,212 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_List.json +func ExamplePoliciesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPoliciesClient().NewListPager("resourceGroupName", "{labName}", "{policySetName}", &armdevtestlabs.PoliciesClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.PolicyList = armdevtestlabs.PolicyList{ + // Value: []*armdevtestlabs.Policy{ + // { + // Name: to.Ptr("{labName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/policySets/policies"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{policyName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.PolicyProperties{ + // Description: to.Ptr("{policyDescription}"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // EvaluatorType: to.Ptr(armdevtestlabs.PolicyEvaluatorType("{policyEvaluatorType}")), + // FactData: to.Ptr("{policyFactData}"), + // FactName: to.Ptr(armdevtestlabs.PolicyFactName("{policyFactName}")), + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.PolicyStatus("{policyStatus}")), + // Threshold: to.Ptr("{policyThreshold}"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_Get.json +func ExamplePoliciesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPoliciesClient().Get(ctx, "resourceGroupName", "{labName}", "{policySetName}", "{policyName}", &armdevtestlabs.PoliciesClientGetOptions{Expand: 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.Policy = armdevtestlabs.Policy{ + // Properties: &armdevtestlabs.PolicyProperties{ + // Description: to.Ptr("{policyDescription}"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // EvaluatorType: to.Ptr(armdevtestlabs.PolicyEvaluatorType("{policyEvaluatorType}")), + // FactData: to.Ptr("{policyFactData}"), + // FactName: to.Ptr(armdevtestlabs.PolicyFactName("{policyFactName}")), + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.PolicyStatus("{policyStatus}")), + // Threshold: to.Ptr("{policyThreshold}"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_CreateOrUpdate.json +func ExamplePoliciesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPoliciesClient().CreateOrUpdate(ctx, "resourceGroupName", "{labName}", "{policySetName}", "{policyName}", armdevtestlabs.Policy{ + Location: to.Ptr("{location}"), + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + Properties: &armdevtestlabs.PolicyProperties{ + Description: to.Ptr("{policyDescription}"), + EvaluatorType: to.Ptr(armdevtestlabs.PolicyEvaluatorType("{policyEvaluatorType}")), + FactData: to.Ptr("{policyFactData}"), + FactName: to.Ptr(armdevtestlabs.PolicyFactName("{policyFactName}")), + Status: to.Ptr(armdevtestlabs.PolicyStatus("{policyStatus}")), + Threshold: to.Ptr("{policyThreshold}"), + }, + }, 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.Policy = armdevtestlabs.Policy{ + // Name: to.Ptr("{labName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/policies"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{policyName}"), + // Location: to.Ptr("{location}"), + // Properties: &armdevtestlabs.PolicyProperties{ + // Description: to.Ptr("{policyDescription}"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // EvaluatorType: to.Ptr(armdevtestlabs.PolicyEvaluatorType("{policyEvaluatorType}")), + // FactData: to.Ptr("{policyFactData}"), + // FactName: to.Ptr(armdevtestlabs.PolicyFactName("{policyFactName}")), + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.PolicyStatus("{policyStatus}")), + // Threshold: to.Ptr("{policyThreshold}"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_Delete.json +func ExamplePoliciesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewPoliciesClient().Delete(ctx, "resourceGroupName", "{labName}", "{policySetName}", "{policyName}", 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_Update.json +func ExamplePoliciesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPoliciesClient().Update(ctx, "resourceGroupName", "{labName}", "{policySetName}", "{policyName}", armdevtestlabs.PolicyFragment{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + }, 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.Policy = armdevtestlabs.Policy{ + // Name: to.Ptr("{labName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/policies"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{policyName}"), + // Location: to.Ptr("{location}"), + // Properties: &armdevtestlabs.PolicyProperties{ + // Description: to.Ptr("{policyDescription}"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // EvaluatorType: to.Ptr(armdevtestlabs.PolicyEvaluatorType("{policyEvaluatorType}")), + // FactData: to.Ptr("{policyFactData}"), + // FactName: to.Ptr(armdevtestlabs.PolicyFactName("{policyFactName}")), + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.PolicyStatus("{policyStatus}")), + // Threshold: to.Ptr("{policyThreshold}"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_policysets_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/policysets_client.go similarity index 78% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_policysets_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/policysets_client.go index 875b43d1b747..5c4686c45413 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_policysets_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/policysets_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 armdevtestlabs @@ -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 ( // PolicySetsClient contains the methods for the PolicySets group. // Don't use this type directly, use NewPolicySetsClient() instead. type PolicySetsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPolicySetsClient creates a new instance of PolicySetsClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPolicySetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PolicySetsClient, 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+".PolicySetsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PolicySetsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // EvaluatePolicies - Evaluates lab policy. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the policy set. -// evaluatePoliciesRequest - Request body for evaluating a policy set. -// options - PolicySetsClientEvaluatePoliciesOptions contains the optional parameters for the PolicySetsClient.EvaluatePolicies -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the policy set. +// - evaluatePoliciesRequest - Request body for evaluating a policy set. +// - options - PolicySetsClientEvaluatePoliciesOptions contains the optional parameters for the PolicySetsClient.EvaluatePolicies +// method. func (client *PolicySetsClient) EvaluatePolicies(ctx context.Context, resourceGroupName string, labName string, name string, evaluatePoliciesRequest EvaluatePoliciesRequest, options *PolicySetsClientEvaluatePoliciesOptions) (PolicySetsClientEvaluatePoliciesResponse, error) { req, err := client.evaluatePoliciesCreateRequest(ctx, resourceGroupName, labName, name, evaluatePoliciesRequest, options) if err != nil { return PolicySetsClientEvaluatePoliciesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PolicySetsClientEvaluatePoliciesResponse{}, err } @@ -97,7 +88,7 @@ func (client *PolicySetsClient) evaluatePoliciesCreateRequest(ctx context.Contex return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/policysets_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/policysets_client_example_test.go new file mode 100644 index 000000000000..aebb625ec7cc --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/policysets_client_example_test.go @@ -0,0 +1,56 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/PolicySets_EvaluatePolicies.json +func ExamplePolicySetsClient_EvaluatePolicies() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPolicySetsClient().EvaluatePolicies(ctx, "resourceGroupName", "{labName}", "{policySetName}", armdevtestlabs.EvaluatePoliciesRequest{ + Policies: []*armdevtestlabs.EvaluatePoliciesProperties{ + { + FactName: to.Ptr("LabVmCount"), + ValueOffset: to.Ptr("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.EvaluatePoliciesResponse = armdevtestlabs.EvaluatePoliciesResponse{ + // Results: []*armdevtestlabs.PolicySetResult{ + // { + // HasError: to.Ptr(true), + // PolicyViolations: []*armdevtestlabs.PolicyViolation{ + // { + // Code: to.Ptr("MaxValuePolicy"), + // Message: to.Ptr("You cannot exceed the limit (1) of virtual machines that can be created in this lab."), + // }}, + // }}, + // } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_provideroperations_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/provideroperations_client.go similarity index 79% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_provideroperations_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/provideroperations_client.go index 3c589c6a4aa8..082545dc3ecb 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_provideroperations_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/provideroperations_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 armdevtestlabs @@ -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,28 @@ import ( // ProviderOperationsClient contains the methods for the ProviderOperations group. // Don't use this type directly, use NewProviderOperationsClient() instead. type ProviderOperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewProviderOperationsClient creates a new instance of ProviderOperationsClient 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 NewProviderOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ProviderOperationsClient, 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+".ProviderOperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ProviderOperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Result of the request to list REST API operations -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// options - ProviderOperationsClientListOptions contains the optional parameters for the ProviderOperationsClient.List method. +// - options - ProviderOperationsClientListOptions contains the optional parameters for the ProviderOperationsClient.NewListPager +// method. func (client *ProviderOperationsClient) NewListPager(options *ProviderOperationsClientListOptions) *runtime.Pager[ProviderOperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ProviderOperationsClientListResponse]{ More: func(page ProviderOperationsClientListResponse) bool { @@ -68,7 +59,7 @@ func (client *ProviderOperationsClient) NewListPager(options *ProviderOperations if err != nil { return ProviderOperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProviderOperationsClientListResponse{}, err } @@ -83,7 +74,7 @@ func (client *ProviderOperationsClient) NewListPager(options *ProviderOperations // listCreateRequest creates the List request. func (client *ProviderOperationsClient) listCreateRequest(ctx context.Context, options *ProviderOperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.DevTestLab/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/devtestlabs/armdevtestlabs/provideroperations_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/provideroperations_client_example_test.go new file mode 100644 index 000000000000..50534eca6d17 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/provideroperations_client_example_test.go @@ -0,0 +1,892 @@ +//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 armdevtestlabs_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ProviderOperations_List.json +func ExampleProviderOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewProviderOperationsClient().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.ProviderOperationResult = armdevtestlabs.ProviderOperationResult{ + // Value: []*armdevtestlabs.OperationMetadata{ + // { + // Name: to.Ptr("Microsoft.DevTestLab/register/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Registers the subscription"), + // Operation: to.Ptr("Register Subscription"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("register"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/policySets/EvaluatePolicies/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Evaluates lab policy."), + // Operation: to.Ptr("Evaluate policy"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("policy sets"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete labs."), + // Operation: to.Ptr("Delete labs."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Labs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read labs."), + // Operation: to.Ptr("Read labs."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Labs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify labs."), + // Operation: to.Ptr("Add or modify labs."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Labs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/ListVhds/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("List disk images available for custom image creation."), + // Operation: to.Ptr("List VHDs"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Labs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/GenerateUploadUri/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Generate a URI for uploading custom disk images to a Lab."), + // Operation: to.Ptr("Generate image upload URI"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Labs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/CreateEnvironment/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Create virtual machines in a lab."), + // Operation: to.Ptr("Create a virtual machine"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Labs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/ClaimAnyVm/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Claim a random claimable virtual machine in the lab."), + // Operation: to.Ptr("Claim Any Virtual Machine"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Labs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/ExportResourceUsage/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Exports the lab resource usage into a storage account"), + // Operation: to.Ptr("Exports the lab resource usage into a storage account"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Labs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/ImportVirtualMachine/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Import a virtual machine into a different lab."), + // Operation: to.Ptr("Import a virtual machine"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Labs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/policySets/policies/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete policies."), + // Operation: to.Ptr("Delete policies."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("policies"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/policySets/policies/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read policies."), + // Operation: to.Ptr("Read policies."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("policies"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/policySets/policies/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify policies."), + // Operation: to.Ptr("Add or modify policies."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("policies"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/schedules/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete schedules."), + // Operation: to.Ptr("Delete schedules."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/schedules/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read schedules."), + // Operation: to.Ptr("Read schedules."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/schedules/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify schedules."), + // Operation: to.Ptr("Add or modify schedules."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/schedules/Execute/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Execute a schedule."), + // Operation: to.Ptr("Execute schedule"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/schedules/ListApplicable/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Lists all applicable schedules"), + // Operation: to.Ptr("List all applicable schedules"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/schedules/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete schedules."), + // Operation: to.Ptr("Delete schedules."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/schedules/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read schedules."), + // Operation: to.Ptr("Read schedules."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/schedules/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify schedules."), + // Operation: to.Ptr("Add or modify schedules."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/schedules/Execute/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Execute a schedule."), + // Operation: to.Ptr("Execute schedule"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/schedules/Retarget/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Updates a schedule's target resource Id."), + // Operation: to.Ptr("Retarget schedule."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/schedules/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete schedules."), + // Operation: to.Ptr("Delete schedules."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/schedules/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read schedules."), + // Operation: to.Ptr("Read schedules."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/schedules/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify schedules."), + // Operation: to.Ptr("Add or modify schedules."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/schedules/Execute/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Execute a schedule."), + // Operation: to.Ptr("Execute schedule"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/serviceFabrics/schedules/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete schedules."), + // Operation: to.Ptr("Delete schedules."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/serviceFabrics/schedules/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read schedules."), + // Operation: to.Ptr("Read schedules."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/serviceFabrics/schedules/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify schedules."), + // Operation: to.Ptr("Add or modify schedules."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/serviceFabrics/schedules/Execute/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Execute a schedule."), + // Operation: to.Ptr("Execute schedule"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("schedules"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/artifactSources/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete artifact sources."), + // Operation: to.Ptr("Delete artifact sources."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Artifact sources"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/artifactSources/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read artifact sources."), + // Operation: to.Ptr("Read artifact sources."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Artifact sources"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/artifactSources/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify artifact sources."), + // Operation: to.Ptr("Add or modify artifact sources."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Artifact sources"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/artifactSources/artifacts/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read artifacts."), + // Operation: to.Ptr("Read artifacts."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Artifacts"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/artifactSources/artifacts/GenerateArmTemplate/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Generates an ARM template for the given artifact, uploads the required files to a storage account, and validates the generated artifact."), + // Operation: to.Ptr("Generates an ARM template for the given artifact"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Artifacts"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/galleryImages/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read gallery images."), + // Operation: to.Ptr("Read gallery images."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("gallery images"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/customImages/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete custom images."), + // Operation: to.Ptr("Delete custom images."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("custom images"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/customImages/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read custom images."), + // Operation: to.Ptr("Read custom images."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("custom images"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/customImages/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify custom images."), + // Operation: to.Ptr("Add or modify custom images."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("custom images"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualNetworks/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete virtual networks."), + // Operation: to.Ptr("Delete virtual networks."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("virtual networks"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualNetworks/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read virtual networks."), + // Operation: to.Ptr("Read virtual networks."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("virtual networks"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualNetworks/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify virtual networks."), + // Operation: to.Ptr("Add or modify virtual networks."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("virtual networks"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete virtual machines."), + // Operation: to.Ptr("Delete virtual machines."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read virtual machines."), + // Operation: to.Ptr("Read virtual machines."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify virtual machines."), + // Operation: to.Ptr("Add or modify virtual machines."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/Start/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Start a virtual machine."), + // Operation: to.Ptr("Start virtual machine"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/Stop/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Stop a virtual machine"), + // Operation: to.Ptr("Stop virtual machine"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/Restart/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Restart a virtual machine."), + // Operation: to.Ptr("Restart virtual machine"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/Redeploy/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Redeploy a virtual machine"), + // Operation: to.Ptr("Redeploy a virtual machine"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/Resize/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Resize Virtual Machine."), + // Operation: to.Ptr("Resize Virtual Machine."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/ApplyArtifacts/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Apply artifacts to virtual machine."), + // Operation: to.Ptr("Apply artifacts to virtual machine"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/AddDataDisk/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Attach a new or existing data disk to virtual machine."), + // Operation: to.Ptr("Add or attach a data disk"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/DetachDataDisk/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Detach the specified disk from the virtual machine."), + // Operation: to.Ptr("Detach the specified disk from the virtual machine"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/Claim/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Take ownership of an existing virtual machine"), + // Operation: to.Ptr("Claim a virtual machine"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/UnClaim/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Release ownership of an existing virtual machine"), + // Operation: to.Ptr("Unclaim a virtual machine"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/TransferDisks/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Transfer ownership of virtual machine data disks to yourself"), + // Operation: to.Ptr("Transfer data disks to yourself"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/ListApplicableSchedules/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Lists all applicable schedules"), + // Operation: to.Ptr("List all applicable schedules"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/GetRdpFileContents/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Gets a string that represents the contents of the RDP file for the virtual machine"), + // Operation: to.Ptr("Get RDP file contents"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Virtual machines"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/formulas/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete formulas."), + // Operation: to.Ptr("Delete formulas."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Formulas"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/formulas/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read formulas."), + // Operation: to.Ptr("Read formulas."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Formulas"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/formulas/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify formulas."), + // Operation: to.Ptr("Add or modify formulas."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Formulas"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/costs/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read costs."), + // Operation: to.Ptr("Read costs."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("costs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/costs/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify costs."), + // Operation: to.Ptr("Add or modify costs."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("costs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/disks/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete disks."), + // Operation: to.Ptr("Delete disks."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("disks"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/disks/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read disks."), + // Operation: to.Ptr("Read disks."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("disks"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/disks/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify disks."), + // Operation: to.Ptr("Add or modify disks."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("disks"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/disks/Attach/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Attach and create the lease of the disk to the virtual machine."), + // Operation: to.Ptr("Attach disk"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("disks"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/disks/Detach/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Detach and break the lease of the disk attached to the virtual machine."), + // Operation: to.Ptr("Detach and break the lease of the disk attached to the virtual machine"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("disks"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete user profiles."), + // Operation: to.Ptr("Delete user profiles."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("user profiles"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read user profiles."), + // Operation: to.Ptr("Read user profiles."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("user profiles"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify user profiles."), + // Operation: to.Ptr("Add or modify user profiles."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("user profiles"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/notificationChannels/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete notification channels."), + // Operation: to.Ptr("Delete notification channels."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("notificationChannels"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/notificationChannels/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read notification channels."), + // Operation: to.Ptr("Read notification channels."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("notificationChannels"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/notificationChannels/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify notification channels."), + // Operation: to.Ptr("Add or modify notification channels."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("notificationChannels"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/notificationChannels/Notify/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Send notification to provided channel."), + // Operation: to.Ptr("Notify"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("notificationChannels"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/secrets/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete secrets."), + // Operation: to.Ptr("Delete secrets."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("secrets"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/secrets/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read secrets."), + // Operation: to.Ptr("Read secrets."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("secrets"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/secrets/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify secrets."), + // Operation: to.Ptr("Add or modify secrets."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("secrets"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/locations/operations/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read operations."), + // Operation: to.Ptr("Read operations."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("operations"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/artifactSources/armTemplates/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read azure resource manager templates."), + // Operation: to.Ptr("Read azure resource manager templates."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Azure Resource Manager templates"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/environments/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete environments."), + // Operation: to.Ptr("Delete environments."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("environments"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/environments/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read environments."), + // Operation: to.Ptr("Read environments."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("environments"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/environments/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify environments."), + // Operation: to.Ptr("Add or modify environments."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("environments"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/serviceRunners/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete service runners."), + // Operation: to.Ptr("Delete service runners."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Service runners"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/serviceRunners/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read service runners."), + // Operation: to.Ptr("Read service runners."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Service runners"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/serviceRunners/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify service runners."), + // Operation: to.Ptr("Add or modify service runners."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Service runners"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/serviceFabrics/delete"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Delete service fabrics."), + // Operation: to.Ptr("Delete service fabrics."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Service Fabrics"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/serviceFabrics/read"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Read service fabrics."), + // Operation: to.Ptr("Read service fabrics."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Service Fabrics"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/serviceFabrics/write"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Add or modify service fabrics."), + // Operation: to.Ptr("Add or modify service fabrics."), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Service Fabrics"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/serviceFabrics/Start/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Start a service fabric."), + // Operation: to.Ptr("Start service fabric"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Service Fabrics"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/serviceFabrics/Stop/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Stop a service fabric"), + // Operation: to.Ptr("Stop service fabric"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Service Fabrics"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DevTestLab/labs/users/serviceFabrics/ListApplicableSchedules/action"), + // Display: &armdevtestlabs.OperationMetadataDisplay{ + // Description: to.Ptr("Lists all applicable schedules"), + // Operation: to.Ptr("List all applicable schedules"), + // Provider: to.Ptr("Microsoft DevTest Labs"), + // Resource: to.Ptr("Service Fabrics"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_response_types.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/response_types.go similarity index 87% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_response_types.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/response_types.go index 719a28021754..03ea54b20f24 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_response_types.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/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 armdevtestlabs @@ -13,7 +14,7 @@ type ArmTemplatesClientGetResponse struct { ArmTemplate } -// ArmTemplatesClientListResponse contains the response from method ArmTemplatesClient.List. +// ArmTemplatesClientListResponse contains the response from method ArmTemplatesClient.NewListPager. type ArmTemplatesClientListResponse struct { ArmTemplateList } @@ -33,7 +34,7 @@ type ArtifactSourcesClientGetResponse struct { ArtifactSource } -// ArtifactSourcesClientListResponse contains the response from method ArtifactSourcesClient.List. +// ArtifactSourcesClientListResponse contains the response from method ArtifactSourcesClient.NewListPager. type ArtifactSourcesClientListResponse struct { ArtifactSourceList } @@ -53,7 +54,7 @@ type ArtifactsClientGetResponse struct { Artifact } -// ArtifactsClientListResponse contains the response from method ArtifactsClient.List. +// ArtifactsClientListResponse contains the response from method ArtifactsClient.NewListPager. type ArtifactsClientListResponse struct { ArtifactList } @@ -68,12 +69,12 @@ type CostsClientGetResponse struct { LabCost } -// CustomImagesClientCreateOrUpdateResponse contains the response from method CustomImagesClient.CreateOrUpdate. +// CustomImagesClientCreateOrUpdateResponse contains the response from method CustomImagesClient.BeginCreateOrUpdate. type CustomImagesClientCreateOrUpdateResponse struct { CustomImage } -// CustomImagesClientDeleteResponse contains the response from method CustomImagesClient.Delete. +// CustomImagesClientDeleteResponse contains the response from method CustomImagesClient.BeginDelete. type CustomImagesClientDeleteResponse struct { // placeholder for future response values } @@ -83,7 +84,7 @@ type CustomImagesClientGetResponse struct { CustomImage } -// CustomImagesClientListResponse contains the response from method CustomImagesClient.List. +// CustomImagesClientListResponse contains the response from method CustomImagesClient.NewListPager. type CustomImagesClientListResponse struct { CustomImageList } @@ -93,22 +94,22 @@ type CustomImagesClientUpdateResponse struct { CustomImage } -// DisksClientAttachResponse contains the response from method DisksClient.Attach. +// DisksClientAttachResponse contains the response from method DisksClient.BeginAttach. type DisksClientAttachResponse struct { // placeholder for future response values } -// DisksClientCreateOrUpdateResponse contains the response from method DisksClient.CreateOrUpdate. +// DisksClientCreateOrUpdateResponse contains the response from method DisksClient.BeginCreateOrUpdate. type DisksClientCreateOrUpdateResponse struct { Disk } -// DisksClientDeleteResponse contains the response from method DisksClient.Delete. +// DisksClientDeleteResponse contains the response from method DisksClient.BeginDelete. type DisksClientDeleteResponse struct { // placeholder for future response values } -// DisksClientDetachResponse contains the response from method DisksClient.Detach. +// DisksClientDetachResponse contains the response from method DisksClient.BeginDetach. type DisksClientDetachResponse struct { // placeholder for future response values } @@ -118,7 +119,7 @@ type DisksClientGetResponse struct { Disk } -// DisksClientListResponse contains the response from method DisksClient.List. +// DisksClientListResponse contains the response from method DisksClient.NewListPager. type DisksClientListResponse struct { DiskList } @@ -128,12 +129,12 @@ type DisksClientUpdateResponse struct { Disk } -// EnvironmentsClientCreateOrUpdateResponse contains the response from method EnvironmentsClient.CreateOrUpdate. +// EnvironmentsClientCreateOrUpdateResponse contains the response from method EnvironmentsClient.BeginCreateOrUpdate. type EnvironmentsClientCreateOrUpdateResponse struct { DtlEnvironment } -// EnvironmentsClientDeleteResponse contains the response from method EnvironmentsClient.Delete. +// EnvironmentsClientDeleteResponse contains the response from method EnvironmentsClient.BeginDelete. type EnvironmentsClientDeleteResponse struct { // placeholder for future response values } @@ -143,7 +144,7 @@ type EnvironmentsClientGetResponse struct { DtlEnvironment } -// EnvironmentsClientListResponse contains the response from method EnvironmentsClient.List. +// EnvironmentsClientListResponse contains the response from method EnvironmentsClient.NewListPager. type EnvironmentsClientListResponse struct { DtlEnvironmentList } @@ -153,7 +154,7 @@ type EnvironmentsClientUpdateResponse struct { DtlEnvironment } -// FormulasClientCreateOrUpdateResponse contains the response from method FormulasClient.CreateOrUpdate. +// FormulasClientCreateOrUpdateResponse contains the response from method FormulasClient.BeginCreateOrUpdate. type FormulasClientCreateOrUpdateResponse struct { Formula } @@ -168,7 +169,7 @@ type FormulasClientGetResponse struct { Formula } -// FormulasClientListResponse contains the response from method FormulasClient.List. +// FormulasClientListResponse contains the response from method FormulasClient.NewListPager. type FormulasClientListResponse struct { FormulaList } @@ -178,7 +179,7 @@ type FormulasClientUpdateResponse struct { Formula } -// GalleryImagesClientListResponse contains the response from method GalleryImagesClient.List. +// GalleryImagesClientListResponse contains the response from method GalleryImagesClient.NewListPager. type GalleryImagesClientListResponse struct { GalleryImageList } @@ -193,7 +194,7 @@ type GlobalSchedulesClientDeleteResponse struct { // placeholder for future response values } -// GlobalSchedulesClientExecuteResponse contains the response from method GlobalSchedulesClient.Execute. +// GlobalSchedulesClientExecuteResponse contains the response from method GlobalSchedulesClient.BeginExecute. type GlobalSchedulesClientExecuteResponse struct { // placeholder for future response values } @@ -203,17 +204,17 @@ type GlobalSchedulesClientGetResponse struct { Schedule } -// GlobalSchedulesClientListByResourceGroupResponse contains the response from method GlobalSchedulesClient.ListByResourceGroup. +// GlobalSchedulesClientListByResourceGroupResponse contains the response from method GlobalSchedulesClient.NewListByResourceGroupPager. type GlobalSchedulesClientListByResourceGroupResponse struct { ScheduleList } -// GlobalSchedulesClientListBySubscriptionResponse contains the response from method GlobalSchedulesClient.ListBySubscription. +// GlobalSchedulesClientListBySubscriptionResponse contains the response from method GlobalSchedulesClient.NewListBySubscriptionPager. type GlobalSchedulesClientListBySubscriptionResponse struct { ScheduleList } -// GlobalSchedulesClientRetargetResponse contains the response from method GlobalSchedulesClient.Retarget. +// GlobalSchedulesClientRetargetResponse contains the response from method GlobalSchedulesClient.BeginRetarget. type GlobalSchedulesClientRetargetResponse struct { // placeholder for future response values } @@ -223,27 +224,27 @@ type GlobalSchedulesClientUpdateResponse struct { Schedule } -// LabsClientClaimAnyVMResponse contains the response from method LabsClient.ClaimAnyVM. +// LabsClientClaimAnyVMResponse contains the response from method LabsClient.BeginClaimAnyVM. type LabsClientClaimAnyVMResponse struct { // placeholder for future response values } -// LabsClientCreateEnvironmentResponse contains the response from method LabsClient.CreateEnvironment. +// LabsClientCreateEnvironmentResponse contains the response from method LabsClient.BeginCreateEnvironment. type LabsClientCreateEnvironmentResponse struct { // placeholder for future response values } -// LabsClientCreateOrUpdateResponse contains the response from method LabsClient.CreateOrUpdate. +// LabsClientCreateOrUpdateResponse contains the response from method LabsClient.BeginCreateOrUpdate. type LabsClientCreateOrUpdateResponse struct { Lab } -// LabsClientDeleteResponse contains the response from method LabsClient.Delete. +// LabsClientDeleteResponse contains the response from method LabsClient.BeginDelete. type LabsClientDeleteResponse struct { // placeholder for future response values } -// LabsClientExportResourceUsageResponse contains the response from method LabsClient.ExportResourceUsage. +// LabsClientExportResourceUsageResponse contains the response from method LabsClient.BeginExportResourceUsage. type LabsClientExportResourceUsageResponse struct { // placeholder for future response values } @@ -258,22 +259,22 @@ type LabsClientGetResponse struct { Lab } -// LabsClientImportVirtualMachineResponse contains the response from method LabsClient.ImportVirtualMachine. +// LabsClientImportVirtualMachineResponse contains the response from method LabsClient.BeginImportVirtualMachine. type LabsClientImportVirtualMachineResponse struct { // placeholder for future response values } -// LabsClientListByResourceGroupResponse contains the response from method LabsClient.ListByResourceGroup. +// LabsClientListByResourceGroupResponse contains the response from method LabsClient.NewListByResourceGroupPager. type LabsClientListByResourceGroupResponse struct { LabList } -// LabsClientListBySubscriptionResponse contains the response from method LabsClient.ListBySubscription. +// LabsClientListBySubscriptionResponse contains the response from method LabsClient.NewListBySubscriptionPager. type LabsClientListBySubscriptionResponse struct { LabList } -// LabsClientListVhdsResponse contains the response from method LabsClient.ListVhds. +// LabsClientListVhdsResponse contains the response from method LabsClient.NewListVhdsPager. type LabsClientListVhdsResponse struct { LabVhdList } @@ -298,7 +299,7 @@ type NotificationChannelsClientGetResponse struct { NotificationChannel } -// NotificationChannelsClientListResponse contains the response from method NotificationChannelsClient.List. +// NotificationChannelsClientListResponse contains the response from method NotificationChannelsClient.NewListPager. type NotificationChannelsClientListResponse struct { NotificationChannelList } @@ -333,7 +334,7 @@ type PoliciesClientGetResponse struct { Policy } -// PoliciesClientListResponse contains the response from method PoliciesClient.List. +// PoliciesClientListResponse contains the response from method PoliciesClient.NewListPager. type PoliciesClientListResponse struct { PolicyList } @@ -348,7 +349,7 @@ type PolicySetsClientEvaluatePoliciesResponse struct { EvaluatePoliciesResponse } -// ProviderOperationsClientListResponse contains the response from method ProviderOperationsClient.List. +// ProviderOperationsClientListResponse contains the response from method ProviderOperationsClient.NewListPager. type ProviderOperationsClientListResponse struct { ProviderOperationResult } @@ -363,7 +364,7 @@ type SchedulesClientDeleteResponse struct { // placeholder for future response values } -// SchedulesClientExecuteResponse contains the response from method SchedulesClient.Execute. +// SchedulesClientExecuteResponse contains the response from method SchedulesClient.BeginExecute. type SchedulesClientExecuteResponse struct { // placeholder for future response values } @@ -373,12 +374,12 @@ type SchedulesClientGetResponse struct { Schedule } -// SchedulesClientListApplicableResponse contains the response from method SchedulesClient.ListApplicable. +// SchedulesClientListApplicableResponse contains the response from method SchedulesClient.NewListApplicablePager. type SchedulesClientListApplicableResponse struct { ScheduleList } -// SchedulesClientListResponse contains the response from method SchedulesClient.List. +// SchedulesClientListResponse contains the response from method SchedulesClient.NewListPager. type SchedulesClientListResponse struct { ScheduleList } @@ -388,7 +389,7 @@ type SchedulesClientUpdateResponse struct { Schedule } -// SecretsClientCreateOrUpdateResponse contains the response from method SecretsClient.CreateOrUpdate. +// SecretsClientCreateOrUpdateResponse contains the response from method SecretsClient.BeginCreateOrUpdate. type SecretsClientCreateOrUpdateResponse struct { Secret } @@ -403,7 +404,7 @@ type SecretsClientGetResponse struct { Secret } -// SecretsClientListResponse contains the response from method SecretsClient.List. +// SecretsClientListResponse contains the response from method SecretsClient.NewListPager. type SecretsClientListResponse struct { SecretList } @@ -423,7 +424,7 @@ type ServiceFabricSchedulesClientDeleteResponse struct { // placeholder for future response values } -// ServiceFabricSchedulesClientExecuteResponse contains the response from method ServiceFabricSchedulesClient.Execute. +// ServiceFabricSchedulesClientExecuteResponse contains the response from method ServiceFabricSchedulesClient.BeginExecute. type ServiceFabricSchedulesClientExecuteResponse struct { // placeholder for future response values } @@ -433,7 +434,7 @@ type ServiceFabricSchedulesClientGetResponse struct { Schedule } -// ServiceFabricSchedulesClientListResponse contains the response from method ServiceFabricSchedulesClient.List. +// ServiceFabricSchedulesClientListResponse contains the response from method ServiceFabricSchedulesClient.NewListPager. type ServiceFabricSchedulesClientListResponse struct { ScheduleList } @@ -443,12 +444,12 @@ type ServiceFabricSchedulesClientUpdateResponse struct { Schedule } -// ServiceFabricsClientCreateOrUpdateResponse contains the response from method ServiceFabricsClient.CreateOrUpdate. +// ServiceFabricsClientCreateOrUpdateResponse contains the response from method ServiceFabricsClient.BeginCreateOrUpdate. type ServiceFabricsClientCreateOrUpdateResponse struct { ServiceFabric } -// ServiceFabricsClientDeleteResponse contains the response from method ServiceFabricsClient.Delete. +// ServiceFabricsClientDeleteResponse contains the response from method ServiceFabricsClient.BeginDelete. type ServiceFabricsClientDeleteResponse struct { // placeholder for future response values } @@ -463,17 +464,17 @@ type ServiceFabricsClientListApplicableSchedulesResponse struct { ApplicableSchedule } -// ServiceFabricsClientListResponse contains the response from method ServiceFabricsClient.List. +// ServiceFabricsClientListResponse contains the response from method ServiceFabricsClient.NewListPager. type ServiceFabricsClientListResponse struct { ServiceFabricList } -// ServiceFabricsClientStartResponse contains the response from method ServiceFabricsClient.Start. +// ServiceFabricsClientStartResponse contains the response from method ServiceFabricsClient.BeginStart. type ServiceFabricsClientStartResponse struct { // placeholder for future response values } -// ServiceFabricsClientStopResponse contains the response from method ServiceFabricsClient.Stop. +// ServiceFabricsClientStopResponse contains the response from method ServiceFabricsClient.BeginStop. type ServiceFabricsClientStopResponse struct { // placeholder for future response values } @@ -498,12 +499,12 @@ type ServiceRunnersClientGetResponse struct { ServiceRunner } -// UsersClientCreateOrUpdateResponse contains the response from method UsersClient.CreateOrUpdate. +// UsersClientCreateOrUpdateResponse contains the response from method UsersClient.BeginCreateOrUpdate. type UsersClientCreateOrUpdateResponse struct { User } -// UsersClientDeleteResponse contains the response from method UsersClient.Delete. +// UsersClientDeleteResponse contains the response from method UsersClient.BeginDelete. type UsersClientDeleteResponse struct { // placeholder for future response values } @@ -513,7 +514,7 @@ type UsersClientGetResponse struct { User } -// UsersClientListResponse contains the response from method UsersClient.List. +// UsersClientListResponse contains the response from method UsersClient.NewListPager. type UsersClientListResponse struct { UserList } @@ -533,7 +534,7 @@ type VirtualMachineSchedulesClientDeleteResponse struct { // placeholder for future response values } -// VirtualMachineSchedulesClientExecuteResponse contains the response from method VirtualMachineSchedulesClient.Execute. +// VirtualMachineSchedulesClientExecuteResponse contains the response from method VirtualMachineSchedulesClient.BeginExecute. type VirtualMachineSchedulesClientExecuteResponse struct { // placeholder for future response values } @@ -543,7 +544,7 @@ type VirtualMachineSchedulesClientGetResponse struct { Schedule } -// VirtualMachineSchedulesClientListResponse contains the response from method VirtualMachineSchedulesClient.List. +// VirtualMachineSchedulesClientListResponse contains the response from method VirtualMachineSchedulesClient.NewListPager. type VirtualMachineSchedulesClientListResponse struct { ScheduleList } @@ -553,32 +554,32 @@ type VirtualMachineSchedulesClientUpdateResponse struct { Schedule } -// VirtualMachinesClientAddDataDiskResponse contains the response from method VirtualMachinesClient.AddDataDisk. +// VirtualMachinesClientAddDataDiskResponse contains the response from method VirtualMachinesClient.BeginAddDataDisk. type VirtualMachinesClientAddDataDiskResponse struct { // placeholder for future response values } -// VirtualMachinesClientApplyArtifactsResponse contains the response from method VirtualMachinesClient.ApplyArtifacts. +// VirtualMachinesClientApplyArtifactsResponse contains the response from method VirtualMachinesClient.BeginApplyArtifacts. type VirtualMachinesClientApplyArtifactsResponse struct { // placeholder for future response values } -// VirtualMachinesClientClaimResponse contains the response from method VirtualMachinesClient.Claim. +// VirtualMachinesClientClaimResponse contains the response from method VirtualMachinesClient.BeginClaim. type VirtualMachinesClientClaimResponse struct { // placeholder for future response values } -// VirtualMachinesClientCreateOrUpdateResponse contains the response from method VirtualMachinesClient.CreateOrUpdate. +// VirtualMachinesClientCreateOrUpdateResponse contains the response from method VirtualMachinesClient.BeginCreateOrUpdate. type VirtualMachinesClientCreateOrUpdateResponse struct { LabVirtualMachine } -// VirtualMachinesClientDeleteResponse contains the response from method VirtualMachinesClient.Delete. +// VirtualMachinesClientDeleteResponse contains the response from method VirtualMachinesClient.BeginDelete. type VirtualMachinesClientDeleteResponse struct { // placeholder for future response values } -// VirtualMachinesClientDetachDataDiskResponse contains the response from method VirtualMachinesClient.DetachDataDisk. +// VirtualMachinesClientDetachDataDiskResponse contains the response from method VirtualMachinesClient.BeginDetachDataDisk. type VirtualMachinesClientDetachDataDiskResponse struct { // placeholder for future response values } @@ -598,42 +599,42 @@ type VirtualMachinesClientListApplicableSchedulesResponse struct { ApplicableSchedule } -// VirtualMachinesClientListResponse contains the response from method VirtualMachinesClient.List. +// VirtualMachinesClientListResponse contains the response from method VirtualMachinesClient.NewListPager. type VirtualMachinesClientListResponse struct { LabVirtualMachineList } -// VirtualMachinesClientRedeployResponse contains the response from method VirtualMachinesClient.Redeploy. +// VirtualMachinesClientRedeployResponse contains the response from method VirtualMachinesClient.BeginRedeploy. type VirtualMachinesClientRedeployResponse struct { // placeholder for future response values } -// VirtualMachinesClientResizeResponse contains the response from method VirtualMachinesClient.Resize. +// VirtualMachinesClientResizeResponse contains the response from method VirtualMachinesClient.BeginResize. type VirtualMachinesClientResizeResponse struct { // placeholder for future response values } -// VirtualMachinesClientRestartResponse contains the response from method VirtualMachinesClient.Restart. +// VirtualMachinesClientRestartResponse contains the response from method VirtualMachinesClient.BeginRestart. type VirtualMachinesClientRestartResponse struct { // placeholder for future response values } -// VirtualMachinesClientStartResponse contains the response from method VirtualMachinesClient.Start. +// VirtualMachinesClientStartResponse contains the response from method VirtualMachinesClient.BeginStart. type VirtualMachinesClientStartResponse struct { // placeholder for future response values } -// VirtualMachinesClientStopResponse contains the response from method VirtualMachinesClient.Stop. +// VirtualMachinesClientStopResponse contains the response from method VirtualMachinesClient.BeginStop. type VirtualMachinesClientStopResponse struct { // placeholder for future response values } -// VirtualMachinesClientTransferDisksResponse contains the response from method VirtualMachinesClient.TransferDisks. +// VirtualMachinesClientTransferDisksResponse contains the response from method VirtualMachinesClient.BeginTransferDisks. type VirtualMachinesClientTransferDisksResponse struct { // placeholder for future response values } -// VirtualMachinesClientUnClaimResponse contains the response from method VirtualMachinesClient.UnClaim. +// VirtualMachinesClientUnClaimResponse contains the response from method VirtualMachinesClient.BeginUnClaim. type VirtualMachinesClientUnClaimResponse struct { // placeholder for future response values } @@ -643,12 +644,12 @@ type VirtualMachinesClientUpdateResponse struct { LabVirtualMachine } -// VirtualNetworksClientCreateOrUpdateResponse contains the response from method VirtualNetworksClient.CreateOrUpdate. +// VirtualNetworksClientCreateOrUpdateResponse contains the response from method VirtualNetworksClient.BeginCreateOrUpdate. type VirtualNetworksClientCreateOrUpdateResponse struct { VirtualNetwork } -// VirtualNetworksClientDeleteResponse contains the response from method VirtualNetworksClient.Delete. +// VirtualNetworksClientDeleteResponse contains the response from method VirtualNetworksClient.BeginDelete. type VirtualNetworksClientDeleteResponse struct { // placeholder for future response values } @@ -658,7 +659,7 @@ type VirtualNetworksClientGetResponse struct { VirtualNetwork } -// VirtualNetworksClientListResponse contains the response from method VirtualNetworksClient.List. +// VirtualNetworksClientListResponse contains the response from method VirtualNetworksClient.NewListPager. type VirtualNetworksClientListResponse struct { VirtualNetworkList } diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_schedules_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/schedules_client.go similarity index 86% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_schedules_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/schedules_client.go index 028759890174..02e2b4b66f67 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_schedules_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/schedules_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 armdevtestlabs @@ -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" @@ -26,50 +25,42 @@ import ( // SchedulesClient contains the methods for the Schedules group. // Don't use this type directly, use NewSchedulesClient() instead. type SchedulesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSchedulesClient creates a new instance of SchedulesClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSchedulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SchedulesClient, 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+".SchedulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SchedulesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or replace an existing schedule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the schedule. -// schedule - A schedule. -// options - SchedulesClientCreateOrUpdateOptions contains the optional parameters for the SchedulesClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the schedule. +// - schedule - A schedule. +// - options - SchedulesClientCreateOrUpdateOptions contains the optional parameters for the SchedulesClient.CreateOrUpdate +// method. func (client *SchedulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, schedule Schedule, options *SchedulesClientCreateOrUpdateOptions) (SchedulesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, name, schedule, options) if err != nil { return SchedulesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SchedulesClientCreateOrUpdateResponse{}, err } @@ -98,7 +89,7 @@ func (client *SchedulesClient) createOrUpdateCreateRequest(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.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 +111,18 @@ func (client *SchedulesClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Delete schedule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the schedule. -// options - SchedulesClientDeleteOptions contains the optional parameters for the SchedulesClient.Delete method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the schedule. +// - options - SchedulesClientDeleteOptions contains the optional parameters for the SchedulesClient.Delete method. func (client *SchedulesClient) Delete(ctx context.Context, resourceGroupName string, labName string, name string, options *SchedulesClientDeleteOptions) (SchedulesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return SchedulesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SchedulesClientDeleteResponse{}, err } @@ -159,7 +151,7 @@ func (client *SchedulesClient) deleteCreateRequest(ctx context.Context, resource 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 } @@ -172,32 +164,34 @@ func (client *SchedulesClient) deleteCreateRequest(ctx context.Context, resource // BeginExecute - Execute a schedule. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the schedule. -// options - SchedulesClientBeginExecuteOptions contains the optional parameters for the SchedulesClient.BeginExecute method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the schedule. +// - options - SchedulesClientBeginExecuteOptions contains the optional parameters for the SchedulesClient.BeginExecute method. func (client *SchedulesClient) BeginExecute(ctx context.Context, resourceGroupName string, labName string, name string, options *SchedulesClientBeginExecuteOptions) (*runtime.Poller[SchedulesClientExecuteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.execute(ctx, resourceGroupName, labName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[SchedulesClientExecuteResponse](resp, client.pl, nil) + return runtime.NewPoller[SchedulesClientExecuteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[SchedulesClientExecuteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SchedulesClientExecuteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Execute - Execute a schedule. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *SchedulesClient) execute(ctx context.Context, resourceGroupName string, labName string, name string, options *SchedulesClientBeginExecuteOptions) (*http.Response, error) { req, err := client.executeCreateRequest(ctx, resourceGroupName, labName, name, 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 } @@ -226,7 +220,7 @@ func (client *SchedulesClient) executeCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -239,17 +233,18 @@ func (client *SchedulesClient) executeCreateRequest(ctx context.Context, resourc // Get - Get schedule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the schedule. -// options - SchedulesClientGetOptions contains the optional parameters for the SchedulesClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the schedule. +// - options - SchedulesClientGetOptions contains the optional parameters for the SchedulesClient.Get method. func (client *SchedulesClient) Get(ctx context.Context, resourceGroupName string, labName string, name string, options *SchedulesClientGetOptions) (SchedulesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return SchedulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SchedulesClientGetResponse{}, err } @@ -278,7 +273,7 @@ func (client *SchedulesClient) getCreateRequest(ctx context.Context, resourceGro 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 } @@ -302,11 +297,11 @@ func (client *SchedulesClient) getHandleResponse(resp *http.Response) (Schedules } // NewListPager - List schedules in a given lab. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// options - SchedulesClientListOptions contains the optional parameters for the SchedulesClient.List method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - options - SchedulesClientListOptions contains the optional parameters for the SchedulesClient.NewListPager method. func (client *SchedulesClient) NewListPager(resourceGroupName string, labName string, options *SchedulesClientListOptions) *runtime.Pager[SchedulesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SchedulesClientListResponse]{ More: func(page SchedulesClientListResponse) bool { @@ -323,7 +318,7 @@ func (client *SchedulesClient) NewListPager(resourceGroupName string, labName st if err != nil { return SchedulesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SchedulesClientListResponse{}, err } @@ -350,7 +345,7 @@ func (client *SchedulesClient) listCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter labName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) - 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 } @@ -383,13 +378,13 @@ func (client *SchedulesClient) listHandleResponse(resp *http.Response) (Schedule } // NewListApplicablePager - Lists all applicable schedules -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the schedule. -// options - SchedulesClientListApplicableOptions contains the optional parameters for the SchedulesClient.ListApplicable -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the schedule. +// - options - SchedulesClientListApplicableOptions contains the optional parameters for the SchedulesClient.NewListApplicablePager +// method. func (client *SchedulesClient) NewListApplicablePager(resourceGroupName string, labName string, name string, options *SchedulesClientListApplicableOptions) *runtime.Pager[SchedulesClientListApplicableResponse] { return runtime.NewPager(runtime.PagingHandler[SchedulesClientListApplicableResponse]{ More: func(page SchedulesClientListApplicableResponse) bool { @@ -406,7 +401,7 @@ func (client *SchedulesClient) NewListApplicablePager(resourceGroupName string, if err != nil { return SchedulesClientListApplicableResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SchedulesClientListApplicableResponse{}, err } @@ -437,7 +432,7 @@ func (client *SchedulesClient) listApplicableCreateRequest(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.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 *SchedulesClient) listApplicableHandleResponse(resp *http.Response) // Update - Allows modifying tags of schedules. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the schedule. -// schedule - A schedule. -// options - SchedulesClientUpdateOptions contains the optional parameters for the SchedulesClient.Update method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the schedule. +// - schedule - A schedule. +// - options - SchedulesClientUpdateOptions contains the optional parameters for the SchedulesClient.Update method. func (client *SchedulesClient) Update(ctx context.Context, resourceGroupName string, labName string, name string, schedule ScheduleFragment, options *SchedulesClientUpdateOptions) (SchedulesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, name, schedule, options) if err != nil { return SchedulesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SchedulesClientUpdateResponse{}, err } @@ -499,7 +495,7 @@ func (client *SchedulesClient) updateCreateRequest(ctx context.Context, resource return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/schedules_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/schedules_client_example_test.go new file mode 100644 index 000000000000..cddf979ba877 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/schedules_client_example_test.go @@ -0,0 +1,402 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_List.json +func ExampleSchedulesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSchedulesClient().NewListPager("resourceGroupName", "{labName}", &armdevtestlabs.SchedulesClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.ScheduleList = armdevtestlabs.ScheduleList{ + // Value: []*armdevtestlabs.Schedule{ + // { + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // TaskType: to.Ptr("{myLabVmTaskType}"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Wednesday"), + // to.Ptr("Friday")}, + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_Get.json +func ExampleSchedulesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSchedulesClient().Get(ctx, "resourceGroupName", "{labName}", "{scheduleName}", &armdevtestlabs.SchedulesClientGetOptions{Expand: 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.Schedule = armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // TaskType: to.Ptr("{myLabVmTaskType}"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Wednesday"), + // to.Ptr("Friday")}, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_CreateOrUpdate.json +func ExampleSchedulesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSchedulesClient().CreateOrUpdate(ctx, "resourceGroupName", "{labName}", "{scheduleName}", armdevtestlabs.Schedule{ + Location: to.Ptr("{location}"), + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + Properties: &armdevtestlabs.ScheduleProperties{ + DailyRecurrence: &armdevtestlabs.DayDetails{ + Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + }, + HourlyRecurrence: &armdevtestlabs.HourDetails{ + Minute: to.Ptr[int32](30), + }, + NotificationSettings: &armdevtestlabs.NotificationSettings{ + EmailRecipient: to.Ptr("{email}"), + NotificationLocale: to.Ptr("EN"), + Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + TimeInMinutes: to.Ptr[int32](15), + WebhookURL: to.Ptr("{webhookUrl}"), + }, + Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + TaskType: to.Ptr("{myLabVmTaskType}"), + TimeZoneID: to.Ptr("Pacific Standard Time"), + WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + Weekdays: []*string{ + to.Ptr("Monday"), + to.Ptr("Wednesday"), + to.Ptr("Friday")}, + }, + }, + }, 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.Schedule = armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // TaskType: to.Ptr("{myLabVmTaskType}"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Wednesday"), + // to.Ptr("Friday")}, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_Delete.json +func ExampleSchedulesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewSchedulesClient().Delete(ctx, "resourceGroupName", "{labName}", "{scheduleName}", 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_Update.json +func ExampleSchedulesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSchedulesClient().Update(ctx, "resourceGroupName", "{labName}", "{scheduleName}", armdevtestlabs.ScheduleFragment{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + }, 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.Schedule = armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // TaskType: to.Ptr("{myLabVmTaskType}"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Wednesday"), + // to.Ptr("Friday")}, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_Execute.json +func ExampleSchedulesClient_BeginExecute() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSchedulesClient().BeginExecute(ctx, "resourceGroupName", "{labName}", "{scheduleName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_ListApplicable.json +func ExampleSchedulesClient_NewListApplicablePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSchedulesClient().NewListApplicablePager("resourceGroupName", "{labName}", "{scheduleName}", 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.ScheduleList = armdevtestlabs.ScheduleList{ + // Value: []*armdevtestlabs.Schedule{ + // { + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // TaskType: to.Ptr("{myLabVmTaskType}"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Wednesday"), + // to.Ptr("Friday")}, + // }, + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_secrets_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/secrets_client.go similarity index 85% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_secrets_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/secrets_client.go index f7d3508e68e9..67586e3c1fc6 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_secrets_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/secrets_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 armdevtestlabs @@ -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" @@ -26,66 +25,59 @@ import ( // SecretsClient contains the methods for the Secrets group. // Don't use this type directly, use NewSecretsClient() instead. type SecretsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSecretsClient creates a new instance of SecretsClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSecretsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SecretsClient, 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+".SecretsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SecretsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create or replace an existing secret. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the secret. -// secret - A secret. -// options - SecretsClientBeginCreateOrUpdateOptions contains the optional parameters for the SecretsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the secret. +// - secret - A secret. +// - options - SecretsClientBeginCreateOrUpdateOptions contains the optional parameters for the SecretsClient.BeginCreateOrUpdate +// method. func (client *SecretsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, userName string, name string, secret Secret, options *SecretsClientBeginCreateOrUpdateOptions) (*runtime.Poller[SecretsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, labName, userName, name, secret, options) if err != nil { return nil, err } - return runtime.NewPoller[SecretsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[SecretsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[SecretsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SecretsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or replace an existing secret. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *SecretsClient) createOrUpdate(ctx context.Context, resourceGroupName string, labName string, userName string, name string, secret Secret, options *SecretsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, userName, name, secret, 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 +110,7 @@ func (client *SecretsClient) createOrUpdateCreateRequest(ctx context.Context, re 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 } @@ -131,18 +123,19 @@ func (client *SecretsClient) createOrUpdateCreateRequest(ctx context.Context, re // Delete - Delete secret. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the secret. -// options - SecretsClientDeleteOptions contains the optional parameters for the SecretsClient.Delete method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the secret. +// - options - SecretsClientDeleteOptions contains the optional parameters for the SecretsClient.Delete method. func (client *SecretsClient) Delete(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *SecretsClientDeleteOptions) (SecretsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, userName, name, options) if err != nil { return SecretsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SecretsClientDeleteResponse{}, err } @@ -175,7 +168,7 @@ func (client *SecretsClient) deleteCreateRequest(ctx context.Context, resourceGr 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 } @@ -188,18 +181,19 @@ func (client *SecretsClient) deleteCreateRequest(ctx context.Context, resourceGr // Get - Get secret. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the secret. -// options - SecretsClientGetOptions contains the optional parameters for the SecretsClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the secret. +// - options - SecretsClientGetOptions contains the optional parameters for the SecretsClient.Get method. func (client *SecretsClient) Get(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *SecretsClientGetOptions) (SecretsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, userName, name, options) if err != nil { return SecretsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SecretsClientGetResponse{}, err } @@ -232,7 +226,7 @@ func (client *SecretsClient) getCreateRequest(ctx context.Context, resourceGroup 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 } @@ -256,12 +250,12 @@ func (client *SecretsClient) getHandleResponse(resp *http.Response) (SecretsClie } // NewListPager - List secrets in a given user profile. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// options - SecretsClientListOptions contains the optional parameters for the SecretsClient.List method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - options - SecretsClientListOptions contains the optional parameters for the SecretsClient.NewListPager method. func (client *SecretsClient) NewListPager(resourceGroupName string, labName string, userName string, options *SecretsClientListOptions) *runtime.Pager[SecretsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SecretsClientListResponse]{ More: func(page SecretsClientListResponse) bool { @@ -278,7 +272,7 @@ func (client *SecretsClient) NewListPager(resourceGroupName string, labName stri if err != nil { return SecretsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SecretsClientListResponse{}, err } @@ -309,7 +303,7 @@ func (client *SecretsClient) listCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter userName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{userName}", url.PathEscape(userName)) - 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 } @@ -343,19 +337,20 @@ func (client *SecretsClient) listHandleResponse(resp *http.Response) (SecretsCli // Update - Allows modifying tags of secrets. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the secret. -// secret - A secret. -// options - SecretsClientUpdateOptions contains the optional parameters for the SecretsClient.Update method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the secret. +// - secret - A secret. +// - options - SecretsClientUpdateOptions contains the optional parameters for the SecretsClient.Update method. func (client *SecretsClient) Update(ctx context.Context, resourceGroupName string, labName string, userName string, name string, secret SecretFragment, options *SecretsClientUpdateOptions) (SecretsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, userName, name, secret, options) if err != nil { return SecretsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SecretsClientUpdateResponse{}, err } @@ -388,7 +383,7 @@ func (client *SecretsClient) updateCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/secrets_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/secrets_client_example_test.go new file mode 100644 index 000000000000..736b59555d37 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/secrets_client_example_test.go @@ -0,0 +1,180 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_List.json +func ExampleSecretsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSecretsClient().NewListPager("resourceGroupName", "{labName}", "{userName}", &armdevtestlabs.SecretsClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.SecretList = armdevtestlabs.SecretList{ + // Value: []*armdevtestlabs.Secret{ + // { + // Name: to.Ptr("secret1"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/secrets"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{userName}/secrets/secret1"), + // Properties: &armdevtestlabs.SecretProperties{ + // UniqueIdentifier: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // { + // Name: to.Ptr("secret2"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/secrets"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{userName}/secrets/secret2"), + // Properties: &armdevtestlabs.SecretProperties{ + // UniqueIdentifier: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_Get.json +func ExampleSecretsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSecretsClient().Get(ctx, "resourceGroupName", "{labName}", "{userName}", "{secretName}", &armdevtestlabs.SecretsClientGetOptions{Expand: 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.Secret = armdevtestlabs.Secret{ + // Name: to.Ptr("{secretName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/secrets"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{userName}/secrets/{secretName}"), + // Properties: &armdevtestlabs.SecretProperties{ + // UniqueIdentifier: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_CreateOrUpdate.json +func ExampleSecretsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSecretsClient().BeginCreateOrUpdate(ctx, "resourceGroupName", "{labName}", "{userName}", "{secretName}", armdevtestlabs.Secret{ + Properties: &armdevtestlabs.SecretProperties{ + Value: to.Ptr("{secret}"), + }, + }, 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.Secret = armdevtestlabs.Secret{ + // Name: to.Ptr("{secretName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/secrets"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{userName}/secrets/{secretName}"), + // Properties: &armdevtestlabs.SecretProperties{ + // UniqueIdentifier: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_Delete.json +func ExampleSecretsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewSecretsClient().Delete(ctx, "resourceGroupName", "{labName}", "{userName}", "{secretName}", 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_Update.json +func ExampleSecretsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSecretsClient().Update(ctx, "resourceGroupName", "{labName}", "{userName}", "{secretName}", armdevtestlabs.SecretFragment{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + }, 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.Secret = armdevtestlabs.Secret{ + // Name: to.Ptr("{secretName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/secrets"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{userName}/secrets/{secretName}"), + // Properties: &armdevtestlabs.SecretProperties{ + // UniqueIdentifier: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_servicefabrics_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/servicefabrics_client.go similarity index 86% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_servicefabrics_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/servicefabrics_client.go index fadc574de54f..5ecae77f2884 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_servicefabrics_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/servicefabrics_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 armdevtestlabs @@ -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" @@ -26,66 +25,59 @@ import ( // ServiceFabricsClient contains the methods for the ServiceFabrics group. // Don't use this type directly, use NewServiceFabricsClient() instead. type ServiceFabricsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServiceFabricsClient creates a new instance of ServiceFabricsClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServiceFabricsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServiceFabricsClient, 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+".ServiceFabricsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServiceFabricsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create or replace an existing service fabric. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the service fabric. -// serviceFabric - A Service Fabric. -// options - ServiceFabricsClientBeginCreateOrUpdateOptions contains the optional parameters for the ServiceFabricsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the service fabric. +// - serviceFabric - A Service Fabric. +// - options - ServiceFabricsClientBeginCreateOrUpdateOptions contains the optional parameters for the ServiceFabricsClient.BeginCreateOrUpdate +// method. func (client *ServiceFabricsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, userName string, name string, serviceFabric ServiceFabric, options *ServiceFabricsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ServiceFabricsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, labName, userName, name, serviceFabric, options) if err != nil { return nil, err } - return runtime.NewPoller[ServiceFabricsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[ServiceFabricsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServiceFabricsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServiceFabricsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or replace an existing service fabric. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *ServiceFabricsClient) createOrUpdate(ctx context.Context, resourceGroupName string, labName string, userName string, name string, serviceFabric ServiceFabric, options *ServiceFabricsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, userName, name, serviceFabric, 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 +110,7 @@ func (client *ServiceFabricsClient) createOrUpdateCreateRequest(ctx context.Cont 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 } @@ -131,34 +123,36 @@ func (client *ServiceFabricsClient) createOrUpdateCreateRequest(ctx context.Cont // BeginDelete - Delete service fabric. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the service fabric. -// options - ServiceFabricsClientBeginDeleteOptions contains the optional parameters for the ServiceFabricsClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the service fabric. +// - options - ServiceFabricsClientBeginDeleteOptions contains the optional parameters for the ServiceFabricsClient.BeginDelete +// method. func (client *ServiceFabricsClient) BeginDelete(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *ServiceFabricsClientBeginDeleteOptions) (*runtime.Poller[ServiceFabricsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, labName, userName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[ServiceFabricsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[ServiceFabricsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServiceFabricsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServiceFabricsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete service fabric. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *ServiceFabricsClient) deleteOperation(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *ServiceFabricsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, userName, name, 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 } @@ -191,7 +185,7 @@ func (client *ServiceFabricsClient) deleteCreateRequest(ctx context.Context, res 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 } @@ -204,18 +198,19 @@ func (client *ServiceFabricsClient) deleteCreateRequest(ctx context.Context, res // Get - Get service fabric. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the service fabric. -// options - ServiceFabricsClientGetOptions contains the optional parameters for the ServiceFabricsClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the service fabric. +// - options - ServiceFabricsClientGetOptions contains the optional parameters for the ServiceFabricsClient.Get method. func (client *ServiceFabricsClient) Get(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *ServiceFabricsClientGetOptions) (ServiceFabricsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, userName, name, options) if err != nil { return ServiceFabricsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceFabricsClientGetResponse{}, err } @@ -248,7 +243,7 @@ func (client *ServiceFabricsClient) getCreateRequest(ctx context.Context, resour 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 } @@ -272,12 +267,12 @@ func (client *ServiceFabricsClient) getHandleResponse(resp *http.Response) (Serv } // NewListPager - List service fabrics in a given user profile. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// options - ServiceFabricsClientListOptions contains the optional parameters for the ServiceFabricsClient.List method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - options - ServiceFabricsClientListOptions contains the optional parameters for the ServiceFabricsClient.NewListPager method. func (client *ServiceFabricsClient) NewListPager(resourceGroupName string, labName string, userName string, options *ServiceFabricsClientListOptions) *runtime.Pager[ServiceFabricsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ServiceFabricsClientListResponse]{ More: func(page ServiceFabricsClientListResponse) bool { @@ -294,7 +289,7 @@ func (client *ServiceFabricsClient) NewListPager(resourceGroupName string, labNa if err != nil { return ServiceFabricsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceFabricsClientListResponse{}, err } @@ -325,7 +320,7 @@ func (client *ServiceFabricsClient) listCreateRequest(ctx context.Context, resou return nil, errors.New("parameter userName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{userName}", url.PathEscape(userName)) - 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 } @@ -359,19 +354,20 @@ func (client *ServiceFabricsClient) listHandleResponse(resp *http.Response) (Ser // ListApplicableSchedules - Lists the applicable start/stop schedules, if any. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the service fabric. -// options - ServiceFabricsClientListApplicableSchedulesOptions contains the optional parameters for the ServiceFabricsClient.ListApplicableSchedules -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the service fabric. +// - options - ServiceFabricsClientListApplicableSchedulesOptions contains the optional parameters for the ServiceFabricsClient.ListApplicableSchedules +// method. func (client *ServiceFabricsClient) ListApplicableSchedules(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *ServiceFabricsClientListApplicableSchedulesOptions) (ServiceFabricsClientListApplicableSchedulesResponse, error) { req, err := client.listApplicableSchedulesCreateRequest(ctx, resourceGroupName, labName, userName, name, options) if err != nil { return ServiceFabricsClientListApplicableSchedulesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceFabricsClientListApplicableSchedulesResponse{}, err } @@ -404,7 +400,7 @@ func (client *ServiceFabricsClient) listApplicableSchedulesCreateRequest(ctx con return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -426,34 +422,36 @@ func (client *ServiceFabricsClient) listApplicableSchedulesHandleResponse(resp * // BeginStart - Start a service fabric. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the service fabric. -// options - ServiceFabricsClientBeginStartOptions contains the optional parameters for the ServiceFabricsClient.BeginStart -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the service fabric. +// - options - ServiceFabricsClientBeginStartOptions contains the optional parameters for the ServiceFabricsClient.BeginStart +// method. func (client *ServiceFabricsClient) BeginStart(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *ServiceFabricsClientBeginStartOptions) (*runtime.Poller[ServiceFabricsClientStartResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.start(ctx, resourceGroupName, labName, userName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[ServiceFabricsClientStartResponse](resp, client.pl, nil) + return runtime.NewPoller[ServiceFabricsClientStartResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServiceFabricsClientStartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServiceFabricsClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Start - Start a service fabric. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *ServiceFabricsClient) start(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *ServiceFabricsClientBeginStartOptions) (*http.Response, error) { req, err := client.startCreateRequest(ctx, resourceGroupName, labName, userName, name, 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 } @@ -486,7 +484,7 @@ func (client *ServiceFabricsClient) startCreateRequest(ctx context.Context, reso return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -499,34 +497,36 @@ func (client *ServiceFabricsClient) startCreateRequest(ctx context.Context, reso // BeginStop - Stop a service fabric This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the service fabric. -// options - ServiceFabricsClientBeginStopOptions contains the optional parameters for the ServiceFabricsClient.BeginStop -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the service fabric. +// - options - ServiceFabricsClientBeginStopOptions contains the optional parameters for the ServiceFabricsClient.BeginStop +// method. func (client *ServiceFabricsClient) BeginStop(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *ServiceFabricsClientBeginStopOptions) (*runtime.Poller[ServiceFabricsClientStopResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.stop(ctx, resourceGroupName, labName, userName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[ServiceFabricsClientStopResponse](resp, client.pl, nil) + return runtime.NewPoller[ServiceFabricsClientStopResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServiceFabricsClientStopResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServiceFabricsClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Stop - Stop a service fabric This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *ServiceFabricsClient) stop(ctx context.Context, resourceGroupName string, labName string, userName string, name string, options *ServiceFabricsClientBeginStopOptions) (*http.Response, error) { req, err := client.stopCreateRequest(ctx, resourceGroupName, labName, userName, name, 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 } @@ -559,7 +559,7 @@ func (client *ServiceFabricsClient) stopCreateRequest(ctx context.Context, resou return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -572,19 +572,20 @@ func (client *ServiceFabricsClient) stopCreateRequest(ctx context.Context, resou // Update - Allows modifying tags of service fabrics. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// name - The name of the service fabric. -// serviceFabric - A Service Fabric. -// options - ServiceFabricsClientUpdateOptions contains the optional parameters for the ServiceFabricsClient.Update method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - name - The name of the service fabric. +// - serviceFabric - A Service Fabric. +// - options - ServiceFabricsClientUpdateOptions contains the optional parameters for the ServiceFabricsClient.Update method. func (client *ServiceFabricsClient) Update(ctx context.Context, resourceGroupName string, labName string, userName string, name string, serviceFabric ServiceFabricFragment, options *ServiceFabricsClientUpdateOptions) (ServiceFabricsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, userName, name, serviceFabric, options) if err != nil { return ServiceFabricsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceFabricsClientUpdateResponse{}, err } @@ -617,7 +618,7 @@ func (client *ServiceFabricsClient) updateCreateRequest(ctx context.Context, res return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/servicefabrics_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/servicefabrics_client_example_test.go new file mode 100644 index 000000000000..1bbc59c956e1 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/servicefabrics_client_example_test.go @@ -0,0 +1,706 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_List.json +func ExampleServiceFabricsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServiceFabricsClient().NewListPager("resourceGroupName", "{labName}", "{userName}", &armdevtestlabs.ServiceFabricsClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.ServiceFabricList = armdevtestlabs.ServiceFabricList{ + // Value: []*armdevtestlabs.ServiceFabric{ + // { + // Name: to.Ptr("{serviceFabricName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/serviceFabrics"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ServiceFabricProperties{ + // ApplicableSchedule: &armdevtestlabs.ApplicableSchedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("{scheduleType}"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ApplicableScheduleProperties{ + // LabVMsShutdown: &armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // TaskType: to.Ptr("{myLabVmTaskType}"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Wednesday"), + // to.Ptr("Friday")}, + // }, + // }, + // }, + // LabVMsStartup: &armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // TaskType: to.Ptr("{myLabVmTaskType}"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Wednesday"), + // to.Ptr("Friday")}, + // }, + // }, + // }, + // }, + // }, + // EnvironmentID: to.Ptr("{environmentId}"), + // ExternalServiceFabricID: to.Ptr("{serviceFabricId}"), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_Get.json +func ExampleServiceFabricsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServiceFabricsClient().Get(ctx, "resourceGroupName", "{labName}", "{userName}", "{serviceFabricName}", &armdevtestlabs.ServiceFabricsClientGetOptions{Expand: 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.ServiceFabric = armdevtestlabs.ServiceFabric{ + // Name: to.Ptr("{serviceFabricName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/serviceFabrics"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ServiceFabricProperties{ + // ApplicableSchedule: &armdevtestlabs.ApplicableSchedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("{scheduleType}"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ApplicableScheduleProperties{ + // LabVMsShutdown: &armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // TaskType: to.Ptr("{myLabVmTaskType}"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Wednesday"), + // to.Ptr("Friday")}, + // }, + // }, + // }, + // LabVMsStartup: &armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // TaskType: to.Ptr("{myLabVmTaskType}"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Wednesday"), + // to.Ptr("Friday")}, + // }, + // }, + // }, + // }, + // }, + // EnvironmentID: to.Ptr("{environmentId}"), + // ExternalServiceFabricID: to.Ptr("{serviceFabricId}"), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_CreateOrUpdate.json +func ExampleServiceFabricsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServiceFabricsClient().BeginCreateOrUpdate(ctx, "resourceGroupName", "{labName}", "{userName}", "{serviceFabricName}", armdevtestlabs.ServiceFabric{ + Location: to.Ptr("{location}"), + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + Properties: &armdevtestlabs.ServiceFabricProperties{ + EnvironmentID: to.Ptr("{environmentId}"), + ExternalServiceFabricID: to.Ptr("{serviceFabricId}"), + }, + }, 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.ServiceFabric = armdevtestlabs.ServiceFabric{ + // Name: to.Ptr("{serviceFabricName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/serviceFabrics"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ServiceFabricProperties{ + // ApplicableSchedule: &armdevtestlabs.ApplicableSchedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("{scheduleType}"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ApplicableScheduleProperties{ + // LabVMsShutdown: &armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // TaskType: to.Ptr("{myLabVmTaskType}"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Wednesday"), + // to.Ptr("Friday")}, + // }, + // }, + // }, + // LabVMsStartup: &armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // TaskType: to.Ptr("{myLabVmTaskType}"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Wednesday"), + // to.Ptr("Friday")}, + // }, + // }, + // }, + // }, + // }, + // EnvironmentID: to.Ptr("{environmentId}"), + // ExternalServiceFabricID: to.Ptr("{serviceFabricId}"), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_Delete.json +func ExampleServiceFabricsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServiceFabricsClient().BeginDelete(ctx, "resourceGroupName", "{labName}", "{userName}", "{serviceFabricName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_Update.json +func ExampleServiceFabricsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServiceFabricsClient().Update(ctx, "resourceGroupName", "{labName}", "{userName}", "{serviceFabricName}", armdevtestlabs.ServiceFabricFragment{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + }, 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.ServiceFabric = armdevtestlabs.ServiceFabric{ + // Name: to.Ptr("{serviceFabricName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users/serviceFabrics"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ServiceFabricProperties{ + // ApplicableSchedule: &armdevtestlabs.ApplicableSchedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("{scheduleType}"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ApplicableScheduleProperties{ + // LabVMsShutdown: &armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // TaskType: to.Ptr("{myLabVmTaskType}"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Wednesday"), + // to.Ptr("Friday")}, + // }, + // }, + // }, + // LabVMsStartup: &armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // TaskType: to.Ptr("{myLabVmTaskType}"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Wednesday"), + // to.Ptr("Friday")}, + // }, + // }, + // }, + // }, + // }, + // EnvironmentID: to.Ptr("{environmentId}"), + // ExternalServiceFabricID: to.Ptr("{serviceFabricId}"), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_ListApplicableSchedules.json +func ExampleServiceFabricsClient_ListApplicableSchedules() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServiceFabricsClient().ListApplicableSchedules(ctx, "resourceGroupName", "{labName}", "{userName}", "{serviceFabricName}", 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.ApplicableSchedule = armdevtestlabs.ApplicableSchedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("{scheduleType}"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ApplicableScheduleProperties{ + // LabVMsShutdown: &armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // TaskType: to.Ptr("{myLabVmTaskType}"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Wednesday"), + // to.Ptr("Friday")}, + // }, + // }, + // }, + // LabVMsStartup: &armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), + // TaskType: to.Ptr("{myLabVmTaskType}"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), + // Weekdays: []*string{ + // to.Ptr("Monday"), + // to.Ptr("Wednesday"), + // to.Ptr("Friday")}, + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_Start.json +func ExampleServiceFabricsClient_BeginStart() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServiceFabricsClient().BeginStart(ctx, "resourceGroupName", "{labName}", "{userName}", "{serviceFabricName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_Stop.json +func ExampleServiceFabricsClient_BeginStop() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServiceFabricsClient().BeginStop(ctx, "resourceGroupName", "{labName}", "{userName}", "{serviceFabricName}", 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/devtestlabs/armdevtestlabs/zz_generated_servicefabricschedules_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/servicefabricschedules_client.go similarity index 86% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_servicefabricschedules_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/servicefabricschedules_client.go index ea5a66f58d42..5f75dde30c5a 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_servicefabricschedules_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/servicefabricschedules_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 armdevtestlabs @@ -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" @@ -26,52 +25,44 @@ import ( // ServiceFabricSchedulesClient contains the methods for the ServiceFabricSchedules group. // Don't use this type directly, use NewServiceFabricSchedulesClient() instead. type ServiceFabricSchedulesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServiceFabricSchedulesClient creates a new instance of ServiceFabricSchedulesClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServiceFabricSchedulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServiceFabricSchedulesClient, 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+".ServiceFabricSchedulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServiceFabricSchedulesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or replace an existing schedule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// serviceFabricName - The name of the service fabric. -// name - The name of the schedule. -// schedule - A schedule. -// options - ServiceFabricSchedulesClientCreateOrUpdateOptions contains the optional parameters for the ServiceFabricSchedulesClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - serviceFabricName - The name of the service fabric. +// - name - The name of the schedule. +// - schedule - A schedule. +// - options - ServiceFabricSchedulesClientCreateOrUpdateOptions contains the optional parameters for the ServiceFabricSchedulesClient.CreateOrUpdate +// method. func (client *ServiceFabricSchedulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, userName string, serviceFabricName string, name string, schedule Schedule, options *ServiceFabricSchedulesClientCreateOrUpdateOptions) (ServiceFabricSchedulesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, userName, serviceFabricName, name, schedule, options) if err != nil { return ServiceFabricSchedulesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceFabricSchedulesClientCreateOrUpdateResponse{}, err } @@ -108,7 +99,7 @@ func (client *ServiceFabricSchedulesClient) createOrUpdateCreateRequest(ctx cont 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 } @@ -130,20 +121,21 @@ func (client *ServiceFabricSchedulesClient) createOrUpdateHandleResponse(resp *h // Delete - Delete schedule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// serviceFabricName - The name of the service fabric. -// name - The name of the schedule. -// options - ServiceFabricSchedulesClientDeleteOptions contains the optional parameters for the ServiceFabricSchedulesClient.Delete -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - serviceFabricName - The name of the service fabric. +// - name - The name of the schedule. +// - options - ServiceFabricSchedulesClientDeleteOptions contains the optional parameters for the ServiceFabricSchedulesClient.Delete +// method. func (client *ServiceFabricSchedulesClient) Delete(ctx context.Context, resourceGroupName string, labName string, userName string, serviceFabricName string, name string, options *ServiceFabricSchedulesClientDeleteOptions) (ServiceFabricSchedulesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, userName, serviceFabricName, name, options) if err != nil { return ServiceFabricSchedulesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceFabricSchedulesClientDeleteResponse{}, err } @@ -180,7 +172,7 @@ func (client *ServiceFabricSchedulesClient) deleteCreateRequest(ctx context.Cont 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 } @@ -193,35 +185,37 @@ func (client *ServiceFabricSchedulesClient) deleteCreateRequest(ctx context.Cont // BeginExecute - Execute a schedule. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// serviceFabricName - The name of the service fabric. -// name - The name of the schedule. -// options - ServiceFabricSchedulesClientBeginExecuteOptions contains the optional parameters for the ServiceFabricSchedulesClient.BeginExecute -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - serviceFabricName - The name of the service fabric. +// - name - The name of the schedule. +// - options - ServiceFabricSchedulesClientBeginExecuteOptions contains the optional parameters for the ServiceFabricSchedulesClient.BeginExecute +// method. func (client *ServiceFabricSchedulesClient) BeginExecute(ctx context.Context, resourceGroupName string, labName string, userName string, serviceFabricName string, name string, options *ServiceFabricSchedulesClientBeginExecuteOptions) (*runtime.Poller[ServiceFabricSchedulesClientExecuteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.execute(ctx, resourceGroupName, labName, userName, serviceFabricName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[ServiceFabricSchedulesClientExecuteResponse](resp, client.pl, nil) + return runtime.NewPoller[ServiceFabricSchedulesClientExecuteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ServiceFabricSchedulesClientExecuteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServiceFabricSchedulesClientExecuteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Execute - Execute a schedule. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *ServiceFabricSchedulesClient) execute(ctx context.Context, resourceGroupName string, labName string, userName string, serviceFabricName string, name string, options *ServiceFabricSchedulesClientBeginExecuteOptions) (*http.Response, error) { req, err := client.executeCreateRequest(ctx, resourceGroupName, labName, userName, serviceFabricName, name, 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 } @@ -258,7 +252,7 @@ func (client *ServiceFabricSchedulesClient) executeCreateRequest(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.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 } @@ -271,20 +265,21 @@ func (client *ServiceFabricSchedulesClient) executeCreateRequest(ctx context.Con // Get - Get schedule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// serviceFabricName - The name of the service fabric. -// name - The name of the schedule. -// options - ServiceFabricSchedulesClientGetOptions contains the optional parameters for the ServiceFabricSchedulesClient.Get -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - serviceFabricName - The name of the service fabric. +// - name - The name of the schedule. +// - options - ServiceFabricSchedulesClientGetOptions contains the optional parameters for the ServiceFabricSchedulesClient.Get +// method. func (client *ServiceFabricSchedulesClient) Get(ctx context.Context, resourceGroupName string, labName string, userName string, serviceFabricName string, name string, options *ServiceFabricSchedulesClientGetOptions) (ServiceFabricSchedulesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, userName, serviceFabricName, name, options) if err != nil { return ServiceFabricSchedulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceFabricSchedulesClientGetResponse{}, err } @@ -321,7 +316,7 @@ func (client *ServiceFabricSchedulesClient) 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 } @@ -345,14 +340,14 @@ func (client *ServiceFabricSchedulesClient) getHandleResponse(resp *http.Respons } // NewListPager - List schedules in a given service fabric. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// serviceFabricName - The name of the service fabric. -// options - ServiceFabricSchedulesClientListOptions contains the optional parameters for the ServiceFabricSchedulesClient.List -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - serviceFabricName - The name of the service fabric. +// - options - ServiceFabricSchedulesClientListOptions contains the optional parameters for the ServiceFabricSchedulesClient.NewListPager +// method. func (client *ServiceFabricSchedulesClient) NewListPager(resourceGroupName string, labName string, userName string, serviceFabricName string, options *ServiceFabricSchedulesClientListOptions) *runtime.Pager[ServiceFabricSchedulesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ServiceFabricSchedulesClientListResponse]{ More: func(page ServiceFabricSchedulesClientListResponse) bool { @@ -369,7 +364,7 @@ func (client *ServiceFabricSchedulesClient) NewListPager(resourceGroupName strin if err != nil { return ServiceFabricSchedulesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceFabricSchedulesClientListResponse{}, err } @@ -404,7 +399,7 @@ func (client *ServiceFabricSchedulesClient) listCreateRequest(ctx context.Contex return nil, errors.New("parameter serviceFabricName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serviceFabricName}", url.PathEscape(serviceFabricName)) - 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 } @@ -438,21 +433,22 @@ func (client *ServiceFabricSchedulesClient) listHandleResponse(resp *http.Respon // Update - Allows modifying tags of schedules. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// userName - The name of the user profile. -// serviceFabricName - The name of the service fabric. -// name - The name of the schedule. -// schedule - A schedule. -// options - ServiceFabricSchedulesClientUpdateOptions contains the optional parameters for the ServiceFabricSchedulesClient.Update -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - userName - The name of the user profile. +// - serviceFabricName - The name of the service fabric. +// - name - The name of the schedule. +// - schedule - A schedule. +// - options - ServiceFabricSchedulesClientUpdateOptions contains the optional parameters for the ServiceFabricSchedulesClient.Update +// method. func (client *ServiceFabricSchedulesClient) Update(ctx context.Context, resourceGroupName string, labName string, userName string, serviceFabricName string, name string, schedule ScheduleFragment, options *ServiceFabricSchedulesClientUpdateOptions) (ServiceFabricSchedulesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, userName, serviceFabricName, name, schedule, options) if err != nil { return ServiceFabricSchedulesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceFabricSchedulesClientUpdateResponse{}, err } @@ -489,7 +485,7 @@ func (client *ServiceFabricSchedulesClient) updateCreateRequest(ctx context.Cont return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/servicefabricschedules_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/servicefabricschedules_client_example_test.go new file mode 100644 index 000000000000..79cc7c9d9a91 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/servicefabricschedules_client_example_test.go @@ -0,0 +1,332 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_List.json +func ExampleServiceFabricSchedulesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServiceFabricSchedulesClient().NewListPager("resourceGroupName", "{labName}", "@me", "{serviceFrabicName}", &armdevtestlabs.ServiceFabricSchedulesClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.ScheduleList = armdevtestlabs.ScheduleList{ + // Value: []*armdevtestlabs.Schedule{ + // { + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("microsoft.devtestlab/labs/users/servicefabrics/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/users/{uniqueIdentifier}/servicefabrics/{serviceFrabicName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-15T00:00:00.0000000-00:00"); return t}()), + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/users/{uniqueIdentifier}/servicefabrics/{serviceFrabicName}"), + // TaskType: to.Ptr("Unknown"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("1900"), + // Weekdays: []*string{ + // to.Ptr("Sunday"), + // to.Ptr("Monday"), + // to.Ptr("Tuesday"), + // to.Ptr("Wednesday"), + // to.Ptr("Thursday"), + // to.Ptr("Friday"), + // to.Ptr("Saturday")}, + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_Get.json +func ExampleServiceFabricSchedulesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServiceFabricSchedulesClient().Get(ctx, "resourceGroupName", "{labName}", "@me", "{serviceFrabicName}", "{scheduleName}", &armdevtestlabs.ServiceFabricSchedulesClientGetOptions{Expand: 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.Schedule = armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("microsoft.devtestlab/labs/users/servicefabrics/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/users/{uniqueIdentifier}/servicefabrics/{serviceFrabicName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-15T00:00:00.0000000-00:00"); return t}()), + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/users/{uniqueIdentifier}/servicefabrics/{serviceFrabicName}"), + // TaskType: to.Ptr("Unknown"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("1900"), + // Weekdays: []*string{ + // to.Ptr("Sunday"), + // to.Ptr("Monday"), + // to.Ptr("Tuesday"), + // to.Ptr("Wednesday"), + // to.Ptr("Thursday"), + // to.Ptr("Friday"), + // to.Ptr("Saturday")}, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_CreateOrUpdate.json +func ExampleServiceFabricSchedulesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServiceFabricSchedulesClient().CreateOrUpdate(ctx, "resourceGroupName", "{labName}", "@me", "{serviceFrabicName}", "{scheduleName}", armdevtestlabs.Schedule{ + Location: to.Ptr("{location}"), + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + Properties: &armdevtestlabs.ScheduleProperties{ + DailyRecurrence: &armdevtestlabs.DayDetails{ + Time: to.Ptr("19:00"), + }, + HourlyRecurrence: &armdevtestlabs.HourDetails{ + Minute: to.Ptr[int32](0), + }, + NotificationSettings: &armdevtestlabs.NotificationSettings{ + EmailRecipient: to.Ptr("{email}"), + NotificationLocale: to.Ptr("EN"), + Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + TimeInMinutes: to.Ptr[int32](15), + WebhookURL: to.Ptr("{webhoolUrl}"), + }, + Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), + TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/users/{uniqueIdentifier}/servicefabrics/{serviceFrabicName}"), + TaskType: to.Ptr("{Unknown|LabVmsShutdownTask|LabVmsStartupTask|LabVmReclamationTask|ComputeVmShutdownTask}"), + TimeZoneID: to.Ptr("Pacific Standard Time"), + WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + Time: to.Ptr("19:00"), + Weekdays: []*string{ + to.Ptr("Monday"), + to.Ptr("Tuesday"), + to.Ptr("Wednesday"), + to.Ptr("Thursday"), + to.Ptr("Friday"), + to.Ptr("Saturday"), + to.Ptr("Sunday")}, + }, + }, + }, 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.Schedule = armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("microsoft.devtestlab/labs/users/servicefabrics/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/users/{uniqueIdentifier}/servicefabrics/{serviceFrabicName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-15T00:00:00.0000000-00:00"); return t}()), + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/users/{uniqueIdentifier}/servicefabrics/{serviceFrabicName}"), + // TaskType: to.Ptr("Unknown"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("1900"), + // Weekdays: []*string{ + // to.Ptr("Sunday"), + // to.Ptr("Monday"), + // to.Ptr("Tuesday"), + // to.Ptr("Wednesday"), + // to.Ptr("Thursday"), + // to.Ptr("Friday"), + // to.Ptr("Saturday")}, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_Delete.json +func ExampleServiceFabricSchedulesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewServiceFabricSchedulesClient().Delete(ctx, "resourceGroupName", "{labName}", "@me", "{serviceFrabicName}", "{scheduleName}", 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_Update.json +func ExampleServiceFabricSchedulesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServiceFabricSchedulesClient().Update(ctx, "resourceGroupName", "{labName}", "@me", "{serviceFrabicName}", "{scheduleName}", armdevtestlabs.ScheduleFragment{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + }, 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.Schedule = armdevtestlabs.Schedule{ + // Name: to.Ptr("{scheduleName}"), + // Type: to.Ptr("microsoft.devtestlab/labs/users/servicefabrics/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/users/{uniqueIdentifier}/servicefabrics/{serviceFrabicName}/schedules/{scheduleName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-15T00:00:00.0000000-00:00"); return t}()), + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // TimeInMinutes: to.Ptr[int32](15), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatusDisabled), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/users/{uniqueIdentifier}/servicefabrics/{serviceFrabicName}"), + // TaskType: to.Ptr("Unknown"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("1900"), + // Weekdays: []*string{ + // to.Ptr("Sunday"), + // to.Ptr("Monday"), + // to.Ptr("Tuesday"), + // to.Ptr("Wednesday"), + // to.Ptr("Thursday"), + // to.Ptr("Friday"), + // to.Ptr("Saturday")}, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_Execute.json +func ExampleServiceFabricSchedulesClient_BeginExecute() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServiceFabricSchedulesClient().BeginExecute(ctx, "resourceGroupName", "{labName}", "@me", "{serviceFrabicName}", "{scheduleName}", 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/devtestlabs/armdevtestlabs/zz_generated_servicerunners_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/servicerunners_client.go similarity index 83% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_servicerunners_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/servicerunners_client.go index f558b716e79e..5f49332f3d34 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_servicerunners_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/servicerunners_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 armdevtestlabs @@ -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 ( // ServiceRunnersClient contains the methods for the ServiceRunners group. // Don't use this type directly, use NewServiceRunnersClient() instead. type ServiceRunnersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServiceRunnersClient creates a new instance of ServiceRunnersClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServiceRunnersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServiceRunnersClient, 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+".ServiceRunnersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServiceRunnersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or replace an existing service runner. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the service runner. -// serviceRunner - A container for a managed identity to execute DevTest lab services. -// options - ServiceRunnersClientCreateOrUpdateOptions contains the optional parameters for the ServiceRunnersClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the service runner. +// - serviceRunner - A container for a managed identity to execute DevTest lab services. +// - options - ServiceRunnersClientCreateOrUpdateOptions contains the optional parameters for the ServiceRunnersClient.CreateOrUpdate +// method. func (client *ServiceRunnersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, serviceRunner ServiceRunner, options *ServiceRunnersClientCreateOrUpdateOptions) (ServiceRunnersClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, name, serviceRunner, options) if err != nil { return ServiceRunnersClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceRunnersClientCreateOrUpdateResponse{}, err } @@ -97,7 +88,7 @@ func (client *ServiceRunnersClient) createOrUpdateCreateRequest(ctx context.Cont 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 +110,18 @@ func (client *ServiceRunnersClient) createOrUpdateHandleResponse(resp *http.Resp // Delete - Delete service runner. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the service runner. -// options - ServiceRunnersClientDeleteOptions contains the optional parameters for the ServiceRunnersClient.Delete method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the service runner. +// - options - ServiceRunnersClientDeleteOptions contains the optional parameters for the ServiceRunnersClient.Delete method. func (client *ServiceRunnersClient) Delete(ctx context.Context, resourceGroupName string, labName string, name string, options *ServiceRunnersClientDeleteOptions) (ServiceRunnersClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return ServiceRunnersClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceRunnersClientDeleteResponse{}, err } @@ -158,7 +150,7 @@ func (client *ServiceRunnersClient) deleteCreateRequest(ctx context.Context, res 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 +163,18 @@ func (client *ServiceRunnersClient) deleteCreateRequest(ctx context.Context, res // Get - Get service runner. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the service runner. -// options - ServiceRunnersClientGetOptions contains the optional parameters for the ServiceRunnersClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the service runner. +// - options - ServiceRunnersClientGetOptions contains the optional parameters for the ServiceRunnersClient.Get method. func (client *ServiceRunnersClient) Get(ctx context.Context, resourceGroupName string, labName string, name string, options *ServiceRunnersClientGetOptions) (ServiceRunnersClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return ServiceRunnersClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceRunnersClientGetResponse{}, err } @@ -210,7 +203,7 @@ func (client *ServiceRunnersClient) getCreateRequest(ctx context.Context, resour 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 } diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/servicerunners_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/servicerunners_client_example_test.go new file mode 100644 index 000000000000..eca3f1d56679 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/servicerunners_client_example_test.go @@ -0,0 +1,110 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_Get.json +func ExampleServiceRunnersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServiceRunnersClient().Get(ctx, "resourceGroupName", "{devtestlabName}", "{servicerunnerName}", 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.ServiceRunner = armdevtestlabs.ServiceRunner{ + // Name: to.Ptr("{serviceRunnerName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/serviceRunners"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/serviceRunners/{serviceRunnerName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Identity: &armdevtestlabs.IdentityProperties{ + // Type: to.Ptr(armdevtestlabs.ManagedIdentityType("{identityType}")), + // ClientSecretURL: to.Ptr("{identityClientSecretUrl}"), + // PrincipalID: to.Ptr("{identityPrincipalId}"), + // TenantID: to.Ptr("{identityTenantId}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_CreateOrUpdate.json +func ExampleServiceRunnersClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServiceRunnersClient().CreateOrUpdate(ctx, "resourceGroupName", "{devtestlabName}", "{servicerunnerName}", armdevtestlabs.ServiceRunner{ + Location: to.Ptr("{location}"), + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + Identity: &armdevtestlabs.IdentityProperties{ + Type: to.Ptr(armdevtestlabs.ManagedIdentityType("{identityType}")), + ClientSecretURL: to.Ptr("{identityClientSecretUrl}"), + PrincipalID: to.Ptr("{identityPrincipalId}"), + TenantID: to.Ptr("{identityTenantId}"), + }, + }, 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.ServiceRunner = armdevtestlabs.ServiceRunner{ + // Identity: &armdevtestlabs.IdentityProperties{ + // Type: to.Ptr(armdevtestlabs.ManagedIdentityType("{identityType}")), + // ClientSecretURL: to.Ptr("{identityClientSecretUrl}"), + // PrincipalID: to.Ptr("{identityPrincipalId}"), + // TenantID: to.Ptr("{identityTenantId}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_Delete.json +func ExampleServiceRunnersClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewServiceRunnersClient().Delete(ctx, "resourceGroupName", "{devtestlabName}", "{servicerunnerName}", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_time_rfc3339.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/time_rfc3339.go index 6547f953cdc8..9d45f8ef934b 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/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 armdevtestlabs @@ -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/devtestlabs/armdevtestlabs/zz_generated_users_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/users_client.go similarity index 85% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_users_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/users_client.go index 50d22c429a2d..5760b8246c43 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_users_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/users_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 armdevtestlabs @@ -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" @@ -26,65 +25,58 @@ import ( // UsersClient contains the methods for the Users group. // Don't use this type directly, use NewUsersClient() instead. type UsersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewUsersClient creates a new instance of UsersClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewUsersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UsersClient, 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+".UsersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &UsersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create or replace an existing user profile. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the user profile. -// userParam - Profile of a lab user. -// options - UsersClientBeginCreateOrUpdateOptions contains the optional parameters for the UsersClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the user profile. +// - userParam - Profile of a lab user. +// - options - UsersClientBeginCreateOrUpdateOptions contains the optional parameters for the UsersClient.BeginCreateOrUpdate +// method. func (client *UsersClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, userParam User, options *UsersClientBeginCreateOrUpdateOptions) (*runtime.Poller[UsersClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, labName, name, userParam, options) if err != nil { return nil, err } - return runtime.NewPoller[UsersClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[UsersClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[UsersClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[UsersClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or replace an existing user profile. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *UsersClient) createOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, userParam User, options *UsersClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, name, userParam, 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 +105,7 @@ func (client *UsersClient) createOrUpdateCreateRequest(ctx context.Context, reso 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 } @@ -126,32 +118,34 @@ func (client *UsersClient) createOrUpdateCreateRequest(ctx context.Context, reso // BeginDelete - Delete user profile. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the user profile. -// options - UsersClientBeginDeleteOptions contains the optional parameters for the UsersClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the user profile. +// - options - UsersClientBeginDeleteOptions contains the optional parameters for the UsersClient.BeginDelete method. func (client *UsersClient) BeginDelete(ctx context.Context, resourceGroupName string, labName string, name string, options *UsersClientBeginDeleteOptions) (*runtime.Poller[UsersClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, labName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[UsersClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[UsersClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[UsersClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[UsersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete user profile. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *UsersClient) deleteOperation(ctx context.Context, resourceGroupName string, labName string, name string, options *UsersClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, name, 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 *UsersClient) deleteCreateRequest(ctx context.Context, resourceGrou 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 } @@ -193,17 +187,18 @@ func (client *UsersClient) deleteCreateRequest(ctx context.Context, resourceGrou // Get - Get user profile. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the user profile. -// options - UsersClientGetOptions contains the optional parameters for the UsersClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the user profile. +// - options - UsersClientGetOptions contains the optional parameters for the UsersClient.Get method. func (client *UsersClient) Get(ctx context.Context, resourceGroupName string, labName string, name string, options *UsersClientGetOptions) (UsersClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return UsersClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UsersClientGetResponse{}, err } @@ -232,7 +227,7 @@ func (client *UsersClient) getCreateRequest(ctx context.Context, resourceGroupNa 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 } @@ -256,11 +251,11 @@ func (client *UsersClient) getHandleResponse(resp *http.Response) (UsersClientGe } // NewListPager - List user profiles in a given lab. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// options - UsersClientListOptions contains the optional parameters for the UsersClient.List method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - options - UsersClientListOptions contains the optional parameters for the UsersClient.NewListPager method. func (client *UsersClient) NewListPager(resourceGroupName string, labName string, options *UsersClientListOptions) *runtime.Pager[UsersClientListResponse] { return runtime.NewPager(runtime.PagingHandler[UsersClientListResponse]{ More: func(page UsersClientListResponse) bool { @@ -277,7 +272,7 @@ func (client *UsersClient) NewListPager(resourceGroupName string, labName string if err != nil { return UsersClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UsersClientListResponse{}, err } @@ -304,7 +299,7 @@ func (client *UsersClient) listCreateRequest(ctx context.Context, resourceGroupN return nil, errors.New("parameter labName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) - 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 } @@ -338,18 +333,19 @@ func (client *UsersClient) listHandleResponse(resp *http.Response) (UsersClientL // Update - Allows modifying tags of user profiles. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the user profile. -// userParam - Profile of a lab user. -// options - UsersClientUpdateOptions contains the optional parameters for the UsersClient.Update method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the user profile. +// - userParam - Profile of a lab user. +// - options - UsersClientUpdateOptions contains the optional parameters for the UsersClient.Update method. func (client *UsersClient) Update(ctx context.Context, resourceGroupName string, labName string, name string, userParam UserFragment, options *UsersClientUpdateOptions) (UsersClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, name, userParam, options) if err != nil { return UsersClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UsersClientUpdateResponse{}, err } @@ -378,7 +374,7 @@ func (client *UsersClient) updateCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/users_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/users_client_example_test.go new file mode 100644 index 000000000000..ee7339f156d5 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/users_client_example_test.go @@ -0,0 +1,244 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_List.json +func ExampleUsersClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewUsersClient().NewListPager("resourceGroupName", "{devtestlabName}", &armdevtestlabs.UsersClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.UserList = armdevtestlabs.UserList{ + // Value: []*armdevtestlabs.User{ + // { + // Name: to.Ptr("{userName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.UserProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // Identity: &armdevtestlabs.UserIdentity{ + // AppID: to.Ptr("{appId}"), + // ObjectID: to.Ptr("{objectId}"), + // PrincipalID: to.Ptr("{principalId}"), + // PrincipalName: to.Ptr("{principalName}"), + // TenantID: to.Ptr("{tenantId}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // SecretStore: &armdevtestlabs.UserSecretStore{ + // KeyVaultID: to.Ptr("{keyVaultId}"), + // KeyVaultURI: to.Ptr("{keyVaultUri}"), + // }, + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_Get.json +func ExampleUsersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewUsersClient().Get(ctx, "resourceGroupName", "{devtestlabName}", "{userName}", &armdevtestlabs.UsersClientGetOptions{Expand: 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.User = armdevtestlabs.User{ + // Name: to.Ptr("{userName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/users"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.UserProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // Identity: &armdevtestlabs.UserIdentity{ + // AppID: to.Ptr("{appId}"), + // ObjectID: to.Ptr("{objectId}"), + // PrincipalID: to.Ptr("{principalId}"), + // PrincipalName: to.Ptr("{principalName}"), + // TenantID: to.Ptr("{tenantId}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // SecretStore: &armdevtestlabs.UserSecretStore{ + // KeyVaultID: to.Ptr("{keyVaultId}"), + // KeyVaultURI: to.Ptr("{keyVaultUri}"), + // }, + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_CreateOrUpdate.json +func ExampleUsersClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewUsersClient().BeginCreateOrUpdate(ctx, "resourceGroupName", "{devtestlabName}", "{userName}", armdevtestlabs.User{ + Location: to.Ptr("{location}"), + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + Properties: &armdevtestlabs.UserProperties{ + Identity: &armdevtestlabs.UserIdentity{ + AppID: to.Ptr("{appId}"), + ObjectID: to.Ptr("{objectId}"), + PrincipalID: to.Ptr("{principalId}"), + PrincipalName: to.Ptr("{principalName}"), + TenantID: to.Ptr("{tenantId}"), + }, + SecretStore: &armdevtestlabs.UserSecretStore{ + KeyVaultID: to.Ptr("{keyVaultId}"), + KeyVaultURI: to.Ptr("{keyVaultUri}"), + }, + }, + }, 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.User = armdevtestlabs.User{ + // Properties: &armdevtestlabs.UserProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // Identity: &armdevtestlabs.UserIdentity{ + // AppID: to.Ptr("{appId}"), + // ObjectID: to.Ptr("{objectId}"), + // PrincipalID: to.Ptr("{principalId}"), + // PrincipalName: to.Ptr("{principalName}"), + // TenantID: to.Ptr("{tenantId}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // SecretStore: &armdevtestlabs.UserSecretStore{ + // KeyVaultID: to.Ptr("{keyVaultId}"), + // KeyVaultURI: to.Ptr("{keyVaultUri}"), + // }, + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_Delete.json +func ExampleUsersClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewUsersClient().BeginDelete(ctx, "resourceGroupName", "{devtestlabName}", "{userName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_Update.json +func ExampleUsersClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewUsersClient().Update(ctx, "resourceGroupName", "{devtestlabName}", "{userName}", armdevtestlabs.UserFragment{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + }, 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.User = armdevtestlabs.User{ + // Properties: &armdevtestlabs.UserProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T18:40:48.1739018-07:00"); return t}()), + // Identity: &armdevtestlabs.UserIdentity{ + // AppID: to.Ptr("{appId}"), + // ObjectID: to.Ptr("{objectId}"), + // PrincipalID: to.Ptr("{principalId}"), + // PrincipalName: to.Ptr("{principalName}"), + // TenantID: to.Ptr("{tenantId}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // SecretStore: &armdevtestlabs.UserSecretStore{ + // KeyVaultID: to.Ptr("{keyVaultId}"), + // KeyVaultURI: to.Ptr("users/{userName}"), + // }, + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_virtualmachines_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/virtualmachines_client.go similarity index 85% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_virtualmachines_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/virtualmachines_client.go index 3b34316a9389..770443f3ad33 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_virtualmachines_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/virtualmachines_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 armdevtestlabs @@ -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" @@ -26,65 +25,58 @@ import ( // VirtualMachinesClient contains the methods for the VirtualMachines group. // Don't use this type directly, use NewVirtualMachinesClient() instead. type VirtualMachinesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVirtualMachinesClient creates a new instance of VirtualMachinesClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewVirtualMachinesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualMachinesClient, 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+".VirtualMachinesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VirtualMachinesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginAddDataDisk - Attach a new or existing data disk to virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// dataDiskProperties - Request body for adding a new or existing data disk to a virtual machine. -// options - VirtualMachinesClientBeginAddDataDiskOptions contains the optional parameters for the VirtualMachinesClient.BeginAddDataDisk -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - dataDiskProperties - Request body for adding a new or existing data disk to a virtual machine. +// - options - VirtualMachinesClientBeginAddDataDiskOptions contains the optional parameters for the VirtualMachinesClient.BeginAddDataDisk +// method. func (client *VirtualMachinesClient) BeginAddDataDisk(ctx context.Context, resourceGroupName string, labName string, name string, dataDiskProperties DataDiskProperties, options *VirtualMachinesClientBeginAddDataDiskOptions) (*runtime.Poller[VirtualMachinesClientAddDataDiskResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.addDataDisk(ctx, resourceGroupName, labName, name, dataDiskProperties, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientAddDataDiskResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientAddDataDiskResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientAddDataDiskResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientAddDataDiskResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // AddDataDisk - Attach a new or existing data disk to virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualMachinesClient) addDataDisk(ctx context.Context, resourceGroupName string, labName string, name string, dataDiskProperties DataDiskProperties, options *VirtualMachinesClientBeginAddDataDiskOptions) (*http.Response, error) { req, err := client.addDataDiskCreateRequest(ctx, resourceGroupName, labName, name, dataDiskProperties, 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 +105,7 @@ func (client *VirtualMachinesClient) addDataDiskCreateRequest(ctx context.Contex return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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,34 +118,36 @@ func (client *VirtualMachinesClient) addDataDiskCreateRequest(ctx context.Contex // BeginApplyArtifacts - Apply artifacts to virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// applyArtifactsRequest - Request body for applying artifacts to a virtual machine. -// options - VirtualMachinesClientBeginApplyArtifactsOptions contains the optional parameters for the VirtualMachinesClient.BeginApplyArtifacts -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - applyArtifactsRequest - Request body for applying artifacts to a virtual machine. +// - options - VirtualMachinesClientBeginApplyArtifactsOptions contains the optional parameters for the VirtualMachinesClient.BeginApplyArtifacts +// method. func (client *VirtualMachinesClient) BeginApplyArtifacts(ctx context.Context, resourceGroupName string, labName string, name string, applyArtifactsRequest ApplyArtifactsRequest, options *VirtualMachinesClientBeginApplyArtifactsOptions) (*runtime.Poller[VirtualMachinesClientApplyArtifactsResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.applyArtifacts(ctx, resourceGroupName, labName, name, applyArtifactsRequest, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientApplyArtifactsResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientApplyArtifactsResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientApplyArtifactsResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientApplyArtifactsResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // ApplyArtifacts - Apply artifacts to virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualMachinesClient) applyArtifacts(ctx context.Context, resourceGroupName string, labName string, name string, applyArtifactsRequest ApplyArtifactsRequest, options *VirtualMachinesClientBeginApplyArtifactsOptions) (*http.Response, error) { req, err := client.applyArtifactsCreateRequest(ctx, resourceGroupName, labName, name, applyArtifactsRequest, 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 } @@ -182,7 +176,7 @@ func (client *VirtualMachinesClient) applyArtifactsCreateRequest(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.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 } @@ -195,33 +189,35 @@ func (client *VirtualMachinesClient) applyArtifactsCreateRequest(ctx context.Con // BeginClaim - Take ownership of an existing virtual machine This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// options - VirtualMachinesClientBeginClaimOptions contains the optional parameters for the VirtualMachinesClient.BeginClaim -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - options - VirtualMachinesClientBeginClaimOptions contains the optional parameters for the VirtualMachinesClient.BeginClaim +// method. func (client *VirtualMachinesClient) BeginClaim(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginClaimOptions) (*runtime.Poller[VirtualMachinesClientClaimResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.claim(ctx, resourceGroupName, labName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientClaimResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientClaimResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientClaimResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientClaimResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Claim - Take ownership of an existing virtual machine This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualMachinesClient) claim(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginClaimOptions) (*http.Response, error) { req, err := client.claimCreateRequest(ctx, resourceGroupName, labName, name, 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 } @@ -250,7 +246,7 @@ func (client *VirtualMachinesClient) claimCreateRequest(ctx context.Context, res return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -263,34 +259,36 @@ func (client *VirtualMachinesClient) claimCreateRequest(ctx context.Context, res // BeginCreateOrUpdate - Create or replace an existing virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// labVirtualMachine - A virtual machine. -// options - VirtualMachinesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - labVirtualMachine - A virtual machine. +// - options - VirtualMachinesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginCreateOrUpdate +// method. func (client *VirtualMachinesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, labVirtualMachine LabVirtualMachine, options *VirtualMachinesClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualMachinesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, labName, name, labVirtualMachine, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or replace an existing virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualMachinesClient) createOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, labVirtualMachine LabVirtualMachine, options *VirtualMachinesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, name, labVirtualMachine, 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 } @@ -319,7 +317,7 @@ func (client *VirtualMachinesClient) createOrUpdateCreateRequest(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.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 } @@ -332,33 +330,35 @@ func (client *VirtualMachinesClient) createOrUpdateCreateRequest(ctx context.Con // BeginDelete - Delete virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// options - VirtualMachinesClientBeginDeleteOptions contains the optional parameters for the VirtualMachinesClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - options - VirtualMachinesClientBeginDeleteOptions contains the optional parameters for the VirtualMachinesClient.BeginDelete +// method. func (client *VirtualMachinesClient) BeginDelete(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginDeleteOptions) (*runtime.Poller[VirtualMachinesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, labName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualMachinesClient) deleteOperation(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, name, 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 } @@ -387,7 +387,7 @@ func (client *VirtualMachinesClient) deleteCreateRequest(ctx context.Context, re 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 } @@ -400,34 +400,36 @@ func (client *VirtualMachinesClient) deleteCreateRequest(ctx context.Context, re // BeginDetachDataDisk - Detach the specified disk from the virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// detachDataDiskProperties - Request body for detaching data disk from a virtual machine. -// options - VirtualMachinesClientBeginDetachDataDiskOptions contains the optional parameters for the VirtualMachinesClient.BeginDetachDataDisk -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - detachDataDiskProperties - Request body for detaching data disk from a virtual machine. +// - options - VirtualMachinesClientBeginDetachDataDiskOptions contains the optional parameters for the VirtualMachinesClient.BeginDetachDataDisk +// method. func (client *VirtualMachinesClient) BeginDetachDataDisk(ctx context.Context, resourceGroupName string, labName string, name string, detachDataDiskProperties DetachDataDiskProperties, options *VirtualMachinesClientBeginDetachDataDiskOptions) (*runtime.Poller[VirtualMachinesClientDetachDataDiskResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.detachDataDisk(ctx, resourceGroupName, labName, name, detachDataDiskProperties, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientDetachDataDiskResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientDetachDataDiskResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientDetachDataDiskResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientDetachDataDiskResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // DetachDataDisk - Detach the specified disk from the virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualMachinesClient) detachDataDisk(ctx context.Context, resourceGroupName string, labName string, name string, detachDataDiskProperties DetachDataDiskProperties, options *VirtualMachinesClientBeginDetachDataDiskOptions) (*http.Response, error) { req, err := client.detachDataDiskCreateRequest(ctx, resourceGroupName, labName, name, detachDataDiskProperties, 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 } @@ -456,7 +458,7 @@ func (client *VirtualMachinesClient) detachDataDiskCreateRequest(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.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 } @@ -469,17 +471,18 @@ func (client *VirtualMachinesClient) detachDataDiskCreateRequest(ctx context.Con // Get - Get virtual machine. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// options - VirtualMachinesClientGetOptions contains the optional parameters for the VirtualMachinesClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - options - VirtualMachinesClientGetOptions contains the optional parameters for the VirtualMachinesClient.Get method. func (client *VirtualMachinesClient) Get(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientGetOptions) (VirtualMachinesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return VirtualMachinesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachinesClientGetResponse{}, err } @@ -508,7 +511,7 @@ func (client *VirtualMachinesClient) getCreateRequest(ctx context.Context, resou 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 } @@ -533,18 +536,19 @@ func (client *VirtualMachinesClient) getHandleResponse(resp *http.Response) (Vir // GetRdpFileContents - Gets a string that represents the contents of the RDP file for the virtual machine // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// options - VirtualMachinesClientGetRdpFileContentsOptions contains the optional parameters for the VirtualMachinesClient.GetRdpFileContents -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - options - VirtualMachinesClientGetRdpFileContentsOptions contains the optional parameters for the VirtualMachinesClient.GetRdpFileContents +// method. func (client *VirtualMachinesClient) GetRdpFileContents(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientGetRdpFileContentsOptions) (VirtualMachinesClientGetRdpFileContentsResponse, error) { req, err := client.getRdpFileContentsCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return VirtualMachinesClientGetRdpFileContentsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachinesClientGetRdpFileContentsResponse{}, err } @@ -573,7 +577,7 @@ func (client *VirtualMachinesClient) getRdpFileContentsCreateRequest(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.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 } @@ -594,11 +598,12 @@ func (client *VirtualMachinesClient) getRdpFileContentsHandleResponse(resp *http } // NewListPager - List virtual machines in a given lab. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// options - VirtualMachinesClientListOptions contains the optional parameters for the VirtualMachinesClient.List method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - options - VirtualMachinesClientListOptions contains the optional parameters for the VirtualMachinesClient.NewListPager +// method. func (client *VirtualMachinesClient) NewListPager(resourceGroupName string, labName string, options *VirtualMachinesClientListOptions) *runtime.Pager[VirtualMachinesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualMachinesClientListResponse]{ More: func(page VirtualMachinesClientListResponse) bool { @@ -615,7 +620,7 @@ func (client *VirtualMachinesClient) NewListPager(resourceGroupName string, labN if err != nil { return VirtualMachinesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachinesClientListResponse{}, err } @@ -642,7 +647,7 @@ func (client *VirtualMachinesClient) listCreateRequest(ctx context.Context, reso return nil, errors.New("parameter labName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) - 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 } @@ -676,18 +681,19 @@ func (client *VirtualMachinesClient) listHandleResponse(resp *http.Response) (Vi // ListApplicableSchedules - Lists the applicable start/stop schedules, if any. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// options - VirtualMachinesClientListApplicableSchedulesOptions contains the optional parameters for the VirtualMachinesClient.ListApplicableSchedules -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - options - VirtualMachinesClientListApplicableSchedulesOptions contains the optional parameters for the VirtualMachinesClient.ListApplicableSchedules +// method. func (client *VirtualMachinesClient) ListApplicableSchedules(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientListApplicableSchedulesOptions) (VirtualMachinesClientListApplicableSchedulesResponse, error) { req, err := client.listApplicableSchedulesCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return VirtualMachinesClientListApplicableSchedulesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachinesClientListApplicableSchedulesResponse{}, err } @@ -716,7 +722,7 @@ func (client *VirtualMachinesClient) listApplicableSchedulesCreateRequest(ctx co return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -738,33 +744,35 @@ func (client *VirtualMachinesClient) listApplicableSchedulesHandleResponse(resp // BeginRedeploy - Redeploy a virtual machine This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// options - VirtualMachinesClientBeginRedeployOptions contains the optional parameters for the VirtualMachinesClient.BeginRedeploy -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - options - VirtualMachinesClientBeginRedeployOptions contains the optional parameters for the VirtualMachinesClient.BeginRedeploy +// method. func (client *VirtualMachinesClient) BeginRedeploy(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginRedeployOptions) (*runtime.Poller[VirtualMachinesClientRedeployResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.redeploy(ctx, resourceGroupName, labName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientRedeployResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientRedeployResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientRedeployResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientRedeployResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Redeploy - Redeploy a virtual machine This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualMachinesClient) redeploy(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginRedeployOptions) (*http.Response, error) { req, err := client.redeployCreateRequest(ctx, resourceGroupName, labName, name, 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 } @@ -793,7 +801,7 @@ func (client *VirtualMachinesClient) redeployCreateRequest(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.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 } @@ -806,34 +814,36 @@ func (client *VirtualMachinesClient) redeployCreateRequest(ctx context.Context, // BeginResize - Resize Virtual Machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// resizeLabVirtualMachineProperties - Request body for resizing a virtual machine. -// options - VirtualMachinesClientBeginResizeOptions contains the optional parameters for the VirtualMachinesClient.BeginResize -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - resizeLabVirtualMachineProperties - Request body for resizing a virtual machine. +// - options - VirtualMachinesClientBeginResizeOptions contains the optional parameters for the VirtualMachinesClient.BeginResize +// method. func (client *VirtualMachinesClient) BeginResize(ctx context.Context, resourceGroupName string, labName string, name string, resizeLabVirtualMachineProperties ResizeLabVirtualMachineProperties, options *VirtualMachinesClientBeginResizeOptions) (*runtime.Poller[VirtualMachinesClientResizeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.resize(ctx, resourceGroupName, labName, name, resizeLabVirtualMachineProperties, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientResizeResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientResizeResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientResizeResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientResizeResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Resize - Resize Virtual Machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualMachinesClient) resize(ctx context.Context, resourceGroupName string, labName string, name string, resizeLabVirtualMachineProperties ResizeLabVirtualMachineProperties, options *VirtualMachinesClientBeginResizeOptions) (*http.Response, error) { req, err := client.resizeCreateRequest(ctx, resourceGroupName, labName, name, resizeLabVirtualMachineProperties, 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 } @@ -862,7 +872,7 @@ func (client *VirtualMachinesClient) resizeCreateRequest(ctx context.Context, re return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -875,33 +885,35 @@ func (client *VirtualMachinesClient) resizeCreateRequest(ctx context.Context, re // BeginRestart - Restart a virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// options - VirtualMachinesClientBeginRestartOptions contains the optional parameters for the VirtualMachinesClient.BeginRestart -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - options - VirtualMachinesClientBeginRestartOptions contains the optional parameters for the VirtualMachinesClient.BeginRestart +// method. func (client *VirtualMachinesClient) BeginRestart(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginRestartOptions) (*runtime.Poller[VirtualMachinesClientRestartResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.restart(ctx, resourceGroupName, labName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientRestartResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientRestartResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientRestartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientRestartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Restart - Restart a virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualMachinesClient) restart(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginRestartOptions) (*http.Response, error) { req, err := client.restartCreateRequest(ctx, resourceGroupName, labName, name, 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 } @@ -930,7 +942,7 @@ func (client *VirtualMachinesClient) restartCreateRequest(ctx context.Context, r return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -943,33 +955,35 @@ func (client *VirtualMachinesClient) restartCreateRequest(ctx context.Context, r // BeginStart - Start a virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// options - VirtualMachinesClientBeginStartOptions contains the optional parameters for the VirtualMachinesClient.BeginStart -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - options - VirtualMachinesClientBeginStartOptions contains the optional parameters for the VirtualMachinesClient.BeginStart +// method. func (client *VirtualMachinesClient) BeginStart(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginStartOptions) (*runtime.Poller[VirtualMachinesClientStartResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.start(ctx, resourceGroupName, labName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientStartResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientStartResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientStartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Start - Start a virtual machine. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualMachinesClient) start(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginStartOptions) (*http.Response, error) { req, err := client.startCreateRequest(ctx, resourceGroupName, labName, name, 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 } @@ -998,7 +1012,7 @@ func (client *VirtualMachinesClient) startCreateRequest(ctx context.Context, res return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -1011,33 +1025,35 @@ func (client *VirtualMachinesClient) startCreateRequest(ctx context.Context, res // BeginStop - Stop a virtual machine This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// options - VirtualMachinesClientBeginStopOptions contains the optional parameters for the VirtualMachinesClient.BeginStop -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - options - VirtualMachinesClientBeginStopOptions contains the optional parameters for the VirtualMachinesClient.BeginStop +// method. func (client *VirtualMachinesClient) BeginStop(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginStopOptions) (*runtime.Poller[VirtualMachinesClientStopResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.stop(ctx, resourceGroupName, labName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientStopResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientStopResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientStopResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Stop - Stop a virtual machine This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualMachinesClient) stop(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginStopOptions) (*http.Response, error) { req, err := client.stopCreateRequest(ctx, resourceGroupName, labName, name, 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 } @@ -1066,7 +1082,7 @@ func (client *VirtualMachinesClient) stopCreateRequest(ctx context.Context, reso return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -1080,34 +1096,36 @@ func (client *VirtualMachinesClient) stopCreateRequest(ctx context.Context, reso // BeginTransferDisks - Transfers all data disks attached to the virtual machine to be owned by the current user. This operation // can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// options - VirtualMachinesClientBeginTransferDisksOptions contains the optional parameters for the VirtualMachinesClient.BeginTransferDisks -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - options - VirtualMachinesClientBeginTransferDisksOptions contains the optional parameters for the VirtualMachinesClient.BeginTransferDisks +// method. func (client *VirtualMachinesClient) BeginTransferDisks(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginTransferDisksOptions) (*runtime.Poller[VirtualMachinesClientTransferDisksResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.transferDisks(ctx, resourceGroupName, labName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientTransferDisksResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientTransferDisksResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientTransferDisksResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientTransferDisksResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // TransferDisks - Transfers all data disks attached to the virtual machine to be owned by the current user. This operation // can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualMachinesClient) transferDisks(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginTransferDisksOptions) (*http.Response, error) { req, err := client.transferDisksCreateRequest(ctx, resourceGroupName, labName, name, 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 } @@ -1136,7 +1154,7 @@ func (client *VirtualMachinesClient) transferDisksCreateRequest(ctx context.Cont return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -1149,33 +1167,35 @@ func (client *VirtualMachinesClient) transferDisksCreateRequest(ctx context.Cont // BeginUnClaim - Release ownership of an existing virtual machine This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// options - VirtualMachinesClientBeginUnClaimOptions contains the optional parameters for the VirtualMachinesClient.BeginUnClaim -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - options - VirtualMachinesClientBeginUnClaimOptions contains the optional parameters for the VirtualMachinesClient.BeginUnClaim +// method. func (client *VirtualMachinesClient) BeginUnClaim(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginUnClaimOptions) (*runtime.Poller[VirtualMachinesClientUnClaimResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.unClaim(ctx, resourceGroupName, labName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientUnClaimResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientUnClaimResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientUnClaimResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientUnClaimResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // UnClaim - Release ownership of an existing virtual machine This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualMachinesClient) unClaim(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualMachinesClientBeginUnClaimOptions) (*http.Response, error) { req, err := client.unClaimCreateRequest(ctx, resourceGroupName, labName, name, 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 } @@ -1204,7 +1224,7 @@ func (client *VirtualMachinesClient) unClaimCreateRequest(ctx context.Context, r return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -1217,18 +1237,19 @@ func (client *VirtualMachinesClient) unClaimCreateRequest(ctx context.Context, r // Update - Allows modifying tags of virtual machines. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual machine. -// labVirtualMachine - A virtual machine. -// options - VirtualMachinesClientUpdateOptions contains the optional parameters for the VirtualMachinesClient.Update method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual machine. +// - labVirtualMachine - A virtual machine. +// - options - VirtualMachinesClientUpdateOptions contains the optional parameters for the VirtualMachinesClient.Update method. func (client *VirtualMachinesClient) Update(ctx context.Context, resourceGroupName string, labName string, name string, labVirtualMachine LabVirtualMachineFragment, options *VirtualMachinesClientUpdateOptions) (VirtualMachinesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, name, labVirtualMachine, options) if err != nil { return VirtualMachinesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachinesClientUpdateResponse{}, err } @@ -1257,7 +1278,7 @@ func (client *VirtualMachinesClient) updateCreateRequest(ctx context.Context, re return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/virtualmachines_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/virtualmachines_client_example_test.go new file mode 100644 index 000000000000..7350169501da --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/virtualmachines_client_example_test.go @@ -0,0 +1,690 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_List.json +func ExampleVirtualMachinesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewVirtualMachinesClient().NewListPager("resourceGroupName", "{labName}", &armdevtestlabs.VirtualMachinesClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.LabVirtualMachineList = armdevtestlabs.LabVirtualMachineList{ + // Value: []*armdevtestlabs.LabVirtualMachine{ + // { + // Name: to.Ptr("{vmName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.LabVirtualMachineProperties{ + // AllowClaim: to.Ptr(true), + // ArtifactDeploymentStatus: &armdevtestlabs.ArtifactDeploymentStatusProperties{ + // ArtifactsApplied: to.Ptr[int32](0), + // TotalArtifacts: to.Ptr[int32](0), + // }, + // ComputeID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{labName}-{vmName}-{randomSuffix}/providers/Microsoft.Compute/virtualMachines/{vmName}"), + // CreatedByUser: to.Ptr(""), + // CreatedByUserID: to.Ptr(""), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T16:53:02.4830866-07:00"); return t}()), + // DataDiskParameters: []*armdevtestlabs.DataDiskProperties{ + // }, + // DisallowPublicIPAddress: to.Ptr(true), + // GalleryImageReference: &armdevtestlabs.GalleryImageReference{ + // Offer: to.Ptr("UbuntuServer"), + // OSType: to.Ptr("Linux"), + // Publisher: to.Ptr("Canonical"), + // SKU: to.Ptr("16.04-LTS"), + // Version: to.Ptr("Latest"), + // }, + // LabSubnetName: to.Ptr("{virtualNetworkName}Subnet"), + // LabVirtualNetworkID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualnetworks/{virtualNetworkName}"), + // NetworkInterface: &armdevtestlabs.NetworkInterfaceProperties{ + // }, + // OSType: to.Ptr("Linux"), + // OwnerObjectID: to.Ptr(""), + // OwnerUserPrincipalName: to.Ptr(""), + // ProvisioningState: to.Ptr("Succeeded"), + // Size: to.Ptr("Standard_A2_v2"), + // StorageType: to.Ptr("Standard"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // UserName: to.Ptr("{userName}"), + // VirtualMachineCreationSource: to.Ptr(armdevtestlabs.VirtualMachineCreationSourceFromGalleryImage), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Get.json +func ExampleVirtualMachinesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualMachinesClient().Get(ctx, "resourceGroupName", "{labName}", "{vmName}", &armdevtestlabs.VirtualMachinesClientGetOptions{Expand: 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.LabVirtualMachine = armdevtestlabs.LabVirtualMachine{ + // Name: to.Ptr("{vmName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.LabVirtualMachineProperties{ + // AllowClaim: to.Ptr(true), + // ArtifactDeploymentStatus: &armdevtestlabs.ArtifactDeploymentStatusProperties{ + // ArtifactsApplied: to.Ptr[int32](0), + // TotalArtifacts: to.Ptr[int32](0), + // }, + // ComputeID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{labName}-{vmName}-{randomSuffix}/providers/Microsoft.Compute/virtualMachines/{vmName}"), + // CreatedByUser: to.Ptr(""), + // CreatedByUserID: to.Ptr(""), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T16:53:02.4830866-07:00"); return t}()), + // DataDiskParameters: []*armdevtestlabs.DataDiskProperties{ + // }, + // DisallowPublicIPAddress: to.Ptr(true), + // GalleryImageReference: &armdevtestlabs.GalleryImageReference{ + // Offer: to.Ptr("UbuntuServer"), + // OSType: to.Ptr("Linux"), + // Publisher: to.Ptr("Canonical"), + // SKU: to.Ptr("16.04-LTS"), + // Version: to.Ptr("Latest"), + // }, + // LabSubnetName: to.Ptr("{virtualNetworkName}Subnet"), + // LabVirtualNetworkID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualnetworks/{virtualNetworkName}"), + // NetworkInterface: &armdevtestlabs.NetworkInterfaceProperties{ + // }, + // OSType: to.Ptr("Linux"), + // OwnerObjectID: to.Ptr(""), + // OwnerUserPrincipalName: to.Ptr(""), + // ProvisioningState: to.Ptr("Succeeded"), + // Size: to.Ptr("Standard_A2_v2"), + // StorageType: to.Ptr("Standard"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // UserName: to.Ptr("{userName}"), + // VirtualMachineCreationSource: to.Ptr(armdevtestlabs.VirtualMachineCreationSourceFromGalleryImage), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_CreateOrUpdate.json +func ExampleVirtualMachinesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginCreateOrUpdate(ctx, "resourceGroupName", "{labName}", "{vmName}", armdevtestlabs.LabVirtualMachine{ + Location: to.Ptr("{location}"), + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + Properties: &armdevtestlabs.LabVirtualMachineProperties{ + AllowClaim: to.Ptr(true), + DisallowPublicIPAddress: to.Ptr(true), + GalleryImageReference: &armdevtestlabs.GalleryImageReference{ + Offer: to.Ptr("UbuntuServer"), + OSType: to.Ptr("Linux"), + Publisher: to.Ptr("Canonical"), + SKU: to.Ptr("16.04-LTS"), + Version: to.Ptr("Latest"), + }, + LabSubnetName: to.Ptr("{virtualNetworkName}Subnet"), + LabVirtualNetworkID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualnetworks/{virtualNetworkName}"), + Password: to.Ptr("{userPassword}"), + Size: to.Ptr("Standard_A2_v2"), + StorageType: to.Ptr("Standard"), + UserName: to.Ptr("{userName}"), + }, + }, 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.LabVirtualMachine = armdevtestlabs.LabVirtualMachine{ + // Name: to.Ptr("{vmName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.LabVirtualMachineProperties{ + // AllowClaim: to.Ptr(true), + // ArtifactDeploymentStatus: &armdevtestlabs.ArtifactDeploymentStatusProperties{ + // ArtifactsApplied: to.Ptr[int32](0), + // TotalArtifacts: to.Ptr[int32](0), + // }, + // CreatedByUser: to.Ptr(""), + // CreatedByUserID: to.Ptr(""), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T16:53:02.4830866-07:00"); return t}()), + // DataDiskParameters: []*armdevtestlabs.DataDiskProperties{ + // }, + // DisallowPublicIPAddress: to.Ptr(true), + // GalleryImageReference: &armdevtestlabs.GalleryImageReference{ + // Offer: to.Ptr("UbuntuServer"), + // OSType: to.Ptr("Linux"), + // Publisher: to.Ptr("Canonical"), + // SKU: to.Ptr("16.04-LTS"), + // Version: to.Ptr("Latest"), + // }, + // LabSubnetName: to.Ptr("{virtualNetworkName}Subnet"), + // LabVirtualNetworkID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualnetworks/{virtualNetworkName}"), + // NetworkInterface: &armdevtestlabs.NetworkInterfaceProperties{ + // }, + // OwnerObjectID: to.Ptr(""), + // OwnerUserPrincipalName: to.Ptr(""), + // ProvisioningState: to.Ptr("Succeeded"), + // Size: to.Ptr("Standard_A2_v2"), + // StorageType: to.Ptr("Standard"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // UserName: to.Ptr("{userName}"), + // VirtualMachineCreationSource: to.Ptr(armdevtestlabs.VirtualMachineCreationSourceFromGalleryImage), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Delete.json +func ExampleVirtualMachinesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginDelete(ctx, "resourceGroupName", "{labName}", "{vmName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Update.json +func ExampleVirtualMachinesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualMachinesClient().Update(ctx, "resourceGroupName", "{labName}", "{vmName}", armdevtestlabs.LabVirtualMachineFragment{}, 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.LabVirtualMachine = armdevtestlabs.LabVirtualMachine{ + // Name: to.Ptr("{vmName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.LabVirtualMachineProperties{ + // AllowClaim: to.Ptr(true), + // ArtifactDeploymentStatus: &armdevtestlabs.ArtifactDeploymentStatusProperties{ + // ArtifactsApplied: to.Ptr[int32](0), + // TotalArtifacts: to.Ptr[int32](0), + // }, + // ComputeID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{labName}-{vmName}-{randomSuffix}/providers/Microsoft.Compute/virtualMachines/{vmName}"), + // CreatedByUser: to.Ptr(""), + // CreatedByUserID: to.Ptr(""), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T16:53:02.4830866-07:00"); return t}()), + // DataDiskParameters: []*armdevtestlabs.DataDiskProperties{ + // }, + // DisallowPublicIPAddress: to.Ptr(true), + // GalleryImageReference: &armdevtestlabs.GalleryImageReference{ + // Offer: to.Ptr("UbuntuServer"), + // OSType: to.Ptr("Linux"), + // Publisher: to.Ptr("Canonical"), + // SKU: to.Ptr("16.04-LTS"), + // Version: to.Ptr("Latest"), + // }, + // LabSubnetName: to.Ptr("{virtualNetworkName}Subnet"), + // LabVirtualNetworkID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualnetworks/{virtualNetworkName}"), + // NetworkInterface: &armdevtestlabs.NetworkInterfaceProperties{ + // }, + // OSType: to.Ptr("Linux"), + // OwnerObjectID: to.Ptr(""), + // OwnerUserPrincipalName: to.Ptr(""), + // ProvisioningState: to.Ptr("Succeeded"), + // Size: to.Ptr("Standard_A2_v2"), + // StorageType: to.Ptr("Standard"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // UserName: to.Ptr("{userName}"), + // VirtualMachineCreationSource: to.Ptr(armdevtestlabs.VirtualMachineCreationSourceFromGalleryImage), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_AddDataDisk.json +func ExampleVirtualMachinesClient_BeginAddDataDisk() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginAddDataDisk(ctx, "resourceGroupName", "{labName}", "{virtualMachineName}", armdevtestlabs.DataDiskProperties{ + AttachNewDataDiskOptions: &armdevtestlabs.AttachNewDataDiskOptions{ + DiskName: to.Ptr("{diskName}"), + DiskSizeGiB: to.Ptr[int32](127), + DiskType: to.Ptr(armdevtestlabs.StorageType("{diskType}")), + }, + }, 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_ApplyArtifacts.json +func ExampleVirtualMachinesClient_BeginApplyArtifacts() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginApplyArtifacts(ctx, "resourceGroupName", "{labName}", "{vmName}", armdevtestlabs.ApplyArtifactsRequest{ + Artifacts: []*armdevtestlabs.ArtifactInstallProperties{ + { + ArtifactID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/artifactSources/public repo/artifacts/windows-restart"), + }}, + }, 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Claim.json +func ExampleVirtualMachinesClient_BeginClaim() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginClaim(ctx, "resourceGroupName", "{labName}", "{vmName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_DetachDataDisk.json +func ExampleVirtualMachinesClient_BeginDetachDataDisk() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginDetachDataDisk(ctx, "resourceGroupName", "{labName}", "{virtualMachineName}", armdevtestlabs.DetachDataDiskProperties{ + ExistingLabDiskID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{virtualMachineName}"), + }, 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_GetRdpFileContents.json +func ExampleVirtualMachinesClient_GetRdpFileContents() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualMachinesClient().GetRdpFileContents(ctx, "resourceGroupName", "{labName}", "{vmName}", 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.RdpConnection = armdevtestlabs.RdpConnection{ + // Contents: to.Ptr("full address:s:10.0.0.4\r\nprompt for credentials:i:1\r\nusername:s:{vmName}\\{userName}\r\n"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_ListApplicableSchedules.json +func ExampleVirtualMachinesClient_ListApplicableSchedules() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualMachinesClient().ListApplicableSchedules(ctx, "resourceGroupName", "{labName}", "{vmName}", 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.ApplicableSchedule = armdevtestlabs.ApplicableSchedule{ + // Properties: &armdevtestlabs.ApplicableScheduleProperties{ + // LabVMsShutdown: &armdevtestlabs.Schedule{ + // Name: to.Ptr("LabVmsShutdown"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/schedules/myAutoShutdownSchedule"), + // Location: to.Ptr("{location}"), + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-29T21:48:14.1369355+00:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("1900"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TimeInMinutes: to.Ptr[int32](30), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{vmName}"), + // TaskType: to.Ptr("LabVmsShutdownTask"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // UniqueIdentifier: to.Ptr("4acf0408-1c10-49cb-96b7-28ce655c8320"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("1700"), + // Weekdays: []*string{ + // to.Ptr("Friday"), + // to.Ptr("Saturday"), + // to.Ptr("Sunday")}, + // }, + // }, + // }, + // LabVMsStartup: &armdevtestlabs.Schedule{ + // Name: to.Ptr("LabVmAutoStart"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/schedules/myAutoStartSchedule"), + // Location: to.Ptr("{location}"), + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-29T21:46:37.0473976+00:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("0900"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TimeInMinutes: to.Ptr[int32](30), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{vmName}"), + // TaskType: to.Ptr("LabVmsStartupTask"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("1000"), + // Weekdays: []*string{ + // to.Ptr("Friday"), + // to.Ptr("Saturday"), + // to.Ptr("Sunday")}, + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Redeploy.json +func ExampleVirtualMachinesClient_BeginRedeploy() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginRedeploy(ctx, "resourceGroupName", "{labName}", "{vmName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Resize.json +func ExampleVirtualMachinesClient_BeginResize() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginResize(ctx, "resourceGroupName", "{labName}", "{vmName}", armdevtestlabs.ResizeLabVirtualMachineProperties{ + Size: to.Ptr("Standard_A4_v2"), + }, 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Restart.json +func ExampleVirtualMachinesClient_BeginRestart() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginRestart(ctx, "resourceGroupName", "{labName}", "{vmName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Start.json +func ExampleVirtualMachinesClient_BeginStart() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginStart(ctx, "resourceGroupName", "{labName}", "{vmName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Stop.json +func ExampleVirtualMachinesClient_BeginStop() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginStop(ctx, "resourceGroupName", "{labName}", "{vmName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_TransferDisks.json +func ExampleVirtualMachinesClient_BeginTransferDisks() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginTransferDisks(ctx, "resourceGroupName", "{labName}", "{virtualmachineName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_UnClaim.json +func ExampleVirtualMachinesClient_BeginUnClaim() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginUnClaim(ctx, "resourceGroupName", "{labName}", "{vmName}", 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/devtestlabs/armdevtestlabs/zz_generated_virtualmachineschedules_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/virtualmachineschedules_client.go similarity index 86% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_virtualmachineschedules_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/virtualmachineschedules_client.go index 3c0dd744de39..f345eaa4bf08 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_virtualmachineschedules_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/virtualmachineschedules_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 armdevtestlabs @@ -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" @@ -26,51 +25,43 @@ import ( // VirtualMachineSchedulesClient contains the methods for the VirtualMachineSchedules group. // Don't use this type directly, use NewVirtualMachineSchedulesClient() instead. type VirtualMachineSchedulesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVirtualMachineSchedulesClient creates a new instance of VirtualMachineSchedulesClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewVirtualMachineSchedulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualMachineSchedulesClient, 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+".VirtualMachineSchedulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VirtualMachineSchedulesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or replace an existing schedule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// virtualMachineName - The name of the virtual machine. -// name - The name of the schedule. -// schedule - A schedule. -// options - VirtualMachineSchedulesClientCreateOrUpdateOptions contains the optional parameters for the VirtualMachineSchedulesClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - virtualMachineName - The name of the virtual machine. +// - name - The name of the schedule. +// - schedule - A schedule. +// - options - VirtualMachineSchedulesClientCreateOrUpdateOptions contains the optional parameters for the VirtualMachineSchedulesClient.CreateOrUpdate +// method. func (client *VirtualMachineSchedulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, name string, schedule Schedule, options *VirtualMachineSchedulesClientCreateOrUpdateOptions) (VirtualMachineSchedulesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, name, schedule, options) if err != nil { return VirtualMachineSchedulesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineSchedulesClientCreateOrUpdateResponse{}, err } @@ -103,7 +94,7 @@ func (client *VirtualMachineSchedulesClient) createOrUpdateCreateRequest(ctx con 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 } @@ -125,19 +116,20 @@ func (client *VirtualMachineSchedulesClient) createOrUpdateHandleResponse(resp * // Delete - Delete schedule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// virtualMachineName - The name of the virtual machine. -// name - The name of the schedule. -// options - VirtualMachineSchedulesClientDeleteOptions contains the optional parameters for the VirtualMachineSchedulesClient.Delete -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - virtualMachineName - The name of the virtual machine. +// - name - The name of the schedule. +// - options - VirtualMachineSchedulesClientDeleteOptions contains the optional parameters for the VirtualMachineSchedulesClient.Delete +// method. func (client *VirtualMachineSchedulesClient) Delete(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, name string, options *VirtualMachineSchedulesClientDeleteOptions) (VirtualMachineSchedulesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, name, options) if err != nil { return VirtualMachineSchedulesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineSchedulesClientDeleteResponse{}, err } @@ -170,7 +162,7 @@ func (client *VirtualMachineSchedulesClient) deleteCreateRequest(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.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 } @@ -183,34 +175,36 @@ func (client *VirtualMachineSchedulesClient) deleteCreateRequest(ctx context.Con // BeginExecute - Execute a schedule. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// virtualMachineName - The name of the virtual machine. -// name - The name of the schedule. -// options - VirtualMachineSchedulesClientBeginExecuteOptions contains the optional parameters for the VirtualMachineSchedulesClient.BeginExecute -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - virtualMachineName - The name of the virtual machine. +// - name - The name of the schedule. +// - options - VirtualMachineSchedulesClientBeginExecuteOptions contains the optional parameters for the VirtualMachineSchedulesClient.BeginExecute +// method. func (client *VirtualMachineSchedulesClient) BeginExecute(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, name string, options *VirtualMachineSchedulesClientBeginExecuteOptions) (*runtime.Poller[VirtualMachineSchedulesClientExecuteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.execute(ctx, resourceGroupName, labName, virtualMachineName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachineSchedulesClientExecuteResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachineSchedulesClientExecuteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachineSchedulesClientExecuteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachineSchedulesClientExecuteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Execute - Execute a schedule. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualMachineSchedulesClient) execute(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, name string, options *VirtualMachineSchedulesClientBeginExecuteOptions) (*http.Response, error) { req, err := client.executeCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, name, 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 *VirtualMachineSchedulesClient) executeCreateRequest(ctx context.Co return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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 } @@ -256,19 +250,20 @@ func (client *VirtualMachineSchedulesClient) executeCreateRequest(ctx context.Co // Get - Get schedule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// virtualMachineName - The name of the virtual machine. -// name - The name of the schedule. -// options - VirtualMachineSchedulesClientGetOptions contains the optional parameters for the VirtualMachineSchedulesClient.Get -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - virtualMachineName - The name of the virtual machine. +// - name - The name of the schedule. +// - options - VirtualMachineSchedulesClientGetOptions contains the optional parameters for the VirtualMachineSchedulesClient.Get +// method. func (client *VirtualMachineSchedulesClient) Get(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, name string, options *VirtualMachineSchedulesClientGetOptions) (VirtualMachineSchedulesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, name, options) if err != nil { return VirtualMachineSchedulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineSchedulesClientGetResponse{}, err } @@ -301,7 +296,7 @@ func (client *VirtualMachineSchedulesClient) getCreateRequest(ctx context.Contex 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 } @@ -325,13 +320,13 @@ func (client *VirtualMachineSchedulesClient) getHandleResponse(resp *http.Respon } // NewListPager - List schedules in a given virtual machine. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// virtualMachineName - The name of the virtual machine. -// options - VirtualMachineSchedulesClientListOptions contains the optional parameters for the VirtualMachineSchedulesClient.List -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - virtualMachineName - The name of the virtual machine. +// - options - VirtualMachineSchedulesClientListOptions contains the optional parameters for the VirtualMachineSchedulesClient.NewListPager +// method. func (client *VirtualMachineSchedulesClient) NewListPager(resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachineSchedulesClientListOptions) *runtime.Pager[VirtualMachineSchedulesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualMachineSchedulesClientListResponse]{ More: func(page VirtualMachineSchedulesClientListResponse) bool { @@ -348,7 +343,7 @@ func (client *VirtualMachineSchedulesClient) NewListPager(resourceGroupName stri if err != nil { return VirtualMachineSchedulesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineSchedulesClientListResponse{}, err } @@ -379,7 +374,7 @@ func (client *VirtualMachineSchedulesClient) listCreateRequest(ctx context.Conte return nil, errors.New("parameter virtualMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) - 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 } @@ -413,20 +408,21 @@ func (client *VirtualMachineSchedulesClient) listHandleResponse(resp *http.Respo // Update - Allows modifying tags of schedules. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// virtualMachineName - The name of the virtual machine. -// name - The name of the schedule. -// schedule - A schedule. -// options - VirtualMachineSchedulesClientUpdateOptions contains the optional parameters for the VirtualMachineSchedulesClient.Update -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - virtualMachineName - The name of the virtual machine. +// - name - The name of the schedule. +// - schedule - A schedule. +// - options - VirtualMachineSchedulesClientUpdateOptions contains the optional parameters for the VirtualMachineSchedulesClient.Update +// method. func (client *VirtualMachineSchedulesClient) Update(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, name string, schedule ScheduleFragment, options *VirtualMachineSchedulesClientUpdateOptions) (VirtualMachineSchedulesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, name, schedule, options) if err != nil { return VirtualMachineSchedulesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineSchedulesClientUpdateResponse{}, err } @@ -459,7 +455,7 @@ func (client *VirtualMachineSchedulesClient) updateCreateRequest(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.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/devtestlabs/armdevtestlabs/virtualmachineschedules_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/virtualmachineschedules_client_example_test.go new file mode 100644 index 000000000000..2cc901ca29ea --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/virtualmachineschedules_client_example_test.go @@ -0,0 +1,332 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_List.json +func ExampleVirtualMachineSchedulesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewVirtualMachineSchedulesClient().NewListPager("resourceGroupName", "{labName}", "{vmName}", &armdevtestlabs.VirtualMachineSchedulesClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.ScheduleList = armdevtestlabs.ScheduleList{ + // Value: []*armdevtestlabs.Schedule{ + // { + // Name: to.Ptr("LabVmsShutdown"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualMachines/{vmName}/schedules/mySchedule"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-31T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("1900"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TimeInMinutes: to.Ptr[int32](30), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/labName}/virtualMachines/{vmName}"), + // TaskType: to.Ptr("LabVmsShutdownTask"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("1700"), + // Weekdays: []*string{ + // to.Ptr("Friday"), + // to.Ptr("Saturday"), + // to.Ptr("Sunday")}, + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_Get.json +func ExampleVirtualMachineSchedulesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualMachineSchedulesClient().Get(ctx, "resourceGroupName", "{labName}", "{vmName}", "LabVmsShutdown", &armdevtestlabs.VirtualMachineSchedulesClientGetOptions{Expand: 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.Schedule = armdevtestlabs.Schedule{ + // Name: to.Ptr("LabVmsShutdown"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualMachines/{vmName}/schedules/mySchedule"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-31T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("1900"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TimeInMinutes: to.Ptr[int32](30), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualMachines/{vmName}"), + // TaskType: to.Ptr("LabVmsShutdownTask"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("1700"), + // Weekdays: []*string{ + // to.Ptr("Friday"), + // to.Ptr("Saturday"), + // to.Ptr("Sunday")}, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_CreateOrUpdate.json +func ExampleVirtualMachineSchedulesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualMachineSchedulesClient().CreateOrUpdate(ctx, "resourceGroupName", "{labName}", "{vmName}", "LabVmsShutdown", armdevtestlabs.Schedule{ + Location: to.Ptr("{location}"), + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + Properties: &armdevtestlabs.ScheduleProperties{ + DailyRecurrence: &armdevtestlabs.DayDetails{ + Time: to.Ptr("1900"), + }, + HourlyRecurrence: &armdevtestlabs.HourDetails{ + Minute: to.Ptr[int32](30), + }, + NotificationSettings: &armdevtestlabs.NotificationSettings{ + EmailRecipient: to.Ptr("{email}"), + NotificationLocale: to.Ptr("EN"), + Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + TimeInMinutes: to.Ptr[int32](30), + WebhookURL: to.Ptr("{webhookUrl}"), + }, + Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualMachines/{vmName}"), + TaskType: to.Ptr("LabVmsShutdownTask"), + TimeZoneID: to.Ptr("Pacific Standard Time"), + WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + Time: to.Ptr("1700"), + Weekdays: []*string{ + to.Ptr("Friday"), + to.Ptr("Saturday"), + to.Ptr("Sunday")}, + }, + }, + }, 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.Schedule = armdevtestlabs.Schedule{ + // Name: to.Ptr("LabVmsShutdown"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualMachines/{vmName}/schedules/LabVmsShutdown"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-31T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("1900"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TimeInMinutes: to.Ptr[int32](30), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualMachines/{vmName}"), + // TaskType: to.Ptr("LabVmsShutdownTask"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("1700"), + // Weekdays: []*string{ + // to.Ptr("Friday"), + // to.Ptr("Saturday"), + // to.Ptr("Sunday")}, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_Delete.json +func ExampleVirtualMachineSchedulesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewVirtualMachineSchedulesClient().Delete(ctx, "resourceGroupName", "{labName}", "{vmName}", "LabVmsShutdown", 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_Update.json +func ExampleVirtualMachineSchedulesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualMachineSchedulesClient().Update(ctx, "resourceGroupName", "{labName}", "{vmName}", "LabVmsShutdown", armdevtestlabs.ScheduleFragment{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + }, 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.Schedule = armdevtestlabs.Schedule{ + // Name: to.Ptr("LabVmsShutdown"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/virtualMachines/schedules"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualMachines/{vmName}/schedules/mySchedule"), + // Location: to.Ptr("{location}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.ScheduleProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-31T18:40:48.1739018-07:00"); return t}()), + // DailyRecurrence: &armdevtestlabs.DayDetails{ + // Time: to.Ptr("1900"), + // }, + // HourlyRecurrence: &armdevtestlabs.HourDetails{ + // Minute: to.Ptr[int32](30), + // }, + // NotificationSettings: &armdevtestlabs.NotificationSettings{ + // EmailRecipient: to.Ptr("{email}"), + // NotificationLocale: to.Ptr("EN"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TimeInMinutes: to.Ptr[int32](30), + // WebhookURL: to.Ptr("{webhookUrl}"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), + // TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualMachines/{vmName}"), + // TaskType: to.Ptr("LabVmsShutdownTask"), + // TimeZoneID: to.Ptr("Pacific Standard Time"), + // WeeklyRecurrence: &armdevtestlabs.WeekDetails{ + // Time: to.Ptr("1700"), + // Weekdays: []*string{ + // to.Ptr("Friday"), + // to.Ptr("Saturday"), + // to.Ptr("Sunday")}, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_Execute.json +func ExampleVirtualMachineSchedulesClient_BeginExecute() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachineSchedulesClient().BeginExecute(ctx, "resourceGroupName", "{labName}", "{vmName}", "LabVmsShutdown", 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/devtestlabs/armdevtestlabs/zz_generated_virtualnetworks_client.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/virtualnetworks_client.go similarity index 85% rename from sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_virtualnetworks_client.go rename to sdk/resourcemanager/devtestlabs/armdevtestlabs/virtualnetworks_client.go index ec4b9f75337f..1dc6ec094075 100644 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_virtualnetworks_client.go +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/virtualnetworks_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 armdevtestlabs @@ -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" @@ -26,65 +25,58 @@ import ( // VirtualNetworksClient contains the methods for the VirtualNetworks group. // Don't use this type directly, use NewVirtualNetworksClient() instead. type VirtualNetworksClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVirtualNetworksClient creates a new instance of VirtualNetworksClient with the specified values. -// subscriptionID - The subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewVirtualNetworksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualNetworksClient, 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+".VirtualNetworksClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VirtualNetworksClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create or replace an existing virtual network. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual network. -// virtualNetwork - A virtual network. -// options - VirtualNetworksClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualNetworksClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual network. +// - virtualNetwork - A virtual network. +// - options - VirtualNetworksClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualNetworksClient.BeginCreateOrUpdate +// method. func (client *VirtualNetworksClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, virtualNetwork VirtualNetwork, options *VirtualNetworksClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualNetworksClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, labName, name, virtualNetwork, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualNetworksClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualNetworksClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualNetworksClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualNetworksClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or replace an existing virtual network. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualNetworksClient) createOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, virtualNetwork VirtualNetwork, options *VirtualNetworksClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, name, virtualNetwork, 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 +105,7 @@ func (client *VirtualNetworksClient) createOrUpdateCreateRequest(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.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 } @@ -126,33 +118,35 @@ func (client *VirtualNetworksClient) createOrUpdateCreateRequest(ctx context.Con // BeginDelete - Delete virtual network. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual network. -// options - VirtualNetworksClientBeginDeleteOptions contains the optional parameters for the VirtualNetworksClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual network. +// - options - VirtualNetworksClientBeginDeleteOptions contains the optional parameters for the VirtualNetworksClient.BeginDelete +// method. func (client *VirtualNetworksClient) BeginDelete(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualNetworksClientBeginDeleteOptions) (*runtime.Poller[VirtualNetworksClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, labName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualNetworksClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualNetworksClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualNetworksClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualNetworksClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete virtual network. This operation can take a while to complete. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 func (client *VirtualNetworksClient) deleteOperation(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualNetworksClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, name, 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 } @@ -181,7 +175,7 @@ func (client *VirtualNetworksClient) deleteCreateRequest(ctx context.Context, re 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 } @@ -194,17 +188,18 @@ func (client *VirtualNetworksClient) deleteCreateRequest(ctx context.Context, re // Get - Get virtual network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual network. -// options - VirtualNetworksClientGetOptions contains the optional parameters for the VirtualNetworksClient.Get method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual network. +// - options - VirtualNetworksClientGetOptions contains the optional parameters for the VirtualNetworksClient.Get method. func (client *VirtualNetworksClient) Get(ctx context.Context, resourceGroupName string, labName string, name string, options *VirtualNetworksClientGetOptions) (VirtualNetworksClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, labName, name, options) if err != nil { return VirtualNetworksClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualNetworksClientGetResponse{}, err } @@ -233,7 +228,7 @@ func (client *VirtualNetworksClient) getCreateRequest(ctx context.Context, resou 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 } @@ -257,11 +252,12 @@ func (client *VirtualNetworksClient) getHandleResponse(resp *http.Response) (Vir } // NewListPager - List virtual networks in a given lab. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// options - VirtualNetworksClientListOptions contains the optional parameters for the VirtualNetworksClient.List method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - options - VirtualNetworksClientListOptions contains the optional parameters for the VirtualNetworksClient.NewListPager +// method. func (client *VirtualNetworksClient) NewListPager(resourceGroupName string, labName string, options *VirtualNetworksClientListOptions) *runtime.Pager[VirtualNetworksClientListResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualNetworksClientListResponse]{ More: func(page VirtualNetworksClientListResponse) bool { @@ -278,7 +274,7 @@ func (client *VirtualNetworksClient) NewListPager(resourceGroupName string, labN if err != nil { return VirtualNetworksClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualNetworksClientListResponse{}, err } @@ -305,7 +301,7 @@ func (client *VirtualNetworksClient) listCreateRequest(ctx context.Context, reso return nil, errors.New("parameter labName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) - 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 } @@ -339,18 +335,19 @@ func (client *VirtualNetworksClient) listHandleResponse(resp *http.Response) (Vi // Update - Allows modifying tags of virtual networks. All other properties will be ignored. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-15 -// resourceGroupName - The name of the resource group. -// labName - The name of the lab. -// name - The name of the virtual network. -// virtualNetwork - A virtual network. -// options - VirtualNetworksClientUpdateOptions contains the optional parameters for the VirtualNetworksClient.Update method. +// - resourceGroupName - The name of the resource group. +// - labName - The name of the lab. +// - name - The name of the virtual network. +// - virtualNetwork - A virtual network. +// - options - VirtualNetworksClientUpdateOptions contains the optional parameters for the VirtualNetworksClient.Update method. func (client *VirtualNetworksClient) Update(ctx context.Context, resourceGroupName string, labName string, name string, virtualNetwork VirtualNetworkFragment, options *VirtualNetworksClientUpdateOptions) (VirtualNetworksClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, name, virtualNetwork, options) if err != nil { return VirtualNetworksClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualNetworksClientUpdateResponse{}, err } @@ -379,7 +376,7 @@ func (client *VirtualNetworksClient) updateCreateRequest(ctx context.Context, re return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - 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/devtestlabs/armdevtestlabs/virtualnetworks_client_example_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/virtualnetworks_client_example_test.go new file mode 100644 index 000000000000..a62307cae5c6 --- /dev/null +++ b/sdk/resourcemanager/devtestlabs/armdevtestlabs/virtualnetworks_client_example_test.go @@ -0,0 +1,266 @@ +//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 armdevtestlabs_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/devtestlabs/armdevtestlabs" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_List.json +func ExampleVirtualNetworksClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewVirtualNetworksClient().NewListPager("resourceGroupName", "{labName}", &armdevtestlabs.VirtualNetworksClientListOptions{Expand: nil, + Filter: nil, + Top: nil, + Orderby: 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.VirtualNetworkList = armdevtestlabs.VirtualNetworkList{ + // Value: []*armdevtestlabs.VirtualNetwork{ + // { + // Name: to.Ptr("{virtualNetworkName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/virtualNetworks"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualnetworks/{virtualNetworkName}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.VirtualNetworkProperties{ + // AllowedSubnets: []*armdevtestlabs.Subnet{ + // { + // AllowPublicIP: to.Ptr(armdevtestlabs.UsagePermissionTypeAllow), + // LabSubnetName: to.Ptr("{virtualNetworkName}Subnet"), + // ResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{virtualNetworkName}Subnet"), + // }}, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T13:01:44.6005134-07:00"); return t}()), + // ExternalProviderResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}"), + // ProvisioningState: to.Ptr("Succeeded"), + // SubnetOverrides: []*armdevtestlabs.SubnetOverride{ + // { + // LabSubnetName: to.Ptr("{virtualNetworkName}Subnet"), + // ResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{virtualNetworkName}Subnet"), + // SharedPublicIPAddressConfiguration: &armdevtestlabs.SubnetSharedPublicIPAddressConfiguration{ + // AllowedPorts: []*armdevtestlabs.Port{ + // { + // BackendPort: to.Ptr[int32](3389), + // TransportProtocol: to.Ptr(armdevtestlabs.TransportProtocolTCP), + // }, + // { + // BackendPort: to.Ptr[int32](22), + // TransportProtocol: to.Ptr(armdevtestlabs.TransportProtocolTCP), + // }}, + // }, + // UseInVMCreationPermission: to.Ptr(armdevtestlabs.UsagePermissionTypeAllow), + // UsePublicIPAddressPermission: to.Ptr(armdevtestlabs.UsagePermissionTypeAllow), + // }}, + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_Get.json +func ExampleVirtualNetworksClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualNetworksClient().Get(ctx, "resourceGroupName", "{labName}", "{virtualNetworkName}", &armdevtestlabs.VirtualNetworksClientGetOptions{Expand: 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.VirtualNetwork = armdevtestlabs.VirtualNetwork{ + // Name: to.Ptr("{virtualNetworkName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/virtualNetworks"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualnetworks/{virtualNetworkName}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.VirtualNetworkProperties{ + // AllowedSubnets: []*armdevtestlabs.Subnet{ + // { + // AllowPublicIP: to.Ptr(armdevtestlabs.UsagePermissionTypeAllow), + // LabSubnetName: to.Ptr("{virtualNetworkName}Subnet"), + // ResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{virtualNetworkName}Subnet"), + // }}, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T13:01:44.6005134-07:00"); return t}()), + // ExternalProviderResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}"), + // ProvisioningState: to.Ptr("Succeeded"), + // SubnetOverrides: []*armdevtestlabs.SubnetOverride{ + // { + // LabSubnetName: to.Ptr("{virtualNetworkName}Subnet"), + // ResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{virtualNetworkName}Subnet"), + // SharedPublicIPAddressConfiguration: &armdevtestlabs.SubnetSharedPublicIPAddressConfiguration{ + // AllowedPorts: []*armdevtestlabs.Port{ + // { + // BackendPort: to.Ptr[int32](3389), + // TransportProtocol: to.Ptr(armdevtestlabs.TransportProtocolTCP), + // }, + // { + // BackendPort: to.Ptr[int32](22), + // TransportProtocol: to.Ptr(armdevtestlabs.TransportProtocolTCP), + // }}, + // }, + // UseInVMCreationPermission: to.Ptr(armdevtestlabs.UsagePermissionTypeAllow), + // UsePublicIPAddressPermission: to.Ptr(armdevtestlabs.UsagePermissionTypeAllow), + // }}, + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_CreateOrUpdate.json +func ExampleVirtualNetworksClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualNetworksClient().BeginCreateOrUpdate(ctx, "resourceGroupName", "{labName}", "{virtualNetworkName}", armdevtestlabs.VirtualNetwork{ + Location: to.Ptr("{location}"), + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + }, 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.VirtualNetwork = armdevtestlabs.VirtualNetwork{ + // Name: to.Ptr("{virtualNetworkName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/virtualNetworks"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualnetworks/{virtualNetworkName}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.VirtualNetworkProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T13:01:44.6005134-07:00"); return t}()), + // ProvisioningState: to.Ptr("Succeeded"), + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_Delete.json +func ExampleVirtualNetworksClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualNetworksClient().BeginDelete(ctx, "resourceGroupName", "{labName}", "{virtualNetworkName}", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_Update.json +func ExampleVirtualNetworksClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevtestlabs.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualNetworksClient().Update(ctx, "resourceGroupName", "{labName}", "{virtualNetworkName}", armdevtestlabs.VirtualNetworkFragment{ + Tags: map[string]*string{ + "tagName1": to.Ptr("tagValue1"), + }, + }, 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.VirtualNetwork = armdevtestlabs.VirtualNetwork{ + // Name: to.Ptr("{virtualNetworkName}"), + // Type: to.Ptr("Microsoft.DevTestLab/labs/virtualNetworks"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualnetworks/{virtualNetworkName}"), + // Tags: map[string]*string{ + // "tagName1": to.Ptr("tagValue1"), + // }, + // Properties: &armdevtestlabs.VirtualNetworkProperties{ + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-01T13:01:44.6005134-07:00"); return t}()), + // ExternalProviderResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}"), + // ProvisioningState: to.Ptr("Succeeded"), + // SubnetOverrides: []*armdevtestlabs.SubnetOverride{ + // { + // LabSubnetName: to.Ptr("{virtualNetworkName}Subnet"), + // ResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{virtualNetworkName}Subnet"), + // SharedPublicIPAddressConfiguration: &armdevtestlabs.SubnetSharedPublicIPAddressConfiguration{ + // AllowedPorts: []*armdevtestlabs.Port{ + // { + // BackendPort: to.Ptr[int32](3389), + // TransportProtocol: to.Ptr(armdevtestlabs.TransportProtocolTCP), + // }, + // { + // BackendPort: to.Ptr[int32](22), + // TransportProtocol: to.Ptr(armdevtestlabs.TransportProtocolTCP), + // }}, + // }, + // UseInVMCreationPermission: to.Ptr(armdevtestlabs.UsagePermissionTypeAllow), + // UsePublicIPAddressPermission: to.Ptr(armdevtestlabs.UsagePermissionTypeAllow), + // }}, + // UniqueIdentifier: to.Ptr("{uniqueIdentifier}"), + // }, + // } +} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_armtemplates_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_armtemplates_client_test.go deleted file mode 100644 index 04ebd3195dde..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_armtemplates_client_test.go +++ /dev/null @@ -1,72 +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 armdevtestlabs_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArmTemplates_List.json -func ExampleArmTemplatesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewArmTemplatesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - "{artifactSourceName}", - &armdevtestlabs.ArmTemplatesClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArmTemplates_Get.json -func ExampleArmTemplatesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewArmTemplatesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "{artifactSourceName}", - "{armTemplateName}", - &armdevtestlabs.ArmTemplatesClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_artifacts_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_artifacts_client_test.go deleted file mode 100644 index 8cf62961ed5e..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_artifacts_client_test.go +++ /dev/null @@ -1,102 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Artifacts_List.json -func ExampleArtifactsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewArtifactsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - "{artifactSourceName}", - &armdevtestlabs.ArtifactsClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Artifacts_Get.json -func ExampleArtifactsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewArtifactsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "{artifactSourceName}", - "{artifactName}", - &armdevtestlabs.ArtifactsClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Artifacts_GenerateArmTemplate.json -func ExampleArtifactsClient_GenerateArmTemplate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewArtifactsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GenerateArmTemplate(ctx, - "resourceGroupName", - "{labName}", - "{artifactSourceName}", - "{artifactName}", - armdevtestlabs.GenerateArmTemplateRequest{ - FileUploadOptions: to.Ptr(armdevtestlabs.FileUploadOptionsNone), - Location: to.Ptr("{location}"), - VirtualMachineName: to.Ptr("{vmName}"), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_artifactsources_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_artifactsources_client_test.go deleted file mode 100644 index ade05084d154..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_artifactsources_client_test.go +++ /dev/null @@ -1,158 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_List.json -func ExampleArtifactSourcesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewArtifactSourcesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - &armdevtestlabs.ArtifactSourcesClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_Get.json -func ExampleArtifactSourcesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewArtifactSourcesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "{artifactSourceName}", - &armdevtestlabs.ArtifactSourcesClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_CreateOrUpdate.json -func ExampleArtifactSourcesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewArtifactSourcesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - "{artifactSourceName}", - armdevtestlabs.ArtifactSource{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - Properties: &armdevtestlabs.ArtifactSourceProperties{ - ArmTemplateFolderPath: to.Ptr("{armTemplateFolderPath}"), - BranchRef: to.Ptr("{branchRef}"), - DisplayName: to.Ptr("{displayName}"), - FolderPath: to.Ptr("{folderPath}"), - SecurityToken: to.Ptr("{securityToken}"), - SourceType: to.Ptr(armdevtestlabs.SourceControlType("{VsoGit|GitHub|StorageAccount}")), - Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), - URI: to.Ptr("{artifactSourceUri}"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_Delete.json -func ExampleArtifactSourcesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewArtifactSourcesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "resourceGroupName", - "{labName}", - "{artifactSourceName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_Update.json -func ExampleArtifactSourcesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewArtifactSourcesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{labName}", - "{artifactSourceName}", - armdevtestlabs.ArtifactSourceFragment{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_costs_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_costs_client_test.go deleted file mode 100644 index 0cded3074844..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_costs_client_test.go +++ /dev/null @@ -1,121 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Costs_Get.json -func ExampleCostsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewCostsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "targetCost", - &armdevtestlabs.CostsClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Costs_CreateOrUpdate.json -func ExampleCostsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewCostsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - "targetCost", - armdevtestlabs.LabCost{ - Properties: &armdevtestlabs.LabCostProperties{ - CurrencyCode: to.Ptr("USD"), - EndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-31T23:59:59Z"); return t }()), - StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T00:00:00Z"); return t }()), - TargetCost: &armdevtestlabs.TargetCostProperties{ - CostThresholds: []*armdevtestlabs.CostThresholdProperties{ - { - DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), - PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ - ThresholdValue: to.Ptr[float64](25), - }, - SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), - ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000001"), - }, - { - DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusEnabled), - PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ - ThresholdValue: to.Ptr[float64](50), - }, - SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusEnabled), - ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000002"), - }, - { - DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), - PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ - ThresholdValue: to.Ptr[float64](75), - }, - SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), - ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000003"), - }, - { - DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), - PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ - ThresholdValue: to.Ptr[float64](100), - }, - SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), - ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000004"), - }, - { - DisplayOnChart: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), - PercentageThreshold: &armdevtestlabs.PercentageCostThresholdProperties{ - ThresholdValue: to.Ptr[float64](125), - }, - SendNotificationWhenExceeded: to.Ptr(armdevtestlabs.CostThresholdStatusDisabled), - ThresholdID: to.Ptr("00000000-0000-0000-0000-000000000005"), - }}, - CycleEndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-31T00:00:00.000Z"); return t }()), - CycleStartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T00:00:00.000Z"); return t }()), - CycleType: to.Ptr(armdevtestlabs.ReportingCycleTypeCalendarMonth), - Status: to.Ptr(armdevtestlabs.TargetCostStatusEnabled), - Target: to.Ptr[int32](100), - }, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_customimages_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_customimages_client_test.go deleted file mode 100644 index e4907bd9132a..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_customimages_client_test.go +++ /dev/null @@ -1,165 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_List.json -func ExampleCustomImagesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewCustomImagesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - &armdevtestlabs.CustomImagesClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_Get.json -func ExampleCustomImagesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewCustomImagesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "{customImageName}", - &armdevtestlabs.CustomImagesClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_CreateOrUpdate.json -func ExampleCustomImagesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewCustomImagesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - "{customImageName}", - armdevtestlabs.CustomImage{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - Properties: &armdevtestlabs.CustomImageProperties{ - Description: to.Ptr("My Custom Image"), - VM: &armdevtestlabs.CustomImagePropertiesFromVM{ - LinuxOsInfo: &armdevtestlabs.LinuxOsInfo{ - LinuxOsState: to.Ptr(armdevtestlabs.LinuxOsStateNonDeprovisioned), - }, - SourceVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), - }, - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_Delete.json -func ExampleCustomImagesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewCustomImagesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "resourceGroupName", - "{labName}", - "{customImageName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_Update.json -func ExampleCustomImagesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewCustomImagesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{labName}", - "{customImageName}", - armdevtestlabs.CustomImageFragment{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue2"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_disks_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_disks_client_test.go deleted file mode 100644 index 3380e67ba8e3..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_disks_client_test.go +++ /dev/null @@ -1,221 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_List.json -func ExampleDisksClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewDisksClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - "@me", - &armdevtestlabs.DisksClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_Get.json -func ExampleDisksClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewDisksClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "@me", - "{diskName}", - &armdevtestlabs.DisksClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_CreateOrUpdate.json -func ExampleDisksClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewDisksClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - "{userId}", - "{diskName}", - armdevtestlabs.Disk{ - Properties: &armdevtestlabs.DiskProperties{ - DiskSizeGiB: to.Ptr[int32](1023), - DiskType: to.Ptr(armdevtestlabs.StorageTypeStandard), - LeasedByLabVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/vmName"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_Delete.json -func ExampleDisksClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewDisksClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "resourceGroupName", - "{labName}", - "{userId}", - "{diskName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_Update.json -func ExampleDisksClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewDisksClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{labName}", - "@me", - "diskName", - armdevtestlabs.DiskFragment{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_Attach.json -func ExampleDisksClient_BeginAttach() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewDisksClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginAttach(ctx, - "resourceGroupName", - "{labName}", - "{userId}", - "{diskName}", - armdevtestlabs.AttachDiskProperties{ - LeasedByLabVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_Detach.json -func ExampleDisksClient_BeginDetach() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewDisksClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDetach(ctx, - "resourceGroupName", - "{labName}", - "{userId}", - "{diskName}", - armdevtestlabs.DetachDiskProperties{ - LeasedByLabVMID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/myResourceGroup/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), - }, - 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/devtestlabs/armdevtestlabs/ze_generated_example_environments_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_environments_client_test.go deleted file mode 100644 index b3296255d5d0..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_environments_client_test.go +++ /dev/null @@ -1,164 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_List.json -func ExampleEnvironmentsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewEnvironmentsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - "@me", - &armdevtestlabs.EnvironmentsClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_Get.json -func ExampleEnvironmentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewEnvironmentsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "@me", - "{environmentName}", - &armdevtestlabs.EnvironmentsClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_CreateOrUpdate.json -func ExampleEnvironmentsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewEnvironmentsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - "@me", - "{environmentName}", - armdevtestlabs.DtlEnvironment{ - Properties: &armdevtestlabs.EnvironmentProperties{ - DeploymentProperties: &armdevtestlabs.EnvironmentDeploymentProperties{ - ArmTemplateID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/artifactSources/{artifactSourceName}/armTemplates/{armTemplateName}"), - Parameters: []*armdevtestlabs.ArmTemplateParameterProperties{}, - }, - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_Delete.json -func ExampleEnvironmentsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewEnvironmentsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "resourceGroupName", - "{labName}", - "@me", - "{environmentName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_Update.json -func ExampleEnvironmentsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewEnvironmentsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{labName}", - "@me", - "{environmentName}", - armdevtestlabs.DtlEnvironmentFragment{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_formulas_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_formulas_client_test.go deleted file mode 100644 index 11156b2386cb..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_formulas_client_test.go +++ /dev/null @@ -1,188 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_List.json -func ExampleFormulasClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewFormulasClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - &armdevtestlabs.FormulasClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_Get.json -func ExampleFormulasClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewFormulasClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "{formulaName}", - &armdevtestlabs.FormulasClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_CreateOrUpdate.json -func ExampleFormulasClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewFormulasClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - "{formulaName}", - armdevtestlabs.Formula{ - Location: to.Ptr("{location}"), - Properties: &armdevtestlabs.FormulaProperties{ - Description: to.Ptr("Formula using a Linux base"), - FormulaContent: &armdevtestlabs.LabVirtualMachineCreationParameter{ - Location: to.Ptr("{location}"), - Properties: &armdevtestlabs.LabVirtualMachineCreationParameterProperties{ - AllowClaim: to.Ptr(false), - Artifacts: []*armdevtestlabs.ArtifactInstallProperties{ - { - ArtifactID: to.Ptr("/artifactsources/{artifactSourceName}/artifacts/linux-install-nodejs"), - Parameters: []*armdevtestlabs.ArtifactParameterProperties{}, - }}, - DisallowPublicIPAddress: to.Ptr(true), - GalleryImageReference: &armdevtestlabs.GalleryImageReference{ - Offer: to.Ptr("0001-com-ubuntu-server-groovy"), - OSType: to.Ptr("Linux"), - Publisher: to.Ptr("canonical"), - SKU: to.Ptr("20_10"), - Version: to.Ptr("latest"), - }, - IsAuthenticationWithSSHKey: to.Ptr(false), - LabSubnetName: to.Ptr("Dtl{labName}Subnet"), - LabVirtualNetworkID: to.Ptr("/virtualnetworks/dtl{labName}"), - NetworkInterface: &armdevtestlabs.NetworkInterfaceProperties{ - SharedPublicIPAddressConfiguration: &armdevtestlabs.SharedPublicIPAddressConfiguration{ - InboundNatRules: []*armdevtestlabs.InboundNatRule{ - { - BackendPort: to.Ptr[int32](22), - TransportProtocol: to.Ptr(armdevtestlabs.TransportProtocolTCP), - }}, - }, - }, - Notes: to.Ptr("Ubuntu Server 20.10"), - Size: to.Ptr("Standard_B1ms"), - StorageType: to.Ptr("Standard"), - UserName: to.Ptr("user"), - }, - }, - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_Delete.json -func ExampleFormulasClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewFormulasClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "resourceGroupName", - "{labName}", - "{formulaName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_Update.json -func ExampleFormulasClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewFormulasClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{labName}", - "{formulaName}", - armdevtestlabs.FormulaFragment{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_galleryimages_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_galleryimages_client_test.go deleted file mode 100644 index b9b9ce46c44e..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_galleryimages_client_test.go +++ /dev/null @@ -1,47 +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 armdevtestlabs_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GalleryImages_List.json -func ExampleGalleryImagesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewGalleryImagesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - &armdevtestlabs.GalleryImagesClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/armdevtestlabs/ze_generated_example_globalschedules_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_globalschedules_client_test.go deleted file mode 100644 index 8948dda93aad..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_globalschedules_client_test.go +++ /dev/null @@ -1,235 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_ListBySubscription.json -func ExampleGlobalSchedulesClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewGlobalSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(&armdevtestlabs.GlobalSchedulesClientListBySubscriptionOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_ListByResourceGroup.json -func ExampleGlobalSchedulesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewGlobalSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("resourceGroupName", - &armdevtestlabs.GlobalSchedulesClientListByResourceGroupOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_Get.json -func ExampleGlobalSchedulesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewGlobalSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "labvmautostart", - &armdevtestlabs.GlobalSchedulesClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_CreateOrUpdate.json -func ExampleGlobalSchedulesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewGlobalSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "resourceGroupName", - "labvmautostart", - armdevtestlabs.Schedule{ - Properties: &armdevtestlabs.ScheduleProperties{ - Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), - TaskType: to.Ptr("LabVmsStartupTask"), - TimeZoneID: to.Ptr("Hawaiian Standard Time"), - WeeklyRecurrence: &armdevtestlabs.WeekDetails{ - Time: to.Ptr("0700"), - Weekdays: []*string{ - to.Ptr("Monday"), - to.Ptr("Tuesday"), - to.Ptr("Wednesday"), - to.Ptr("Thursday"), - to.Ptr("Friday"), - to.Ptr("Saturday")}, - }, - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_Delete.json -func ExampleGlobalSchedulesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewGlobalSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "resourceGroupName", - "labvmautostart", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_Update.json -func ExampleGlobalSchedulesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewGlobalSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "labvmautostart", - armdevtestlabs.ScheduleFragment{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_Execute.json -func ExampleGlobalSchedulesClient_BeginExecute() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewGlobalSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginExecute(ctx, - "resourceGroupName", - "labvmautostart", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_Retarget.json -func ExampleGlobalSchedulesClient_BeginRetarget() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewGlobalSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginRetarget(ctx, - "resourceGroupName", - "{scheduleName}", - armdevtestlabs.RetargetScheduleProperties{ - CurrentResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{targetLab}"), - TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{currentLab}"), - }, - 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/devtestlabs/armdevtestlabs/ze_generated_example_labs_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_labs_client_test.go deleted file mode 100644 index 541853c59432..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_labs_client_test.go +++ /dev/null @@ -1,311 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_ListBySubscription.json -func ExampleLabsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewLabsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(&armdevtestlabs.LabsClientListBySubscriptionOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_ListByResourceGroup.json -func ExampleLabsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewLabsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("resourceGroupName", - &armdevtestlabs.LabsClientListByResourceGroupOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_Get.json -func ExampleLabsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewLabsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - &armdevtestlabs.LabsClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_CreateOrUpdate.json -func ExampleLabsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewLabsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - armdevtestlabs.Lab{ - Location: to.Ptr("{location}"), - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - Properties: &armdevtestlabs.LabProperties{ - LabStorageType: to.Ptr(armdevtestlabs.StorageType("{Standard|Premium}")), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_Delete.json -func ExampleLabsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewLabsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "resourceGroupName", - "{labName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_Update.json -func ExampleLabsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewLabsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{labName}", - armdevtestlabs.LabFragment{}, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_CreateEnvironment.json -func ExampleLabsClient_BeginCreateEnvironment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewLabsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateEnvironment(ctx, - "resourceGroupName", - "{labName}", - armdevtestlabs.LabVirtualMachineCreationParameter{ - Name: to.Ptr("{vmName}"), - Location: to.Ptr("{location}"), - Properties: &armdevtestlabs.LabVirtualMachineCreationParameterProperties{ - AllowClaim: to.Ptr(true), - DisallowPublicIPAddress: to.Ptr(true), - GalleryImageReference: &armdevtestlabs.GalleryImageReference{ - Offer: to.Ptr("UbuntuServer"), - OSType: to.Ptr("Linux"), - Publisher: to.Ptr("Canonical"), - SKU: to.Ptr("16.04-LTS"), - Version: to.Ptr("Latest"), - }, - LabSubnetName: to.Ptr("{virtualnetwork-subnet-name}"), - LabVirtualNetworkID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualnetworks/{virtualNetworkName}"), - Password: to.Ptr("{userPassword}"), - Size: to.Ptr("Standard_A2_v2"), - StorageType: to.Ptr("Standard"), - UserName: to.Ptr("{userName}"), - }, - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_ExportResourceUsage.json -func ExampleLabsClient_BeginExportResourceUsage() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewLabsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginExportResourceUsage(ctx, - "resourceGroupName", - "{labName}", - armdevtestlabs.ExportResourceUsageParameters{ - BlobStorageAbsoluteSasURI: to.Ptr("https://invalid.blob.core.windows.net/export.blob?sv=2015-07-08&sig={sas}&sp=rcw"), - UsageStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T00:00:00Z"); return t }()), - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_ImportVirtualMachine.json -func ExampleLabsClient_BeginImportVirtualMachine() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewLabsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginImportVirtualMachine(ctx, - "resourceGroupName", - "{labName}", - armdevtestlabs.ImportLabVirtualMachineRequest{ - DestinationVirtualMachineName: to.Ptr("{vmName}"), - SourceVirtualMachineResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{otherResourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"), - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_ListVhds.json -func ExampleLabsClient_NewListVhdsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewLabsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListVhdsPager("resourceGroupName", - "{labName}", - 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/devtestlabs/armdevtestlabs/ze_generated_example_notificationchannels_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_notificationchannels_client_test.go deleted file mode 100644 index 07c7aaed7302..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_notificationchannels_client_test.go +++ /dev/null @@ -1,176 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_List.json -func ExampleNotificationChannelsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewNotificationChannelsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - &armdevtestlabs.NotificationChannelsClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_Get.json -func ExampleNotificationChannelsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewNotificationChannelsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "{notificationChannelName}", - &armdevtestlabs.NotificationChannelsClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_CreateOrUpdate.json -func ExampleNotificationChannelsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewNotificationChannelsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - "{notificationChannelName}", - armdevtestlabs.NotificationChannel{ - Properties: &armdevtestlabs.NotificationChannelProperties{ - Description: to.Ptr("Integration configured for auto-shutdown"), - EmailRecipient: to.Ptr("{email}"), - Events: []*armdevtestlabs.Event{ - { - EventName: to.Ptr(armdevtestlabs.NotificationChannelEventTypeAutoShutdown), - }}, - NotificationLocale: to.Ptr("en"), - WebHookURL: to.Ptr("{webhookUrl}"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_Delete.json -func ExampleNotificationChannelsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewNotificationChannelsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "resourceGroupName", - "{labName}", - "{notificationChannelName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_Update.json -func ExampleNotificationChannelsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewNotificationChannelsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{labName}", - "{notificationChannelName}", - armdevtestlabs.NotificationChannelFragment{}, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_Notify.json -func ExampleNotificationChannelsClient_Notify() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewNotificationChannelsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Notify(ctx, - "resourceGroupName", - "{labName}", - "{notificationChannelName}", - armdevtestlabs.NotifyParameters{ - EventName: to.Ptr(armdevtestlabs.NotificationChannelEventTypeAutoShutdown), - JSONPayload: to.Ptr("{\"eventType\":\"AutoShutdown\",\"subscriptionId\":\"{subscriptionId}\",\"resourceGroupName\":\"resourceGroupName\",\"labName\":\"{labName}\"}"), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_policies_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_policies_client_test.go deleted file mode 100644 index f702bf8b781a..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_policies_client_test.go +++ /dev/null @@ -1,162 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_List.json -func ExamplePoliciesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewPoliciesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - "{policySetName}", - &armdevtestlabs.PoliciesClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_Get.json -func ExamplePoliciesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewPoliciesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "{policySetName}", - "{policyName}", - &armdevtestlabs.PoliciesClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_CreateOrUpdate.json -func ExamplePoliciesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewPoliciesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - "{policySetName}", - "{policyName}", - armdevtestlabs.Policy{ - Location: to.Ptr("{location}"), - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - Properties: &armdevtestlabs.PolicyProperties{ - Description: to.Ptr("{policyDescription}"), - EvaluatorType: to.Ptr(armdevtestlabs.PolicyEvaluatorType("{policyEvaluatorType}")), - FactData: to.Ptr("{policyFactData}"), - FactName: to.Ptr(armdevtestlabs.PolicyFactName("{policyFactName}")), - Status: to.Ptr(armdevtestlabs.PolicyStatus("{policyStatus}")), - Threshold: to.Ptr("{policyThreshold}"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_Delete.json -func ExamplePoliciesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewPoliciesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "resourceGroupName", - "{labName}", - "{policySetName}", - "{policyName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_Update.json -func ExamplePoliciesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewPoliciesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{labName}", - "{policySetName}", - "{policyName}", - armdevtestlabs.PolicyFragment{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_policysets_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_policysets_client_test.go deleted file mode 100644 index e5d72bd393f1..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_policysets_client_test.go +++ /dev/null @@ -1,48 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/PolicySets_EvaluatePolicies.json -func ExamplePolicySetsClient_EvaluatePolicies() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewPolicySetsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.EvaluatePolicies(ctx, - "resourceGroupName", - "{labName}", - "{policySetName}", - armdevtestlabs.EvaluatePoliciesRequest{ - Policies: []*armdevtestlabs.EvaluatePoliciesProperties{ - { - FactName: to.Ptr("LabVmCount"), - ValueOffset: to.Ptr("1"), - }}, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_provideroperations_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_provideroperations_client_test.go deleted file mode 100644 index 7789b827b050..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_provideroperations_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 armdevtestlabs_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ProviderOperations_List.json -func ExampleProviderOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewProviderOperationsClient(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/devtestlabs/armdevtestlabs/ze_generated_example_schedules_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_schedules_client_test.go deleted file mode 100644 index 4d97d7d621d5..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_schedules_client_test.go +++ /dev/null @@ -1,227 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_List.json -func ExampleSchedulesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - &armdevtestlabs.SchedulesClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_Get.json -func ExampleSchedulesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "{scheduleName}", - &armdevtestlabs.SchedulesClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_CreateOrUpdate.json -func ExampleSchedulesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - "{scheduleName}", - armdevtestlabs.Schedule{ - Location: to.Ptr("{location}"), - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - Properties: &armdevtestlabs.ScheduleProperties{ - DailyRecurrence: &armdevtestlabs.DayDetails{ - Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurEveryDay}"), - }, - HourlyRecurrence: &armdevtestlabs.HourDetails{ - Minute: to.Ptr[int32](30), - }, - NotificationSettings: &armdevtestlabs.NotificationSettings{ - EmailRecipient: to.Ptr("{email}"), - NotificationLocale: to.Ptr("EN"), - Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), - TimeInMinutes: to.Ptr[int32](15), - WebhookURL: to.Ptr("{webhookUrl}"), - }, - Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), - TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}"), - TaskType: to.Ptr("{myLabVmTaskType}"), - TimeZoneID: to.Ptr("Pacific Standard Time"), - WeeklyRecurrence: &armdevtestlabs.WeekDetails{ - Time: to.Ptr("{timeOfTheDayTheScheduleWillOccurOnThoseDays}"), - Weekdays: []*string{ - to.Ptr("Monday"), - to.Ptr("Wednesday"), - to.Ptr("Friday")}, - }, - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_Delete.json -func ExampleSchedulesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "resourceGroupName", - "{labName}", - "{scheduleName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_Update.json -func ExampleSchedulesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{labName}", - "{scheduleName}", - armdevtestlabs.ScheduleFragment{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_Execute.json -func ExampleSchedulesClient_BeginExecute() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginExecute(ctx, - "resourceGroupName", - "{labName}", - "{scheduleName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_ListApplicable.json -func ExampleSchedulesClient_NewListApplicablePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListApplicablePager("resourceGroupName", - "{labName}", - "{scheduleName}", - 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/devtestlabs/armdevtestlabs/ze_generated_example_secrets_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_secrets_client_test.go deleted file mode 100644 index bd155b92efee..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_secrets_client_test.go +++ /dev/null @@ -1,157 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_List.json -func ExampleSecretsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewSecretsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - "{userName}", - &armdevtestlabs.SecretsClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_Get.json -func ExampleSecretsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewSecretsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "{userName}", - "{secretName}", - &armdevtestlabs.SecretsClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_CreateOrUpdate.json -func ExampleSecretsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewSecretsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - "{userName}", - "{secretName}", - armdevtestlabs.Secret{ - Properties: &armdevtestlabs.SecretProperties{ - Value: to.Ptr("{secret}"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_Delete.json -func ExampleSecretsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewSecretsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "resourceGroupName", - "{labName}", - "{userName}", - "{secretName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_Update.json -func ExampleSecretsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewSecretsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{labName}", - "{userName}", - "{secretName}", - armdevtestlabs.SecretFragment{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_servicefabrics_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_servicefabrics_client_test.go deleted file mode 100644 index 1e625ca970a7..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_servicefabrics_client_test.go +++ /dev/null @@ -1,242 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_List.json -func ExampleServiceFabricsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceFabricsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - "{userName}", - &armdevtestlabs.ServiceFabricsClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_Get.json -func ExampleServiceFabricsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceFabricsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "{userName}", - "{serviceFabricName}", - &armdevtestlabs.ServiceFabricsClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_CreateOrUpdate.json -func ExampleServiceFabricsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceFabricsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - "{userName}", - "{serviceFabricName}", - armdevtestlabs.ServiceFabric{ - Location: to.Ptr("{location}"), - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - Properties: &armdevtestlabs.ServiceFabricProperties{ - EnvironmentID: to.Ptr("{environmentId}"), - ExternalServiceFabricID: to.Ptr("{serviceFabricId}"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_Delete.json -func ExampleServiceFabricsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceFabricsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "resourceGroupName", - "{labName}", - "{userName}", - "{serviceFabricName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_Update.json -func ExampleServiceFabricsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceFabricsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{labName}", - "{userName}", - "{serviceFabricName}", - armdevtestlabs.ServiceFabricFragment{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_ListApplicableSchedules.json -func ExampleServiceFabricsClient_ListApplicableSchedules() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceFabricsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListApplicableSchedules(ctx, - "resourceGroupName", - "{labName}", - "{userName}", - "{serviceFabricName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_Start.json -func ExampleServiceFabricsClient_BeginStart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceFabricsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStart(ctx, - "resourceGroupName", - "{labName}", - "{userName}", - "{serviceFabricName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_Stop.json -func ExampleServiceFabricsClient_BeginStop() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceFabricsClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStop(ctx, - "resourceGroupName", - "{labName}", - "{userName}", - "{serviceFabricName}", - 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/devtestlabs/armdevtestlabs/ze_generated_example_servicefabricschedules_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_servicefabricschedules_client_test.go deleted file mode 100644 index 6752f7384d30..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_servicefabricschedules_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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_List.json -func ExampleServiceFabricSchedulesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceFabricSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - "@me", - "{serviceFrabicName}", - &armdevtestlabs.ServiceFabricSchedulesClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_Get.json -func ExampleServiceFabricSchedulesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceFabricSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "@me", - "{serviceFrabicName}", - "{scheduleName}", - &armdevtestlabs.ServiceFabricSchedulesClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_CreateOrUpdate.json -func ExampleServiceFabricSchedulesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceFabricSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - "@me", - "{serviceFrabicName}", - "{scheduleName}", - armdevtestlabs.Schedule{ - Location: to.Ptr("{location}"), - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - Properties: &armdevtestlabs.ScheduleProperties{ - DailyRecurrence: &armdevtestlabs.DayDetails{ - Time: to.Ptr("19:00"), - }, - HourlyRecurrence: &armdevtestlabs.HourDetails{ - Minute: to.Ptr[int32](0), - }, - NotificationSettings: &armdevtestlabs.NotificationSettings{ - EmailRecipient: to.Ptr("{email}"), - NotificationLocale: to.Ptr("EN"), - Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), - TimeInMinutes: to.Ptr[int32](15), - WebhookURL: to.Ptr("{webhoolUrl}"), - }, - Status: to.Ptr(armdevtestlabs.EnableStatus("{Enabled|Disabled}")), - TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/users/{uniqueIdentifier}/servicefabrics/{serviceFrabicName}"), - TaskType: to.Ptr("{Unknown|LabVmsShutdownTask|LabVmsStartupTask|LabVmReclamationTask|ComputeVmShutdownTask}"), - TimeZoneID: to.Ptr("Pacific Standard Time"), - WeeklyRecurrence: &armdevtestlabs.WeekDetails{ - Time: to.Ptr("19:00"), - Weekdays: []*string{ - to.Ptr("Monday"), - to.Ptr("Tuesday"), - to.Ptr("Wednesday"), - to.Ptr("Thursday"), - to.Ptr("Friday"), - to.Ptr("Saturday"), - to.Ptr("Sunday")}, - }, - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_Delete.json -func ExampleServiceFabricSchedulesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceFabricSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "resourceGroupName", - "{labName}", - "@me", - "{serviceFrabicName}", - "{scheduleName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_Update.json -func ExampleServiceFabricSchedulesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceFabricSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{labName}", - "@me", - "{serviceFrabicName}", - "{scheduleName}", - armdevtestlabs.ScheduleFragment{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_Execute.json -func ExampleServiceFabricSchedulesClient_BeginExecute() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceFabricSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginExecute(ctx, - "resourceGroupName", - "{labName}", - "@me", - "{serviceFrabicName}", - "{scheduleName}", - 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/devtestlabs/armdevtestlabs/ze_generated_example_servicerunners_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_servicerunners_client_test.go deleted file mode 100644 index de0dca270fee..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_servicerunners_client_test.go +++ /dev/null @@ -1,97 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_Get.json -func ExampleServiceRunnersClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceRunnersClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{devtestlabName}", - "{servicerunnerName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_CreateOrUpdate.json -func ExampleServiceRunnersClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceRunnersClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "resourceGroupName", - "{devtestlabName}", - "{servicerunnerName}", - armdevtestlabs.ServiceRunner{ - Location: to.Ptr("{location}"), - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - Identity: &armdevtestlabs.IdentityProperties{ - Type: to.Ptr(armdevtestlabs.ManagedIdentityType("{identityType}")), - ClientSecretURL: to.Ptr("{identityClientSecretUrl}"), - PrincipalID: to.Ptr("{identityPrincipalId}"), - TenantID: to.Ptr("{identityTenantId}"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_Delete.json -func ExampleServiceRunnersClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewServiceRunnersClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "resourceGroupName", - "{devtestlabName}", - "{servicerunnerName}", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_users_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_users_client_test.go deleted file mode 100644 index e3cee64f3fe6..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_users_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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_List.json -func ExampleUsersClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewUsersClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{devtestlabName}", - &armdevtestlabs.UsersClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_Get.json -func ExampleUsersClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewUsersClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{devtestlabName}", - "{userName}", - &armdevtestlabs.UsersClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_CreateOrUpdate.json -func ExampleUsersClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewUsersClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "resourceGroupName", - "{devtestlabName}", - "{userName}", - armdevtestlabs.User{ - Location: to.Ptr("{location}"), - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - Properties: &armdevtestlabs.UserProperties{ - Identity: &armdevtestlabs.UserIdentity{ - AppID: to.Ptr("{appId}"), - ObjectID: to.Ptr("{objectId}"), - PrincipalID: to.Ptr("{principalId}"), - PrincipalName: to.Ptr("{principalName}"), - TenantID: to.Ptr("{tenantId}"), - }, - SecretStore: &armdevtestlabs.UserSecretStore{ - KeyVaultID: to.Ptr("{keyVaultId}"), - KeyVaultURI: to.Ptr("{keyVaultUri}"), - }, - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_Delete.json -func ExampleUsersClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewUsersClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "resourceGroupName", - "{devtestlabName}", - "{userName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_Update.json -func ExampleUsersClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewUsersClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{devtestlabName}", - "{userName}", - armdevtestlabs.UserFragment{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_virtualmachines_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_virtualmachines_client_test.go deleted file mode 100644 index 9e16a8b599a2..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_virtualmachines_client_test.go +++ /dev/null @@ -1,510 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_List.json -func ExampleVirtualMachinesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - &armdevtestlabs.VirtualMachinesClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Get.json -func ExampleVirtualMachinesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - &armdevtestlabs.VirtualMachinesClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_CreateOrUpdate.json -func ExampleVirtualMachinesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - armdevtestlabs.LabVirtualMachine{ - Location: to.Ptr("{location}"), - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - Properties: &armdevtestlabs.LabVirtualMachineProperties{ - AllowClaim: to.Ptr(true), - DisallowPublicIPAddress: to.Ptr(true), - GalleryImageReference: &armdevtestlabs.GalleryImageReference{ - Offer: to.Ptr("UbuntuServer"), - OSType: to.Ptr("Linux"), - Publisher: to.Ptr("Canonical"), - SKU: to.Ptr("16.04-LTS"), - Version: to.Ptr("Latest"), - }, - LabSubnetName: to.Ptr("{virtualNetworkName}Subnet"), - LabVirtualNetworkID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualnetworks/{virtualNetworkName}"), - Password: to.Ptr("{userPassword}"), - Size: to.Ptr("Standard_A2_v2"), - StorageType: to.Ptr("Standard"), - UserName: to.Ptr("{userName}"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Delete.json -func ExampleVirtualMachinesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Update.json -func ExampleVirtualMachinesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - armdevtestlabs.LabVirtualMachineFragment{}, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_AddDataDisk.json -func ExampleVirtualMachinesClient_BeginAddDataDisk() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginAddDataDisk(ctx, - "resourceGroupName", - "{labName}", - "{virtualMachineName}", - armdevtestlabs.DataDiskProperties{ - AttachNewDataDiskOptions: &armdevtestlabs.AttachNewDataDiskOptions{ - DiskName: to.Ptr("{diskName}"), - DiskSizeGiB: to.Ptr[int32](127), - DiskType: to.Ptr(armdevtestlabs.StorageType("{diskType}")), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_ApplyArtifacts.json -func ExampleVirtualMachinesClient_BeginApplyArtifacts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginApplyArtifacts(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - armdevtestlabs.ApplyArtifactsRequest{ - Artifacts: []*armdevtestlabs.ArtifactInstallProperties{ - { - ArtifactID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/artifactSources/public repo/artifacts/windows-restart"), - }}, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Claim.json -func ExampleVirtualMachinesClient_BeginClaim() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginClaim(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_DetachDataDisk.json -func ExampleVirtualMachinesClient_BeginDetachDataDisk() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDetachDataDisk(ctx, - "resourceGroupName", - "{labName}", - "{virtualMachineName}", - armdevtestlabs.DetachDataDiskProperties{ - ExistingLabDiskID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{virtualMachineName}"), - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_GetRdpFileContents.json -func ExampleVirtualMachinesClient_GetRdpFileContents() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetRdpFileContents(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_ListApplicableSchedules.json -func ExampleVirtualMachinesClient_ListApplicableSchedules() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListApplicableSchedules(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Redeploy.json -func ExampleVirtualMachinesClient_BeginRedeploy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginRedeploy(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Resize.json -func ExampleVirtualMachinesClient_BeginResize() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginResize(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - armdevtestlabs.ResizeLabVirtualMachineProperties{ - Size: to.Ptr("Standard_A4_v2"), - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Restart.json -func ExampleVirtualMachinesClient_BeginRestart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginRestart(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Start.json -func ExampleVirtualMachinesClient_BeginStart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStart(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Stop.json -func ExampleVirtualMachinesClient_BeginStop() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStop(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_TransferDisks.json -func ExampleVirtualMachinesClient_BeginTransferDisks() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginTransferDisks(ctx, - "resourceGroupName", - "{labName}", - "{virtualmachineName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_UnClaim.json -func ExampleVirtualMachinesClient_BeginUnClaim() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachinesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUnClaim(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - 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/devtestlabs/armdevtestlabs/ze_generated_example_virtualmachineschedules_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_virtualmachineschedules_client_test.go deleted file mode 100644 index 9945954303c0..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_virtualmachineschedules_client_test.go +++ /dev/null @@ -1,206 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_List.json -func ExampleVirtualMachineSchedulesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachineSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - "{vmName}", - &armdevtestlabs.VirtualMachineSchedulesClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_Get.json -func ExampleVirtualMachineSchedulesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachineSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - "LabVmsShutdown", - &armdevtestlabs.VirtualMachineSchedulesClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_CreateOrUpdate.json -func ExampleVirtualMachineSchedulesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachineSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - "LabVmsShutdown", - armdevtestlabs.Schedule{ - Location: to.Ptr("{location}"), - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - Properties: &armdevtestlabs.ScheduleProperties{ - DailyRecurrence: &armdevtestlabs.DayDetails{ - Time: to.Ptr("1900"), - }, - HourlyRecurrence: &armdevtestlabs.HourDetails{ - Minute: to.Ptr[int32](30), - }, - NotificationSettings: &armdevtestlabs.NotificationSettings{ - EmailRecipient: to.Ptr("{email}"), - NotificationLocale: to.Ptr("EN"), - Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), - TimeInMinutes: to.Ptr[int32](30), - WebhookURL: to.Ptr("{webhookUrl}"), - }, - Status: to.Ptr(armdevtestlabs.EnableStatusEnabled), - TargetResourceID: to.Ptr("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualMachines/{vmName}"), - TaskType: to.Ptr("LabVmsShutdownTask"), - TimeZoneID: to.Ptr("Pacific Standard Time"), - WeeklyRecurrence: &armdevtestlabs.WeekDetails{ - Time: to.Ptr("1700"), - Weekdays: []*string{ - to.Ptr("Friday"), - to.Ptr("Saturday"), - to.Ptr("Sunday")}, - }, - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_Delete.json -func ExampleVirtualMachineSchedulesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachineSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - "LabVmsShutdown", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_Update.json -func ExampleVirtualMachineSchedulesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachineSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - "LabVmsShutdown", - armdevtestlabs.ScheduleFragment{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_Execute.json -func ExampleVirtualMachineSchedulesClient_BeginExecute() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualMachineSchedulesClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginExecute(ctx, - "resourceGroupName", - "{labName}", - "{vmName}", - "LabVmsShutdown", - 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/devtestlabs/armdevtestlabs/ze_generated_example_virtualnetworks_client_test.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_virtualnetworks_client_test.go deleted file mode 100644 index 50adfc6fa9c8..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/ze_generated_example_virtualnetworks_client_test.go +++ /dev/null @@ -1,157 +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 armdevtestlabs_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/devtestlabs/armdevtestlabs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_List.json -func ExampleVirtualNetworksClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualNetworksClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceGroupName", - "{labName}", - &armdevtestlabs.VirtualNetworksClientListOptions{Expand: nil, - Filter: nil, - Top: nil, - Orderby: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_Get.json -func ExampleVirtualNetworksClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualNetworksClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "resourceGroupName", - "{labName}", - "{virtualNetworkName}", - &armdevtestlabs.VirtualNetworksClientGetOptions{Expand: 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_CreateOrUpdate.json -func ExampleVirtualNetworksClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualNetworksClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "resourceGroupName", - "{labName}", - "{virtualNetworkName}", - armdevtestlabs.VirtualNetwork{ - Location: to.Ptr("{location}"), - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - }, - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_Delete.json -func ExampleVirtualNetworksClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualNetworksClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "resourceGroupName", - "{labName}", - "{virtualNetworkName}", - 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/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_Update.json -func ExampleVirtualNetworksClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdevtestlabs.NewVirtualNetworksClient("{subscriptionId}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "resourceGroupName", - "{labName}", - "{virtualNetworkName}", - armdevtestlabs.VirtualNetworkFragment{ - Tags: map[string]*string{ - "tagName1": to.Ptr("tagValue1"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_models_serde.go b/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_models_serde.go deleted file mode 100644 index 711601838de0..000000000000 --- a/sdk/resourcemanager/devtestlabs/armdevtestlabs/zz_generated_models_serde.go +++ /dev/null @@ -1,1853 +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 armdevtestlabs - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type ApplicableSchedule. -func (a ApplicableSchedule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", a.ID) - populate(objectMap, "location", a.Location) - populate(objectMap, "name", a.Name) - populate(objectMap, "properties", a.Properties) - populate(objectMap, "tags", a.Tags) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ApplicableScheduleFragment. -func (a ApplicableScheduleFragment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", a.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ApplyArtifactsRequest. -func (a ApplyArtifactsRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "artifacts", a.Artifacts) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ArmTemplate. -func (a ArmTemplate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", a.ID) - populate(objectMap, "location", a.Location) - populate(objectMap, "name", a.Name) - populate(objectMap, "properties", a.Properties) - populate(objectMap, "tags", a.Tags) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ArmTemplateProperties. -func (a ArmTemplateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "contents", &a.Contents) - populateTimeRFC3339(objectMap, "createdDate", a.CreatedDate) - populate(objectMap, "description", a.Description) - populate(objectMap, "displayName", a.DisplayName) - populate(objectMap, "enabled", a.Enabled) - populate(objectMap, "icon", a.Icon) - populate(objectMap, "parametersValueFilesInfo", a.ParametersValueFilesInfo) - populate(objectMap, "publisher", a.Publisher) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ArmTemplateProperties. -func (a *ArmTemplateProperties) UnmarshalJSON(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 "contents": - err = unpopulate(val, "Contents", &a.Contents) - delete(rawMsg, key) - case "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &a.CreatedDate) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &a.Description) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &a.DisplayName) - delete(rawMsg, key) - case "enabled": - err = unpopulate(val, "Enabled", &a.Enabled) - delete(rawMsg, key) - case "icon": - err = unpopulate(val, "Icon", &a.Icon) - delete(rawMsg, key) - case "parametersValueFilesInfo": - err = unpopulate(val, "ParametersValueFilesInfo", &a.ParametersValueFilesInfo) - delete(rawMsg, key) - case "publisher": - err = unpopulate(val, "Publisher", &a.Publisher) - 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 Artifact. -func (a Artifact) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", a.ID) - populate(objectMap, "location", a.Location) - populate(objectMap, "name", a.Name) - populate(objectMap, "properties", a.Properties) - populate(objectMap, "tags", a.Tags) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ArtifactInstallProperties. -func (a ArtifactInstallProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "artifactId", a.ArtifactID) - populate(objectMap, "artifactTitle", a.ArtifactTitle) - populate(objectMap, "deploymentStatusMessage", a.DeploymentStatusMessage) - populateTimeRFC3339(objectMap, "installTime", a.InstallTime) - populate(objectMap, "parameters", a.Parameters) - populate(objectMap, "status", a.Status) - populate(objectMap, "vmExtensionStatusMessage", a.VMExtensionStatusMessage) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ArtifactInstallProperties. -func (a *ArtifactInstallProperties) UnmarshalJSON(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 "artifactId": - err = unpopulate(val, "ArtifactID", &a.ArtifactID) - delete(rawMsg, key) - case "artifactTitle": - err = unpopulate(val, "ArtifactTitle", &a.ArtifactTitle) - delete(rawMsg, key) - case "deploymentStatusMessage": - err = unpopulate(val, "DeploymentStatusMessage", &a.DeploymentStatusMessage) - delete(rawMsg, key) - case "installTime": - err = unpopulateTimeRFC3339(val, "InstallTime", &a.InstallTime) - delete(rawMsg, key) - case "parameters": - err = unpopulate(val, "Parameters", &a.Parameters) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &a.Status) - delete(rawMsg, key) - case "vmExtensionStatusMessage": - err = unpopulate(val, "VMExtensionStatusMessage", &a.VMExtensionStatusMessage) - 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 ArtifactProperties. -func (a ArtifactProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdDate", a.CreatedDate) - populate(objectMap, "description", a.Description) - populate(objectMap, "filePath", a.FilePath) - populate(objectMap, "icon", a.Icon) - populate(objectMap, "parameters", &a.Parameters) - populate(objectMap, "publisher", a.Publisher) - populate(objectMap, "targetOsType", a.TargetOsType) - populate(objectMap, "title", a.Title) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ArtifactProperties. -func (a *ArtifactProperties) UnmarshalJSON(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 "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &a.CreatedDate) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &a.Description) - delete(rawMsg, key) - case "filePath": - err = unpopulate(val, "FilePath", &a.FilePath) - delete(rawMsg, key) - case "icon": - err = unpopulate(val, "Icon", &a.Icon) - delete(rawMsg, key) - case "parameters": - err = unpopulate(val, "Parameters", &a.Parameters) - delete(rawMsg, key) - case "publisher": - err = unpopulate(val, "Publisher", &a.Publisher) - delete(rawMsg, key) - case "targetOsType": - err = unpopulate(val, "TargetOsType", &a.TargetOsType) - delete(rawMsg, key) - case "title": - err = unpopulate(val, "Title", &a.Title) - 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 ArtifactSource. -func (a ArtifactSource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", a.ID) - populate(objectMap, "location", a.Location) - populate(objectMap, "name", a.Name) - populate(objectMap, "properties", a.Properties) - populate(objectMap, "tags", a.Tags) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ArtifactSourceFragment. -func (a ArtifactSourceFragment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", a.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ArtifactSourceProperties. -func (a ArtifactSourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "armTemplateFolderPath", a.ArmTemplateFolderPath) - populate(objectMap, "branchRef", a.BranchRef) - populateTimeRFC3339(objectMap, "createdDate", a.CreatedDate) - populate(objectMap, "displayName", a.DisplayName) - populate(objectMap, "folderPath", a.FolderPath) - populate(objectMap, "provisioningState", a.ProvisioningState) - populate(objectMap, "securityToken", a.SecurityToken) - populate(objectMap, "sourceType", a.SourceType) - populate(objectMap, "status", a.Status) - populate(objectMap, "uri", a.URI) - populate(objectMap, "uniqueIdentifier", a.UniqueIdentifier) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ArtifactSourceProperties. -func (a *ArtifactSourceProperties) UnmarshalJSON(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 "armTemplateFolderPath": - err = unpopulate(val, "ArmTemplateFolderPath", &a.ArmTemplateFolderPath) - delete(rawMsg, key) - case "branchRef": - err = unpopulate(val, "BranchRef", &a.BranchRef) - delete(rawMsg, key) - case "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &a.CreatedDate) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &a.DisplayName) - delete(rawMsg, key) - case "folderPath": - err = unpopulate(val, "FolderPath", &a.FolderPath) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) - delete(rawMsg, key) - case "securityToken": - err = unpopulate(val, "SecurityToken", &a.SecurityToken) - delete(rawMsg, key) - case "sourceType": - err = unpopulate(val, "SourceType", &a.SourceType) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &a.Status) - delete(rawMsg, key) - case "uri": - err = unpopulate(val, "URI", &a.URI) - delete(rawMsg, key) - case "uniqueIdentifier": - err = unpopulate(val, "UniqueIdentifier", &a.UniqueIdentifier) - 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 ComputeVMProperties. -func (c ComputeVMProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "dataDiskIds", c.DataDiskIDs) - populate(objectMap, "dataDisks", c.DataDisks) - populate(objectMap, "networkInterfaceId", c.NetworkInterfaceID) - populate(objectMap, "osDiskId", c.OSDiskID) - populate(objectMap, "osType", c.OSType) - populate(objectMap, "statuses", c.Statuses) - populate(objectMap, "vmSize", c.VMSize) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type CustomImage. -func (c CustomImage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", c.ID) - populate(objectMap, "location", c.Location) - populate(objectMap, "name", c.Name) - populate(objectMap, "properties", c.Properties) - populate(objectMap, "tags", c.Tags) - populate(objectMap, "type", c.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type CustomImageFragment. -func (c CustomImageFragment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", c.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type CustomImageProperties. -func (c CustomImageProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "author", c.Author) - populateTimeRFC3339(objectMap, "creationDate", c.CreationDate) - populate(objectMap, "customImagePlan", c.CustomImagePlan) - populate(objectMap, "dataDiskStorageInfo", c.DataDiskStorageInfo) - populate(objectMap, "description", c.Description) - populate(objectMap, "isPlanAuthorized", c.IsPlanAuthorized) - populate(objectMap, "managedImageId", c.ManagedImageID) - populate(objectMap, "managedSnapshotId", c.ManagedSnapshotID) - populate(objectMap, "provisioningState", c.ProvisioningState) - populate(objectMap, "uniqueIdentifier", c.UniqueIdentifier) - populate(objectMap, "vm", c.VM) - populate(objectMap, "vhd", c.Vhd) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type CustomImageProperties. -func (c *CustomImageProperties) UnmarshalJSON(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 "author": - err = unpopulate(val, "Author", &c.Author) - delete(rawMsg, key) - case "creationDate": - err = unpopulateTimeRFC3339(val, "CreationDate", &c.CreationDate) - delete(rawMsg, key) - case "customImagePlan": - err = unpopulate(val, "CustomImagePlan", &c.CustomImagePlan) - delete(rawMsg, key) - case "dataDiskStorageInfo": - err = unpopulate(val, "DataDiskStorageInfo", &c.DataDiskStorageInfo) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &c.Description) - delete(rawMsg, key) - case "isPlanAuthorized": - err = unpopulate(val, "IsPlanAuthorized", &c.IsPlanAuthorized) - delete(rawMsg, key) - case "managedImageId": - err = unpopulate(val, "ManagedImageID", &c.ManagedImageID) - delete(rawMsg, key) - case "managedSnapshotId": - err = unpopulate(val, "ManagedSnapshotID", &c.ManagedSnapshotID) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) - delete(rawMsg, key) - case "uniqueIdentifier": - err = unpopulate(val, "UniqueIdentifier", &c.UniqueIdentifier) - delete(rawMsg, key) - case "vm": - err = unpopulate(val, "VM", &c.VM) - delete(rawMsg, key) - case "vhd": - err = unpopulate(val, "Vhd", &c.Vhd) - 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]interface{}) - populate(objectMap, "id", d.ID) - populate(objectMap, "location", d.Location) - populate(objectMap, "name", d.Name) - populate(objectMap, "properties", d.Properties) - populate(objectMap, "tags", d.Tags) - populate(objectMap, "type", d.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type DiskFragment. -func (d DiskFragment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", d.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type DiskProperties. -func (d DiskProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdDate", d.CreatedDate) - populate(objectMap, "diskBlobName", d.DiskBlobName) - populate(objectMap, "diskSizeGiB", d.DiskSizeGiB) - populate(objectMap, "diskType", d.DiskType) - populate(objectMap, "diskUri", d.DiskURI) - populate(objectMap, "hostCaching", d.HostCaching) - populate(objectMap, "leasedByLabVmId", d.LeasedByLabVMID) - populate(objectMap, "managedDiskId", d.ManagedDiskID) - populate(objectMap, "provisioningState", d.ProvisioningState) - populate(objectMap, "storageAccountId", d.StorageAccountID) - populate(objectMap, "uniqueIdentifier", d.UniqueIdentifier) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DiskProperties. -func (d *DiskProperties) UnmarshalJSON(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 "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &d.CreatedDate) - delete(rawMsg, key) - case "diskBlobName": - err = unpopulate(val, "DiskBlobName", &d.DiskBlobName) - delete(rawMsg, key) - case "diskSizeGiB": - err = unpopulate(val, "DiskSizeGiB", &d.DiskSizeGiB) - delete(rawMsg, key) - case "diskType": - err = unpopulate(val, "DiskType", &d.DiskType) - delete(rawMsg, key) - case "diskUri": - err = unpopulate(val, "DiskURI", &d.DiskURI) - delete(rawMsg, key) - case "hostCaching": - err = unpopulate(val, "HostCaching", &d.HostCaching) - delete(rawMsg, key) - case "leasedByLabVmId": - err = unpopulate(val, "LeasedByLabVMID", &d.LeasedByLabVMID) - delete(rawMsg, key) - case "managedDiskId": - err = unpopulate(val, "ManagedDiskID", &d.ManagedDiskID) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) - delete(rawMsg, key) - case "storageAccountId": - err = unpopulate(val, "StorageAccountID", &d.StorageAccountID) - delete(rawMsg, key) - case "uniqueIdentifier": - err = unpopulate(val, "UniqueIdentifier", &d.UniqueIdentifier) - 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 DtlEnvironment. -func (d DtlEnvironment) 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, "tags", d.Tags) - populate(objectMap, "type", d.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type DtlEnvironmentFragment. -func (d DtlEnvironmentFragment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", d.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type EnvironmentDeploymentProperties. -func (e EnvironmentDeploymentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "armTemplateId", e.ArmTemplateID) - populate(objectMap, "parameters", e.Parameters) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type EvaluatePoliciesRequest. -func (e EvaluatePoliciesRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "policies", e.Policies) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ExportResourceUsageParameters. -func (e ExportResourceUsageParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "blobStorageAbsoluteSasUri", e.BlobStorageAbsoluteSasURI) - populateTimeRFC3339(objectMap, "usageStartDate", e.UsageStartDate) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExportResourceUsageParameters. -func (e *ExportResourceUsageParameters) UnmarshalJSON(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 "blobStorageAbsoluteSasUri": - err = unpopulate(val, "BlobStorageAbsoluteSasURI", &e.BlobStorageAbsoluteSasURI) - delete(rawMsg, key) - case "usageStartDate": - err = unpopulateTimeRFC3339(val, "UsageStartDate", &e.UsageStartDate) - 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 Formula. -func (f Formula) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", f.ID) - populate(objectMap, "location", f.Location) - populate(objectMap, "name", f.Name) - populate(objectMap, "properties", f.Properties) - populate(objectMap, "tags", f.Tags) - populate(objectMap, "type", f.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type FormulaFragment. -func (f FormulaFragment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", f.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type FormulaProperties. -func (f FormulaProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "author", f.Author) - populateTimeRFC3339(objectMap, "creationDate", f.CreationDate) - populate(objectMap, "description", f.Description) - populate(objectMap, "formulaContent", f.FormulaContent) - populate(objectMap, "osType", f.OSType) - populate(objectMap, "provisioningState", f.ProvisioningState) - populate(objectMap, "uniqueIdentifier", f.UniqueIdentifier) - populate(objectMap, "vm", f.VM) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type FormulaProperties. -func (f *FormulaProperties) UnmarshalJSON(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 "author": - err = unpopulate(val, "Author", &f.Author) - delete(rawMsg, key) - case "creationDate": - err = unpopulateTimeRFC3339(val, "CreationDate", &f.CreationDate) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &f.Description) - delete(rawMsg, key) - case "formulaContent": - err = unpopulate(val, "FormulaContent", &f.FormulaContent) - delete(rawMsg, key) - case "osType": - err = unpopulate(val, "OSType", &f.OSType) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &f.ProvisioningState) - delete(rawMsg, key) - case "uniqueIdentifier": - err = unpopulate(val, "UniqueIdentifier", &f.UniqueIdentifier) - delete(rawMsg, key) - case "vm": - err = unpopulate(val, "VM", &f.VM) - 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 GalleryImage. -func (g GalleryImage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", g.ID) - populate(objectMap, "location", g.Location) - populate(objectMap, "name", g.Name) - populate(objectMap, "properties", g.Properties) - populate(objectMap, "tags", g.Tags) - populate(objectMap, "type", g.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type GalleryImageProperties. -func (g GalleryImageProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "author", g.Author) - populateTimeRFC3339(objectMap, "createdDate", g.CreatedDate) - populate(objectMap, "description", g.Description) - populate(objectMap, "enabled", g.Enabled) - populate(objectMap, "icon", g.Icon) - populate(objectMap, "imageReference", g.ImageReference) - populate(objectMap, "isPlanAuthorized", g.IsPlanAuthorized) - populate(objectMap, "planId", g.PlanID) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type GalleryImageProperties. -func (g *GalleryImageProperties) UnmarshalJSON(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 "author": - err = unpopulate(val, "Author", &g.Author) - delete(rawMsg, key) - case "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &g.CreatedDate) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &g.Description) - delete(rawMsg, key) - case "enabled": - err = unpopulate(val, "Enabled", &g.Enabled) - delete(rawMsg, key) - case "icon": - err = unpopulate(val, "Icon", &g.Icon) - delete(rawMsg, key) - case "imageReference": - err = unpopulate(val, "ImageReference", &g.ImageReference) - delete(rawMsg, key) - case "isPlanAuthorized": - err = unpopulate(val, "IsPlanAuthorized", &g.IsPlanAuthorized) - delete(rawMsg, key) - case "planId": - err = unpopulate(val, "PlanID", &g.PlanID) - 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 GenerateArmTemplateRequest. -func (g GenerateArmTemplateRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "fileUploadOptions", g.FileUploadOptions) - populate(objectMap, "location", g.Location) - populate(objectMap, "parameters", g.Parameters) - populate(objectMap, "virtualMachineName", g.VirtualMachineName) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Lab. -func (l Lab) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", l.ID) - populate(objectMap, "location", l.Location) - populate(objectMap, "name", l.Name) - populate(objectMap, "properties", l.Properties) - populate(objectMap, "tags", l.Tags) - populate(objectMap, "type", l.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type LabAnnouncementProperties. -func (l LabAnnouncementProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "enabled", l.Enabled) - populateTimeRFC3339(objectMap, "expirationDate", l.ExpirationDate) - populate(objectMap, "expired", l.Expired) - populate(objectMap, "markdown", l.Markdown) - populate(objectMap, "provisioningState", l.ProvisioningState) - populate(objectMap, "title", l.Title) - populate(objectMap, "uniqueIdentifier", l.UniqueIdentifier) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type LabAnnouncementProperties. -func (l *LabAnnouncementProperties) UnmarshalJSON(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 "enabled": - err = unpopulate(val, "Enabled", &l.Enabled) - delete(rawMsg, key) - case "expirationDate": - err = unpopulateTimeRFC3339(val, "ExpirationDate", &l.ExpirationDate) - delete(rawMsg, key) - case "expired": - err = unpopulate(val, "Expired", &l.Expired) - delete(rawMsg, key) - case "markdown": - err = unpopulate(val, "Markdown", &l.Markdown) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &l.ProvisioningState) - delete(rawMsg, key) - case "title": - err = unpopulate(val, "Title", &l.Title) - delete(rawMsg, key) - case "uniqueIdentifier": - err = unpopulate(val, "UniqueIdentifier", &l.UniqueIdentifier) - 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 LabCost. -func (l LabCost) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", l.ID) - populate(objectMap, "location", l.Location) - populate(objectMap, "name", l.Name) - populate(objectMap, "properties", l.Properties) - populate(objectMap, "tags", l.Tags) - populate(objectMap, "type", l.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type LabCostDetailsProperties. -func (l LabCostDetailsProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "cost", l.Cost) - populate(objectMap, "costType", l.CostType) - populateTimeRFC3339(objectMap, "date", l.Date) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type LabCostDetailsProperties. -func (l *LabCostDetailsProperties) UnmarshalJSON(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 "cost": - err = unpopulate(val, "Cost", &l.Cost) - delete(rawMsg, key) - case "costType": - err = unpopulate(val, "CostType", &l.CostType) - delete(rawMsg, key) - case "date": - err = unpopulateTimeRFC3339(val, "Date", &l.Date) - 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 LabCostProperties. -func (l LabCostProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdDate", l.CreatedDate) - populate(objectMap, "currencyCode", l.CurrencyCode) - populateTimeRFC3339(objectMap, "endDateTime", l.EndDateTime) - populate(objectMap, "labCostDetails", l.LabCostDetails) - populate(objectMap, "labCostSummary", l.LabCostSummary) - populate(objectMap, "provisioningState", l.ProvisioningState) - populate(objectMap, "resourceCosts", l.ResourceCosts) - populateTimeRFC3339(objectMap, "startDateTime", l.StartDateTime) - populate(objectMap, "targetCost", l.TargetCost) - populate(objectMap, "uniqueIdentifier", l.UniqueIdentifier) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type LabCostProperties. -func (l *LabCostProperties) UnmarshalJSON(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 "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &l.CreatedDate) - delete(rawMsg, key) - case "currencyCode": - err = unpopulate(val, "CurrencyCode", &l.CurrencyCode) - delete(rawMsg, key) - case "endDateTime": - err = unpopulateTimeRFC3339(val, "EndDateTime", &l.EndDateTime) - delete(rawMsg, key) - case "labCostDetails": - err = unpopulate(val, "LabCostDetails", &l.LabCostDetails) - delete(rawMsg, key) - case "labCostSummary": - err = unpopulate(val, "LabCostSummary", &l.LabCostSummary) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &l.ProvisioningState) - delete(rawMsg, key) - case "resourceCosts": - err = unpopulate(val, "ResourceCosts", &l.ResourceCosts) - delete(rawMsg, key) - case "startDateTime": - err = unpopulateTimeRFC3339(val, "StartDateTime", &l.StartDateTime) - delete(rawMsg, key) - case "targetCost": - err = unpopulate(val, "TargetCost", &l.TargetCost) - delete(rawMsg, key) - case "uniqueIdentifier": - err = unpopulate(val, "UniqueIdentifier", &l.UniqueIdentifier) - 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 LabFragment. -func (l LabFragment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", l.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type LabProperties. -func (l LabProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "announcement", l.Announcement) - populate(objectMap, "artifactsStorageAccount", l.ArtifactsStorageAccount) - populateTimeRFC3339(objectMap, "createdDate", l.CreatedDate) - populate(objectMap, "defaultPremiumStorageAccount", l.DefaultPremiumStorageAccount) - populate(objectMap, "defaultStorageAccount", l.DefaultStorageAccount) - populate(objectMap, "environmentPermission", l.EnvironmentPermission) - populate(objectMap, "extendedProperties", l.ExtendedProperties) - populate(objectMap, "labStorageType", l.LabStorageType) - populate(objectMap, "loadBalancerId", l.LoadBalancerID) - populate(objectMap, "mandatoryArtifactsResourceIdsLinux", l.MandatoryArtifactsResourceIDsLinux) - populate(objectMap, "mandatoryArtifactsResourceIdsWindows", l.MandatoryArtifactsResourceIDsWindows) - populate(objectMap, "networkSecurityGroupId", l.NetworkSecurityGroupID) - populate(objectMap, "premiumDataDiskStorageAccount", l.PremiumDataDiskStorageAccount) - populate(objectMap, "premiumDataDisks", l.PremiumDataDisks) - populate(objectMap, "provisioningState", l.ProvisioningState) - populate(objectMap, "publicIpId", l.PublicIPID) - populate(objectMap, "support", l.Support) - populate(objectMap, "uniqueIdentifier", l.UniqueIdentifier) - populate(objectMap, "vmCreationResourceGroup", l.VMCreationResourceGroup) - populate(objectMap, "vaultName", l.VaultName) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type LabProperties. -func (l *LabProperties) UnmarshalJSON(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 "announcement": - err = unpopulate(val, "Announcement", &l.Announcement) - delete(rawMsg, key) - case "artifactsStorageAccount": - err = unpopulate(val, "ArtifactsStorageAccount", &l.ArtifactsStorageAccount) - delete(rawMsg, key) - case "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &l.CreatedDate) - delete(rawMsg, key) - case "defaultPremiumStorageAccount": - err = unpopulate(val, "DefaultPremiumStorageAccount", &l.DefaultPremiumStorageAccount) - delete(rawMsg, key) - case "defaultStorageAccount": - err = unpopulate(val, "DefaultStorageAccount", &l.DefaultStorageAccount) - delete(rawMsg, key) - case "environmentPermission": - err = unpopulate(val, "EnvironmentPermission", &l.EnvironmentPermission) - delete(rawMsg, key) - case "extendedProperties": - err = unpopulate(val, "ExtendedProperties", &l.ExtendedProperties) - delete(rawMsg, key) - case "labStorageType": - err = unpopulate(val, "LabStorageType", &l.LabStorageType) - delete(rawMsg, key) - case "loadBalancerId": - err = unpopulate(val, "LoadBalancerID", &l.LoadBalancerID) - delete(rawMsg, key) - case "mandatoryArtifactsResourceIdsLinux": - err = unpopulate(val, "MandatoryArtifactsResourceIDsLinux", &l.MandatoryArtifactsResourceIDsLinux) - delete(rawMsg, key) - case "mandatoryArtifactsResourceIdsWindows": - err = unpopulate(val, "MandatoryArtifactsResourceIDsWindows", &l.MandatoryArtifactsResourceIDsWindows) - delete(rawMsg, key) - case "networkSecurityGroupId": - err = unpopulate(val, "NetworkSecurityGroupID", &l.NetworkSecurityGroupID) - delete(rawMsg, key) - case "premiumDataDiskStorageAccount": - err = unpopulate(val, "PremiumDataDiskStorageAccount", &l.PremiumDataDiskStorageAccount) - delete(rawMsg, key) - case "premiumDataDisks": - err = unpopulate(val, "PremiumDataDisks", &l.PremiumDataDisks) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &l.ProvisioningState) - delete(rawMsg, key) - case "publicIpId": - err = unpopulate(val, "PublicIPID", &l.PublicIPID) - delete(rawMsg, key) - case "support": - err = unpopulate(val, "Support", &l.Support) - delete(rawMsg, key) - case "uniqueIdentifier": - err = unpopulate(val, "UniqueIdentifier", &l.UniqueIdentifier) - delete(rawMsg, key) - case "vmCreationResourceGroup": - err = unpopulate(val, "VMCreationResourceGroup", &l.VMCreationResourceGroup) - delete(rawMsg, key) - case "vaultName": - err = unpopulate(val, "VaultName", &l.VaultName) - 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 LabVirtualMachine. -func (l LabVirtualMachine) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", l.ID) - populate(objectMap, "location", l.Location) - populate(objectMap, "name", l.Name) - populate(objectMap, "properties", l.Properties) - populate(objectMap, "tags", l.Tags) - populate(objectMap, "type", l.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type LabVirtualMachineCreationParameter. -func (l LabVirtualMachineCreationParameter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "location", l.Location) - populate(objectMap, "name", l.Name) - populate(objectMap, "properties", l.Properties) - populate(objectMap, "tags", l.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type LabVirtualMachineCreationParameterProperties. -func (l LabVirtualMachineCreationParameterProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "allowClaim", l.AllowClaim) - populate(objectMap, "artifacts", l.Artifacts) - populate(objectMap, "bulkCreationParameters", l.BulkCreationParameters) - populateTimeRFC3339(objectMap, "createdDate", l.CreatedDate) - populate(objectMap, "customImageId", l.CustomImageID) - populate(objectMap, "dataDiskParameters", l.DataDiskParameters) - populate(objectMap, "disallowPublicIpAddress", l.DisallowPublicIPAddress) - populate(objectMap, "environmentId", l.EnvironmentID) - populateTimeRFC3339(objectMap, "expirationDate", l.ExpirationDate) - populate(objectMap, "galleryImageReference", l.GalleryImageReference) - populate(objectMap, "isAuthenticationWithSshKey", l.IsAuthenticationWithSSHKey) - populate(objectMap, "labSubnetName", l.LabSubnetName) - populate(objectMap, "labVirtualNetworkId", l.LabVirtualNetworkID) - populate(objectMap, "networkInterface", l.NetworkInterface) - populate(objectMap, "notes", l.Notes) - populate(objectMap, "ownerObjectId", l.OwnerObjectID) - populate(objectMap, "ownerUserPrincipalName", l.OwnerUserPrincipalName) - populate(objectMap, "password", l.Password) - populate(objectMap, "planId", l.PlanID) - populate(objectMap, "sshKey", l.SSHKey) - populate(objectMap, "scheduleParameters", l.ScheduleParameters) - populate(objectMap, "size", l.Size) - populate(objectMap, "storageType", l.StorageType) - populate(objectMap, "userName", l.UserName) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type LabVirtualMachineCreationParameterProperties. -func (l *LabVirtualMachineCreationParameterProperties) UnmarshalJSON(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 "allowClaim": - err = unpopulate(val, "AllowClaim", &l.AllowClaim) - delete(rawMsg, key) - case "artifacts": - err = unpopulate(val, "Artifacts", &l.Artifacts) - delete(rawMsg, key) - case "bulkCreationParameters": - err = unpopulate(val, "BulkCreationParameters", &l.BulkCreationParameters) - delete(rawMsg, key) - case "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &l.CreatedDate) - delete(rawMsg, key) - case "customImageId": - err = unpopulate(val, "CustomImageID", &l.CustomImageID) - delete(rawMsg, key) - case "dataDiskParameters": - err = unpopulate(val, "DataDiskParameters", &l.DataDiskParameters) - delete(rawMsg, key) - case "disallowPublicIpAddress": - err = unpopulate(val, "DisallowPublicIPAddress", &l.DisallowPublicIPAddress) - delete(rawMsg, key) - case "environmentId": - err = unpopulate(val, "EnvironmentID", &l.EnvironmentID) - delete(rawMsg, key) - case "expirationDate": - err = unpopulateTimeRFC3339(val, "ExpirationDate", &l.ExpirationDate) - delete(rawMsg, key) - case "galleryImageReference": - err = unpopulate(val, "GalleryImageReference", &l.GalleryImageReference) - delete(rawMsg, key) - case "isAuthenticationWithSshKey": - err = unpopulate(val, "IsAuthenticationWithSSHKey", &l.IsAuthenticationWithSSHKey) - delete(rawMsg, key) - case "labSubnetName": - err = unpopulate(val, "LabSubnetName", &l.LabSubnetName) - delete(rawMsg, key) - case "labVirtualNetworkId": - err = unpopulate(val, "LabVirtualNetworkID", &l.LabVirtualNetworkID) - delete(rawMsg, key) - case "networkInterface": - err = unpopulate(val, "NetworkInterface", &l.NetworkInterface) - delete(rawMsg, key) - case "notes": - err = unpopulate(val, "Notes", &l.Notes) - delete(rawMsg, key) - case "ownerObjectId": - err = unpopulate(val, "OwnerObjectID", &l.OwnerObjectID) - delete(rawMsg, key) - case "ownerUserPrincipalName": - err = unpopulate(val, "OwnerUserPrincipalName", &l.OwnerUserPrincipalName) - delete(rawMsg, key) - case "password": - err = unpopulate(val, "Password", &l.Password) - delete(rawMsg, key) - case "planId": - err = unpopulate(val, "PlanID", &l.PlanID) - delete(rawMsg, key) - case "sshKey": - err = unpopulate(val, "SSHKey", &l.SSHKey) - delete(rawMsg, key) - case "scheduleParameters": - err = unpopulate(val, "ScheduleParameters", &l.ScheduleParameters) - delete(rawMsg, key) - case "size": - err = unpopulate(val, "Size", &l.Size) - delete(rawMsg, key) - case "storageType": - err = unpopulate(val, "StorageType", &l.StorageType) - delete(rawMsg, key) - case "userName": - err = unpopulate(val, "UserName", &l.UserName) - 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 LabVirtualMachineFragment. -func (l LabVirtualMachineFragment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", l.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type LabVirtualMachineProperties. -func (l LabVirtualMachineProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "allowClaim", l.AllowClaim) - populate(objectMap, "applicableSchedule", l.ApplicableSchedule) - populate(objectMap, "artifactDeploymentStatus", l.ArtifactDeploymentStatus) - populate(objectMap, "artifacts", l.Artifacts) - populate(objectMap, "computeId", l.ComputeID) - populate(objectMap, "computeVm", l.ComputeVM) - populate(objectMap, "createdByUser", l.CreatedByUser) - populate(objectMap, "createdByUserId", l.CreatedByUserID) - populateTimeRFC3339(objectMap, "createdDate", l.CreatedDate) - populate(objectMap, "customImageId", l.CustomImageID) - populate(objectMap, "dataDiskParameters", l.DataDiskParameters) - populate(objectMap, "disallowPublicIpAddress", l.DisallowPublicIPAddress) - populate(objectMap, "environmentId", l.EnvironmentID) - populateTimeRFC3339(objectMap, "expirationDate", l.ExpirationDate) - populate(objectMap, "fqdn", l.Fqdn) - populate(objectMap, "galleryImageReference", l.GalleryImageReference) - populate(objectMap, "isAuthenticationWithSshKey", l.IsAuthenticationWithSSHKey) - populate(objectMap, "labSubnetName", l.LabSubnetName) - populate(objectMap, "labVirtualNetworkId", l.LabVirtualNetworkID) - populate(objectMap, "lastKnownPowerState", l.LastKnownPowerState) - populate(objectMap, "networkInterface", l.NetworkInterface) - populate(objectMap, "notes", l.Notes) - populate(objectMap, "osType", l.OSType) - populate(objectMap, "ownerObjectId", l.OwnerObjectID) - populate(objectMap, "ownerUserPrincipalName", l.OwnerUserPrincipalName) - populate(objectMap, "password", l.Password) - populate(objectMap, "planId", l.PlanID) - populate(objectMap, "provisioningState", l.ProvisioningState) - populate(objectMap, "sshKey", l.SSHKey) - populate(objectMap, "scheduleParameters", l.ScheduleParameters) - populate(objectMap, "size", l.Size) - populate(objectMap, "storageType", l.StorageType) - populate(objectMap, "uniqueIdentifier", l.UniqueIdentifier) - populate(objectMap, "userName", l.UserName) - populate(objectMap, "virtualMachineCreationSource", l.VirtualMachineCreationSource) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type LabVirtualMachineProperties. -func (l *LabVirtualMachineProperties) UnmarshalJSON(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 "allowClaim": - err = unpopulate(val, "AllowClaim", &l.AllowClaim) - delete(rawMsg, key) - case "applicableSchedule": - err = unpopulate(val, "ApplicableSchedule", &l.ApplicableSchedule) - delete(rawMsg, key) - case "artifactDeploymentStatus": - err = unpopulate(val, "ArtifactDeploymentStatus", &l.ArtifactDeploymentStatus) - delete(rawMsg, key) - case "artifacts": - err = unpopulate(val, "Artifacts", &l.Artifacts) - delete(rawMsg, key) - case "computeId": - err = unpopulate(val, "ComputeID", &l.ComputeID) - delete(rawMsg, key) - case "computeVm": - err = unpopulate(val, "ComputeVM", &l.ComputeVM) - delete(rawMsg, key) - case "createdByUser": - err = unpopulate(val, "CreatedByUser", &l.CreatedByUser) - delete(rawMsg, key) - case "createdByUserId": - err = unpopulate(val, "CreatedByUserID", &l.CreatedByUserID) - delete(rawMsg, key) - case "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &l.CreatedDate) - delete(rawMsg, key) - case "customImageId": - err = unpopulate(val, "CustomImageID", &l.CustomImageID) - delete(rawMsg, key) - case "dataDiskParameters": - err = unpopulate(val, "DataDiskParameters", &l.DataDiskParameters) - delete(rawMsg, key) - case "disallowPublicIpAddress": - err = unpopulate(val, "DisallowPublicIPAddress", &l.DisallowPublicIPAddress) - delete(rawMsg, key) - case "environmentId": - err = unpopulate(val, "EnvironmentID", &l.EnvironmentID) - delete(rawMsg, key) - case "expirationDate": - err = unpopulateTimeRFC3339(val, "ExpirationDate", &l.ExpirationDate) - delete(rawMsg, key) - case "fqdn": - err = unpopulate(val, "Fqdn", &l.Fqdn) - delete(rawMsg, key) - case "galleryImageReference": - err = unpopulate(val, "GalleryImageReference", &l.GalleryImageReference) - delete(rawMsg, key) - case "isAuthenticationWithSshKey": - err = unpopulate(val, "IsAuthenticationWithSSHKey", &l.IsAuthenticationWithSSHKey) - delete(rawMsg, key) - case "labSubnetName": - err = unpopulate(val, "LabSubnetName", &l.LabSubnetName) - delete(rawMsg, key) - case "labVirtualNetworkId": - err = unpopulate(val, "LabVirtualNetworkID", &l.LabVirtualNetworkID) - delete(rawMsg, key) - case "lastKnownPowerState": - err = unpopulate(val, "LastKnownPowerState", &l.LastKnownPowerState) - delete(rawMsg, key) - case "networkInterface": - err = unpopulate(val, "NetworkInterface", &l.NetworkInterface) - delete(rawMsg, key) - case "notes": - err = unpopulate(val, "Notes", &l.Notes) - delete(rawMsg, key) - case "osType": - err = unpopulate(val, "OSType", &l.OSType) - delete(rawMsg, key) - case "ownerObjectId": - err = unpopulate(val, "OwnerObjectID", &l.OwnerObjectID) - delete(rawMsg, key) - case "ownerUserPrincipalName": - err = unpopulate(val, "OwnerUserPrincipalName", &l.OwnerUserPrincipalName) - delete(rawMsg, key) - case "password": - err = unpopulate(val, "Password", &l.Password) - delete(rawMsg, key) - case "planId": - err = unpopulate(val, "PlanID", &l.PlanID) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &l.ProvisioningState) - delete(rawMsg, key) - case "sshKey": - err = unpopulate(val, "SSHKey", &l.SSHKey) - delete(rawMsg, key) - case "scheduleParameters": - err = unpopulate(val, "ScheduleParameters", &l.ScheduleParameters) - delete(rawMsg, key) - case "size": - err = unpopulate(val, "Size", &l.Size) - delete(rawMsg, key) - case "storageType": - err = unpopulate(val, "StorageType", &l.StorageType) - delete(rawMsg, key) - case "uniqueIdentifier": - err = unpopulate(val, "UniqueIdentifier", &l.UniqueIdentifier) - delete(rawMsg, key) - case "userName": - err = unpopulate(val, "UserName", &l.UserName) - delete(rawMsg, key) - case "virtualMachineCreationSource": - err = unpopulate(val, "VirtualMachineCreationSource", &l.VirtualMachineCreationSource) - 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 NotificationChannel. -func (n NotificationChannel) 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, "tags", n.Tags) - populate(objectMap, "type", n.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type NotificationChannelFragment. -func (n NotificationChannelFragment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", n.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type NotificationChannelProperties. -func (n NotificationChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdDate", n.CreatedDate) - populate(objectMap, "description", n.Description) - populate(objectMap, "emailRecipient", n.EmailRecipient) - populate(objectMap, "events", n.Events) - populate(objectMap, "notificationLocale", n.NotificationLocale) - populate(objectMap, "provisioningState", n.ProvisioningState) - populate(objectMap, "uniqueIdentifier", n.UniqueIdentifier) - populate(objectMap, "webHookUrl", n.WebHookURL) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type NotificationChannelProperties. -func (n *NotificationChannelProperties) UnmarshalJSON(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 "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &n.CreatedDate) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &n.Description) - delete(rawMsg, key) - case "emailRecipient": - err = unpopulate(val, "EmailRecipient", &n.EmailRecipient) - delete(rawMsg, key) - case "events": - err = unpopulate(val, "Events", &n.Events) - delete(rawMsg, key) - case "notificationLocale": - err = unpopulate(val, "NotificationLocale", &n.NotificationLocale) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &n.ProvisioningState) - delete(rawMsg, key) - case "uniqueIdentifier": - err = unpopulate(val, "UniqueIdentifier", &n.UniqueIdentifier) - delete(rawMsg, key) - case "webHookUrl": - err = unpopulate(val, "WebHookURL", &n.WebHookURL) - 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 Policy. -func (p Policy) 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, "tags", p.Tags) - populate(objectMap, "type", p.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type PolicyFragment. -func (p PolicyFragment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", p.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type PolicyProperties. -func (p PolicyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdDate", p.CreatedDate) - populate(objectMap, "description", p.Description) - populate(objectMap, "evaluatorType", p.EvaluatorType) - populate(objectMap, "factData", p.FactData) - populate(objectMap, "factName", p.FactName) - populate(objectMap, "provisioningState", p.ProvisioningState) - populate(objectMap, "status", p.Status) - populate(objectMap, "threshold", p.Threshold) - populate(objectMap, "uniqueIdentifier", p.UniqueIdentifier) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyProperties. -func (p *PolicyProperties) UnmarshalJSON(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 "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &p.CreatedDate) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &p.Description) - delete(rawMsg, key) - case "evaluatorType": - err = unpopulate(val, "EvaluatorType", &p.EvaluatorType) - delete(rawMsg, key) - case "factData": - err = unpopulate(val, "FactData", &p.FactData) - delete(rawMsg, key) - case "factName": - err = unpopulate(val, "FactName", &p.FactName) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &p.Status) - delete(rawMsg, key) - case "threshold": - err = unpopulate(val, "Threshold", &p.Threshold) - delete(rawMsg, key) - case "uniqueIdentifier": - err = unpopulate(val, "UniqueIdentifier", &p.UniqueIdentifier) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", r.ID) - populate(objectMap, "location", r.Location) - populate(objectMap, "name", r.Name) - populate(objectMap, "tags", r.Tags) - populate(objectMap, "type", r.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Schedule. -func (s Schedule) 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, "tags", s.Tags) - populate(objectMap, "type", s.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ScheduleCreationParameter. -func (s ScheduleCreationParameter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "location", s.Location) - populate(objectMap, "name", s.Name) - populate(objectMap, "properties", s.Properties) - populate(objectMap, "tags", s.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ScheduleFragment. -func (s ScheduleFragment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", s.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ScheduleProperties. -func (s ScheduleProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdDate", s.CreatedDate) - populate(objectMap, "dailyRecurrence", s.DailyRecurrence) - populate(objectMap, "hourlyRecurrence", s.HourlyRecurrence) - populate(objectMap, "notificationSettings", s.NotificationSettings) - populate(objectMap, "provisioningState", s.ProvisioningState) - populate(objectMap, "status", s.Status) - populate(objectMap, "targetResourceId", s.TargetResourceID) - populate(objectMap, "taskType", s.TaskType) - populate(objectMap, "timeZoneId", s.TimeZoneID) - populate(objectMap, "uniqueIdentifier", s.UniqueIdentifier) - populate(objectMap, "weeklyRecurrence", s.WeeklyRecurrence) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ScheduleProperties. -func (s *ScheduleProperties) UnmarshalJSON(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 "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &s.CreatedDate) - delete(rawMsg, key) - case "dailyRecurrence": - err = unpopulate(val, "DailyRecurrence", &s.DailyRecurrence) - delete(rawMsg, key) - case "hourlyRecurrence": - err = unpopulate(val, "HourlyRecurrence", &s.HourlyRecurrence) - delete(rawMsg, key) - case "notificationSettings": - err = unpopulate(val, "NotificationSettings", &s.NotificationSettings) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &s.Status) - delete(rawMsg, key) - case "targetResourceId": - err = unpopulate(val, "TargetResourceID", &s.TargetResourceID) - delete(rawMsg, key) - case "taskType": - err = unpopulate(val, "TaskType", &s.TaskType) - delete(rawMsg, key) - case "timeZoneId": - err = unpopulate(val, "TimeZoneID", &s.TimeZoneID) - delete(rawMsg, key) - case "uniqueIdentifier": - err = unpopulate(val, "UniqueIdentifier", &s.UniqueIdentifier) - delete(rawMsg, key) - case "weeklyRecurrence": - err = unpopulate(val, "WeeklyRecurrence", &s.WeeklyRecurrence) - 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 Secret. -func (s Secret) 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, "tags", s.Tags) - populate(objectMap, "type", s.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type SecretFragment. -func (s SecretFragment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", s.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ServiceFabric. -func (s ServiceFabric) 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, "tags", s.Tags) - populate(objectMap, "type", s.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ServiceFabricFragment. -func (s ServiceFabricFragment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", s.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ServiceRunner. -func (s ServiceRunner) 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, "tags", s.Tags) - populate(objectMap, "type", s.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type SharedPublicIPAddressConfiguration. -func (s SharedPublicIPAddressConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "inboundNatRules", s.InboundNatRules) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type SubnetSharedPublicIPAddressConfiguration. -func (s SubnetSharedPublicIPAddressConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "allowedPorts", s.AllowedPorts) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TargetCostProperties. -func (t TargetCostProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "costThresholds", t.CostThresholds) - populateTimeRFC3339(objectMap, "cycleEndDateTime", t.CycleEndDateTime) - populateTimeRFC3339(objectMap, "cycleStartDateTime", t.CycleStartDateTime) - populate(objectMap, "cycleType", t.CycleType) - populate(objectMap, "status", t.Status) - populate(objectMap, "target", t.Target) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type TargetCostProperties. -func (t *TargetCostProperties) UnmarshalJSON(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 "costThresholds": - err = unpopulate(val, "CostThresholds", &t.CostThresholds) - delete(rawMsg, key) - case "cycleEndDateTime": - err = unpopulateTimeRFC3339(val, "CycleEndDateTime", &t.CycleEndDateTime) - delete(rawMsg, key) - case "cycleStartDateTime": - err = unpopulateTimeRFC3339(val, "CycleStartDateTime", &t.CycleStartDateTime) - delete(rawMsg, key) - case "cycleType": - err = unpopulate(val, "CycleType", &t.CycleType) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &t.Status) - delete(rawMsg, key) - case "target": - err = unpopulate(val, "Target", &t.Target) - 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 UpdateResource. -func (u UpdateResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", u.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type User. -func (u User) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", u.ID) - populate(objectMap, "location", u.Location) - populate(objectMap, "name", u.Name) - populate(objectMap, "properties", u.Properties) - populate(objectMap, "tags", u.Tags) - populate(objectMap, "type", u.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type UserFragment. -func (u UserFragment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", u.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type UserProperties. -func (u UserProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdDate", u.CreatedDate) - populate(objectMap, "identity", u.Identity) - populate(objectMap, "provisioningState", u.ProvisioningState) - populate(objectMap, "secretStore", u.SecretStore) - populate(objectMap, "uniqueIdentifier", u.UniqueIdentifier) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type UserProperties. -func (u *UserProperties) UnmarshalJSON(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 "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &u.CreatedDate) - delete(rawMsg, key) - case "identity": - err = unpopulate(val, "Identity", &u.Identity) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &u.ProvisioningState) - delete(rawMsg, key) - case "secretStore": - err = unpopulate(val, "SecretStore", &u.SecretStore) - delete(rawMsg, key) - case "uniqueIdentifier": - err = unpopulate(val, "UniqueIdentifier", &u.UniqueIdentifier) - 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 VirtualNetwork. -func (v VirtualNetwork) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", v.ID) - populate(objectMap, "location", v.Location) - populate(objectMap, "name", v.Name) - populate(objectMap, "properties", v.Properties) - populate(objectMap, "tags", v.Tags) - populate(objectMap, "type", v.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type VirtualNetworkFragment. -func (v VirtualNetworkFragment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", v.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type VirtualNetworkProperties. -func (v VirtualNetworkProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "allowedSubnets", v.AllowedSubnets) - populateTimeRFC3339(objectMap, "createdDate", v.CreatedDate) - populate(objectMap, "description", v.Description) - populate(objectMap, "externalProviderResourceId", v.ExternalProviderResourceID) - populate(objectMap, "externalSubnets", v.ExternalSubnets) - populate(objectMap, "provisioningState", v.ProvisioningState) - populate(objectMap, "subnetOverrides", v.SubnetOverrides) - populate(objectMap, "uniqueIdentifier", v.UniqueIdentifier) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworkProperties. -func (v *VirtualNetworkProperties) UnmarshalJSON(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 "allowedSubnets": - err = unpopulate(val, "AllowedSubnets", &v.AllowedSubnets) - delete(rawMsg, key) - case "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &v.CreatedDate) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &v.Description) - delete(rawMsg, key) - case "externalProviderResourceId": - err = unpopulate(val, "ExternalProviderResourceID", &v.ExternalProviderResourceID) - delete(rawMsg, key) - case "externalSubnets": - err = unpopulate(val, "ExternalSubnets", &v.ExternalSubnets) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) - delete(rawMsg, key) - case "subnetOverrides": - err = unpopulate(val, "SubnetOverrides", &v.SubnetOverrides) - delete(rawMsg, key) - case "uniqueIdentifier": - err = unpopulate(val, "UniqueIdentifier", &v.UniqueIdentifier) - 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 WeekDetails. -func (w WeekDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "time", w.Time) - populate(objectMap, "weekdays", w.Weekdays) - 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/dns/armdns/CHANGELOG.md b/sdk/resourcemanager/dns/armdns/CHANGELOG.md index b4c7be0b86fe..2c60438a4d5b 100644 --- a/sdk/resourcemanager/dns/armdns/CHANGELOG.md +++ b/sdk/resourcemanager/dns/armdns/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-28) +### 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/dns/armdns` 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/dns/armdns/README.md b/sdk/resourcemanager/dns/armdns/README.md index f9a3ab56341f..523758b9cb29 100644 --- a/sdk/resourcemanager/dns/armdns/README.md +++ b/sdk/resourcemanager/dns/armdns/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 DNS 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 DNS 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 := armdns.NewResourceReferenceClient(, cred, nil) +clientFactory, err := armdns.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 := armdns.NewResourceReferenceClient(, cred, &options) +clientFactory, err := armdns.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.NewRecordSetsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/dns/armdns/autorest.md b/sdk/resourcemanager/dns/armdns/autorest.md index 3cf263d9ae2d..0e4ad64c477b 100644 --- a/sdk/resourcemanager/dns/armdns/autorest.md +++ b/sdk/resourcemanager/dns/armdns/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/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/dns/armdns/client_factory.go b/sdk/resourcemanager/dns/armdns/client_factory.go new file mode 100644 index 000000000000..e42ec0173097 --- /dev/null +++ b/sdk/resourcemanager/dns/armdns/client_factory.go @@ -0,0 +1,54 @@ +//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 armdns + +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 - Specifies the Azure subscription ID, which uniquely identifies the 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) NewRecordSetsClient() *RecordSetsClient { + subClient, _ := NewRecordSetsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewZonesClient() *ZonesClient { + subClient, _ := NewZonesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewResourceReferenceClient() *ResourceReferenceClient { + subClient, _ := NewResourceReferenceClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/dns/armdns/zz_generated_constants.go b/sdk/resourcemanager/dns/armdns/constants.go similarity index 97% rename from sdk/resourcemanager/dns/armdns/zz_generated_constants.go rename to sdk/resourcemanager/dns/armdns/constants.go index d6394999e52b..e1f9a32b752a 100644 --- a/sdk/resourcemanager/dns/armdns/zz_generated_constants.go +++ b/sdk/resourcemanager/dns/armdns/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 armdns const ( moduleName = "armdns" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) type RecordType string diff --git a/sdk/resourcemanager/dns/armdns/go.mod b/sdk/resourcemanager/dns/armdns/go.mod index 90b1a0d5dc26..29c97d98f9a2 100644 --- a/sdk/resourcemanager/dns/armdns/go.mod +++ b/sdk/resourcemanager/dns/armdns/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns 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/dns/armdns/go.sum b/sdk/resourcemanager/dns/armdns/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/dns/armdns/go.sum +++ b/sdk/resourcemanager/dns/armdns/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/dns/armdns/zz_generated_models.go b/sdk/resourcemanager/dns/armdns/models.go similarity index 93% rename from sdk/resourcemanager/dns/armdns/zz_generated_models.go rename to sdk/resourcemanager/dns/armdns/models.go index fb5d6469486a..0308c8edd4b6 100644 --- a/sdk/resourcemanager/dns/armdns/zz_generated_models.go +++ b/sdk/resourcemanager/dns/armdns/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 armdns @@ -32,27 +33,6 @@ type CaaRecord struct { Value *string `json:"value,omitempty"` } -// CloudError - An error response from the service. -type CloudError struct { - // Cloud error body. - Error *CloudErrorBody `json:"error,omitempty"` -} - -// CloudErrorBody - An error response from the 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"` -} - // CnameRecord - A CNAME record. type CnameRecord struct { // The canonical name for this CNAME record. @@ -183,7 +163,8 @@ type RecordSetsClientGetOptions struct { // placeholder for future optional parameters } -// RecordSetsClientListAllByDNSZoneOptions contains the optional parameters for the RecordSetsClient.ListAllByDNSZone method. +// RecordSetsClientListAllByDNSZoneOptions contains the optional parameters for the RecordSetsClient.NewListAllByDNSZonePager +// method. type RecordSetsClientListAllByDNSZoneOptions struct { // The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is // specified, Enumeration will return only records that end with . @@ -192,7 +173,7 @@ type RecordSetsClientListAllByDNSZoneOptions struct { Top *int32 } -// RecordSetsClientListByDNSZoneOptions contains the optional parameters for the RecordSetsClient.ListByDNSZone method. +// RecordSetsClientListByDNSZoneOptions contains the optional parameters for the RecordSetsClient.NewListByDNSZonePager method. type RecordSetsClientListByDNSZoneOptions struct { // The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is // specified, Enumeration will return only records that end with . @@ -201,7 +182,7 @@ type RecordSetsClientListByDNSZoneOptions struct { Top *int32 } -// RecordSetsClientListByTypeOptions contains the optional parameters for the RecordSetsClient.ListByType method. +// RecordSetsClientListByTypeOptions contains the optional parameters for the RecordSetsClient.NewListByTypePager method. type RecordSetsClientListByTypeOptions struct { // The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is // specified, Enumeration will return only records that end with . @@ -416,13 +397,14 @@ type ZonesClientGetOptions struct { // placeholder for future optional parameters } -// ZonesClientListByResourceGroupOptions contains the optional parameters for the ZonesClient.ListByResourceGroup method. +// ZonesClientListByResourceGroupOptions contains the optional parameters for the ZonesClient.NewListByResourceGroupPager +// method. type ZonesClientListByResourceGroupOptions struct { // The maximum number of record sets to return. If not specified, returns up to 100 record sets. Top *int32 } -// ZonesClientListOptions contains the optional parameters for the ZonesClient.List method. +// ZonesClientListOptions contains the optional parameters for the ZonesClient.NewListPager method. type ZonesClientListOptions struct { // The maximum number of DNS zones to return. If not specified, returns up to 100 zones. Top *int32 diff --git a/sdk/resourcemanager/dns/armdns/models_serde.go b/sdk/resourcemanager/dns/armdns/models_serde.go new file mode 100644 index 000000000000..37a7b669b8ee --- /dev/null +++ b/sdk/resourcemanager/dns/armdns/models_serde.go @@ -0,0 +1,908 @@ +//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 armdns + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ARecord. +func (a ARecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ipv4Address", a.IPv4Address) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ARecord. +func (a *ARecord) UnmarshalJSON(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 "ipv4Address": + err = unpopulate(val, "IPv4Address", &a.IPv4Address) + 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 AaaaRecord. +func (a AaaaRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ipv6Address", a.IPv6Address) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AaaaRecord. +func (a *AaaaRecord) UnmarshalJSON(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 "ipv6Address": + err = unpopulate(val, "IPv6Address", &a.IPv6Address) + 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 CaaRecord. +func (c CaaRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "flags", c.Flags) + populate(objectMap, "tag", c.Tag) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CaaRecord. +func (c *CaaRecord) UnmarshalJSON(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 "flags": + err = unpopulate(val, "Flags", &c.Flags) + delete(rawMsg, key) + case "tag": + err = unpopulate(val, "Tag", &c.Tag) + 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 CnameRecord. +func (c CnameRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cname", c.Cname) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CnameRecord. +func (c *CnameRecord) UnmarshalJSON(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 "cname": + err = unpopulate(val, "Cname", &c.Cname) + 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 MxRecord. +func (m MxRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "exchange", m.Exchange) + populate(objectMap, "preference", m.Preference) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MxRecord. +func (m *MxRecord) UnmarshalJSON(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 "exchange": + err = unpopulate(val, "Exchange", &m.Exchange) + delete(rawMsg, key) + case "preference": + err = unpopulate(val, "Preference", &m.Preference) + 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 NsRecord. +func (n NsRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nsdname", n.Nsdname) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NsRecord. +func (n *NsRecord) UnmarshalJSON(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 "nsdname": + err = unpopulate(val, "Nsdname", &n.Nsdname) + 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 PtrRecord. +func (p PtrRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ptrdname", p.Ptrdname) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PtrRecord. +func (p *PtrRecord) UnmarshalJSON(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 "ptrdname": + err = unpopulate(val, "Ptrdname", &p.Ptrdname) + 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 RecordSet. +func (r RecordSet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", r.Etag) + 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 RecordSet. +func (r *RecordSet) UnmarshalJSON(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 "etag": + err = unpopulate(val, "Etag", &r.Etag) + delete(rawMsg, 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 RecordSetListResult. +func (r RecordSetListResult) 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 RecordSetListResult. +func (r *RecordSetListResult) UnmarshalJSON(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 RecordSetProperties. +func (r RecordSetProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ARecords", r.ARecords) + populate(objectMap, "AAAARecords", r.AaaaRecords) + populate(objectMap, "caaRecords", r.CaaRecords) + populate(objectMap, "CNAMERecord", r.CnameRecord) + populate(objectMap, "fqdn", r.Fqdn) + populate(objectMap, "metadata", r.Metadata) + populate(objectMap, "MXRecords", r.MxRecords) + populate(objectMap, "NSRecords", r.NsRecords) + populate(objectMap, "provisioningState", r.ProvisioningState) + populate(objectMap, "PTRRecords", r.PtrRecords) + populate(objectMap, "SOARecord", r.SoaRecord) + populate(objectMap, "SRVRecords", r.SrvRecords) + populate(objectMap, "TTL", r.TTL) + populate(objectMap, "targetResource", r.TargetResource) + populate(objectMap, "TXTRecords", r.TxtRecords) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecordSetProperties. +func (r *RecordSetProperties) UnmarshalJSON(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 "ARecords": + err = unpopulate(val, "ARecords", &r.ARecords) + delete(rawMsg, key) + case "AAAARecords": + err = unpopulate(val, "AaaaRecords", &r.AaaaRecords) + delete(rawMsg, key) + case "caaRecords": + err = unpopulate(val, "CaaRecords", &r.CaaRecords) + delete(rawMsg, key) + case "CNAMERecord": + err = unpopulate(val, "CnameRecord", &r.CnameRecord) + delete(rawMsg, key) + case "fqdn": + err = unpopulate(val, "Fqdn", &r.Fqdn) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &r.Metadata) + delete(rawMsg, key) + case "MXRecords": + err = unpopulate(val, "MxRecords", &r.MxRecords) + delete(rawMsg, key) + case "NSRecords": + err = unpopulate(val, "NsRecords", &r.NsRecords) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + delete(rawMsg, key) + case "PTRRecords": + err = unpopulate(val, "PtrRecords", &r.PtrRecords) + delete(rawMsg, key) + case "SOARecord": + err = unpopulate(val, "SoaRecord", &r.SoaRecord) + delete(rawMsg, key) + case "SRVRecords": + err = unpopulate(val, "SrvRecords", &r.SrvRecords) + delete(rawMsg, key) + case "TTL": + err = unpopulate(val, "TTL", &r.TTL) + delete(rawMsg, key) + case "targetResource": + err = unpopulate(val, "TargetResource", &r.TargetResource) + delete(rawMsg, key) + case "TXTRecords": + err = unpopulate(val, "TxtRecords", &r.TxtRecords) + 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 RecordSetUpdateParameters. +func (r RecordSetUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "RecordSet", r.RecordSet) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecordSetUpdateParameters. +func (r *RecordSetUpdateParameters) UnmarshalJSON(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 "RecordSet": + err = unpopulate(val, "RecordSet", &r.RecordSet) + 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, "location", r.Location) + populate(objectMap, "name", r.Name) + 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 "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 ResourceReference. +func (r ResourceReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dnsResources", r.DNSResources) + populate(objectMap, "targetResource", r.TargetResource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReference. +func (r *ResourceReference) UnmarshalJSON(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 "dnsResources": + err = unpopulate(val, "DNSResources", &r.DNSResources) + delete(rawMsg, key) + case "targetResource": + err = unpopulate(val, "TargetResource", &r.TargetResource) + 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 ResourceReferenceRequest. +func (r ResourceReferenceRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", r.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReferenceRequest. +func (r *ResourceReferenceRequest) UnmarshalJSON(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 "properties": + err = unpopulate(val, "Properties", &r.Properties) + 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 ResourceReferenceRequestProperties. +func (r ResourceReferenceRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "targetResources", r.TargetResources) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReferenceRequestProperties. +func (r *ResourceReferenceRequestProperties) UnmarshalJSON(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 "targetResources": + err = unpopulate(val, "TargetResources", &r.TargetResources) + 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 ResourceReferenceResult. +func (r ResourceReferenceResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", r.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReferenceResult. +func (r *ResourceReferenceResult) UnmarshalJSON(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 "properties": + err = unpopulate(val, "Properties", &r.Properties) + 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 ResourceReferenceResultProperties. +func (r ResourceReferenceResultProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dnsResourceReferences", r.DNSResourceReferences) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReferenceResultProperties. +func (r *ResourceReferenceResultProperties) UnmarshalJSON(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 "dnsResourceReferences": + err = unpopulate(val, "DNSResourceReferences", &r.DNSResourceReferences) + 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 SoaRecord. +func (s SoaRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "email", s.Email) + populate(objectMap, "expireTime", s.ExpireTime) + populate(objectMap, "host", s.Host) + populate(objectMap, "minimumTTL", s.MinimumTTL) + populate(objectMap, "refreshTime", s.RefreshTime) + populate(objectMap, "retryTime", s.RetryTime) + populate(objectMap, "serialNumber", s.SerialNumber) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SoaRecord. +func (s *SoaRecord) UnmarshalJSON(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 "email": + err = unpopulate(val, "Email", &s.Email) + delete(rawMsg, key) + case "expireTime": + err = unpopulate(val, "ExpireTime", &s.ExpireTime) + delete(rawMsg, key) + case "host": + err = unpopulate(val, "Host", &s.Host) + delete(rawMsg, key) + case "minimumTTL": + err = unpopulate(val, "MinimumTTL", &s.MinimumTTL) + delete(rawMsg, key) + case "refreshTime": + err = unpopulate(val, "RefreshTime", &s.RefreshTime) + delete(rawMsg, key) + case "retryTime": + err = unpopulate(val, "RetryTime", &s.RetryTime) + delete(rawMsg, key) + case "serialNumber": + err = unpopulate(val, "SerialNumber", &s.SerialNumber) + 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 SrvRecord. +func (s SrvRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "port", s.Port) + populate(objectMap, "priority", s.Priority) + populate(objectMap, "target", s.Target) + populate(objectMap, "weight", s.Weight) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SrvRecord. +func (s *SrvRecord) UnmarshalJSON(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 "port": + err = unpopulate(val, "Port", &s.Port) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &s.Priority) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &s.Target) + delete(rawMsg, key) + case "weight": + err = unpopulate(val, "Weight", &s.Weight) + 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 TxtRecord. +func (t TxtRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TxtRecord. +func (t *TxtRecord) UnmarshalJSON(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 "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 Zone. +func (z Zone) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", z.Etag) + populate(objectMap, "id", z.ID) + populate(objectMap, "location", z.Location) + populate(objectMap, "name", z.Name) + populate(objectMap, "properties", z.Properties) + populate(objectMap, "tags", z.Tags) + populate(objectMap, "type", z.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Zone. +func (z *Zone) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &z.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &z.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &z.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &z.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &z.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &z.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &z.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ZoneListResult. +func (z ZoneListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", z.NextLink) + populate(objectMap, "value", z.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ZoneListResult. +func (z *ZoneListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &z.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &z.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ZoneProperties. +func (z ZoneProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "maxNumberOfRecordSets", z.MaxNumberOfRecordSets) + populate(objectMap, "maxNumberOfRecordsPerRecordSet", z.MaxNumberOfRecordsPerRecordSet) + populate(objectMap, "nameServers", z.NameServers) + populate(objectMap, "numberOfRecordSets", z.NumberOfRecordSets) + populate(objectMap, "registrationVirtualNetworks", z.RegistrationVirtualNetworks) + populate(objectMap, "resolutionVirtualNetworks", z.ResolutionVirtualNetworks) + populate(objectMap, "zoneType", z.ZoneType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ZoneProperties. +func (z *ZoneProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "maxNumberOfRecordSets": + err = unpopulate(val, "MaxNumberOfRecordSets", &z.MaxNumberOfRecordSets) + delete(rawMsg, key) + case "maxNumberOfRecordsPerRecordSet": + err = unpopulate(val, "MaxNumberOfRecordsPerRecordSet", &z.MaxNumberOfRecordsPerRecordSet) + delete(rawMsg, key) + case "nameServers": + err = unpopulate(val, "NameServers", &z.NameServers) + delete(rawMsg, key) + case "numberOfRecordSets": + err = unpopulate(val, "NumberOfRecordSets", &z.NumberOfRecordSets) + delete(rawMsg, key) + case "registrationVirtualNetworks": + err = unpopulate(val, "RegistrationVirtualNetworks", &z.RegistrationVirtualNetworks) + delete(rawMsg, key) + case "resolutionVirtualNetworks": + err = unpopulate(val, "ResolutionVirtualNetworks", &z.ResolutionVirtualNetworks) + delete(rawMsg, key) + case "zoneType": + err = unpopulate(val, "ZoneType", &z.ZoneType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ZoneUpdate. +func (z ZoneUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", z.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ZoneUpdate. +func (z *ZoneUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &z.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, 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/dns/armdns/zz_generated_recordsets_client.go b/sdk/resourcemanager/dns/armdns/recordsets_client.go similarity index 84% rename from sdk/resourcemanager/dns/armdns/zz_generated_recordsets_client.go rename to sdk/resourcemanager/dns/armdns/recordsets_client.go index be19d9878ba8..4e10bc3dbb00 100644 --- a/sdk/resourcemanager/dns/armdns/zz_generated_recordsets_client.go +++ b/sdk/resourcemanager/dns/armdns/recordsets_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 armdns @@ -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" @@ -26,52 +25,44 @@ import ( // RecordSetsClient contains the methods for the RecordSets group. // Don't use this type directly, use NewRecordSetsClient() instead. type RecordSetsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewRecordSetsClient creates a new instance of RecordSetsClient with the specified values. -// subscriptionID - Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewRecordSetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RecordSetsClient, 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+".RecordSetsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &RecordSetsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Creates or updates a record set within a DNS zone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-05-01 -// resourceGroupName - The name of the resource group. -// zoneName - The name of the DNS zone (without a terminating dot). -// relativeRecordSetName - The name of the record set, relative to the name of the zone. -// recordType - The type of DNS record in this record set. Record sets of type SOA can be updated but not created (they are -// created when the DNS zone is created). -// parameters - Parameters supplied to the CreateOrUpdate operation. -// options - RecordSetsClientCreateOrUpdateOptions contains the optional parameters for the RecordSetsClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - relativeRecordSetName - The name of the record set, relative to the name of the zone. +// - recordType - The type of DNS record in this record set. Record sets of type SOA can be updated but not created (they are +// created when the DNS zone is created). +// - parameters - Parameters supplied to the CreateOrUpdate operation. +// - options - RecordSetsClientCreateOrUpdateOptions contains the optional parameters for the RecordSetsClient.CreateOrUpdate +// method. func (client *RecordSetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, parameters RecordSet, options *RecordSetsClientCreateOrUpdateOptions) (RecordSetsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, options) if err != nil { return RecordSetsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RecordSetsClientCreateOrUpdateResponse{}, err } @@ -101,7 +92,7 @@ func (client *RecordSetsClient) 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 } @@ -129,19 +120,20 @@ func (client *RecordSetsClient) createOrUpdateHandleResponse(resp *http.Response // Delete - Deletes a record set from a DNS zone. This operation cannot be undone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-05-01 -// resourceGroupName - The name of the resource group. -// zoneName - The name of the DNS zone (without a terminating dot). -// relativeRecordSetName - The name of the record set, relative to the name of the zone. -// recordType - The type of DNS record in this record set. Record sets of type SOA cannot be deleted (they are deleted when -// the DNS zone is deleted). -// options - RecordSetsClientDeleteOptions contains the optional parameters for the RecordSetsClient.Delete method. +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - relativeRecordSetName - The name of the record set, relative to the name of the zone. +// - recordType - The type of DNS record in this record set. Record sets of type SOA cannot be deleted (they are deleted when +// the DNS zone is deleted). +// - options - RecordSetsClientDeleteOptions contains the optional parameters for the RecordSetsClient.Delete method. func (client *RecordSetsClient) Delete(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, options *RecordSetsClientDeleteOptions) (RecordSetsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType, options) if err != nil { return RecordSetsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RecordSetsClientDeleteResponse{}, err } @@ -171,7 +163,7 @@ func (client *RecordSetsClient) 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 } @@ -187,18 +179,19 @@ func (client *RecordSetsClient) deleteCreateRequest(ctx context.Context, resourc // Get - Gets a record set. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-05-01 -// resourceGroupName - The name of the resource group. -// zoneName - The name of the DNS zone (without a terminating dot). -// relativeRecordSetName - The name of the record set, relative to the name of the zone. -// recordType - The type of DNS record in this record set. -// options - RecordSetsClientGetOptions contains the optional parameters for the RecordSetsClient.Get method. +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - relativeRecordSetName - The name of the record set, relative to the name of the zone. +// - recordType - The type of DNS record in this record set. +// - options - RecordSetsClientGetOptions contains the optional parameters for the RecordSetsClient.Get method. func (client *RecordSetsClient) Get(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, options *RecordSetsClientGetOptions) (RecordSetsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType, options) if err != nil { return RecordSetsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RecordSetsClientGetResponse{}, err } @@ -228,7 +221,7 @@ func (client *RecordSetsClient) 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 } @@ -249,12 +242,12 @@ func (client *RecordSetsClient) getHandleResponse(resp *http.Response) (RecordSe } // NewListAllByDNSZonePager - Lists all record sets in a DNS zone. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-05-01 -// resourceGroupName - The name of the resource group. -// zoneName - The name of the DNS zone (without a terminating dot). -// options - RecordSetsClientListAllByDNSZoneOptions contains the optional parameters for the RecordSetsClient.ListAllByDNSZone -// method. +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - options - RecordSetsClientListAllByDNSZoneOptions contains the optional parameters for the RecordSetsClient.NewListAllByDNSZonePager +// method. func (client *RecordSetsClient) NewListAllByDNSZonePager(resourceGroupName string, zoneName string, options *RecordSetsClientListAllByDNSZoneOptions) *runtime.Pager[RecordSetsClientListAllByDNSZoneResponse] { return runtime.NewPager(runtime.PagingHandler[RecordSetsClientListAllByDNSZoneResponse]{ More: func(page RecordSetsClientListAllByDNSZoneResponse) bool { @@ -271,7 +264,7 @@ func (client *RecordSetsClient) NewListAllByDNSZonePager(resourceGroupName strin if err != nil { return RecordSetsClientListAllByDNSZoneResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RecordSetsClientListAllByDNSZoneResponse{}, err } @@ -298,7 +291,7 @@ func (client *RecordSetsClient) listAllByDNSZoneCreateRequest(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 } @@ -325,12 +318,12 @@ func (client *RecordSetsClient) listAllByDNSZoneHandleResponse(resp *http.Respon } // NewListByDNSZonePager - Lists all record sets in a DNS zone. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-05-01 -// resourceGroupName - The name of the resource group. -// zoneName - The name of the DNS zone (without a terminating dot). -// options - RecordSetsClientListByDNSZoneOptions contains the optional parameters for the RecordSetsClient.ListByDNSZone -// method. +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - options - RecordSetsClientListByDNSZoneOptions contains the optional parameters for the RecordSetsClient.NewListByDNSZonePager +// method. func (client *RecordSetsClient) NewListByDNSZonePager(resourceGroupName string, zoneName string, options *RecordSetsClientListByDNSZoneOptions) *runtime.Pager[RecordSetsClientListByDNSZoneResponse] { return runtime.NewPager(runtime.PagingHandler[RecordSetsClientListByDNSZoneResponse]{ More: func(page RecordSetsClientListByDNSZoneResponse) bool { @@ -347,7 +340,7 @@ func (client *RecordSetsClient) NewListByDNSZonePager(resourceGroupName string, if err != nil { return RecordSetsClientListByDNSZoneResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RecordSetsClientListByDNSZoneResponse{}, err } @@ -374,7 +367,7 @@ func (client *RecordSetsClient) listByDNSZoneCreateRequest(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 } @@ -401,12 +394,13 @@ func (client *RecordSetsClient) listByDNSZoneHandleResponse(resp *http.Response) } // NewListByTypePager - Lists the record sets of a specified type in a DNS zone. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-05-01 -// resourceGroupName - The name of the resource group. -// zoneName - The name of the DNS zone (without a terminating dot). -// recordType - The type of record sets to enumerate. -// options - RecordSetsClientListByTypeOptions contains the optional parameters for the RecordSetsClient.ListByType method. +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - recordType - The type of record sets to enumerate. +// - options - RecordSetsClientListByTypeOptions contains the optional parameters for the RecordSetsClient.NewListByTypePager +// method. func (client *RecordSetsClient) NewListByTypePager(resourceGroupName string, zoneName string, recordType RecordType, options *RecordSetsClientListByTypeOptions) *runtime.Pager[RecordSetsClientListByTypeResponse] { return runtime.NewPager(runtime.PagingHandler[RecordSetsClientListByTypeResponse]{ More: func(page RecordSetsClientListByTypeResponse) bool { @@ -423,7 +417,7 @@ func (client *RecordSetsClient) NewListByTypePager(resourceGroupName string, zon if err != nil { return RecordSetsClientListByTypeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RecordSetsClientListByTypeResponse{}, err } @@ -454,7 +448,7 @@ func (client *RecordSetsClient) listByTypeCreateRequest(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 } @@ -482,19 +476,20 @@ func (client *RecordSetsClient) listByTypeHandleResponse(resp *http.Response) (R // Update - Updates a record set within a DNS zone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-05-01 -// resourceGroupName - The name of the resource group. -// zoneName - The name of the DNS zone (without a terminating dot). -// relativeRecordSetName - The name of the record set, relative to the name of the zone. -// recordType - The type of DNS record in this record set. -// parameters - Parameters supplied to the Update operation. -// options - RecordSetsClientUpdateOptions contains the optional parameters for the RecordSetsClient.Update method. +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - relativeRecordSetName - The name of the record set, relative to the name of the zone. +// - recordType - The type of DNS record in this record set. +// - parameters - Parameters supplied to the Update operation. +// - options - RecordSetsClientUpdateOptions contains the optional parameters for the RecordSetsClient.Update method. func (client *RecordSetsClient) Update(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, parameters RecordSet, options *RecordSetsClientUpdateOptions) (RecordSetsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, options) if err != nil { return RecordSetsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RecordSetsClientUpdateResponse{}, err } @@ -524,7 +519,7 @@ func (client *RecordSetsClient) updateCreateRequest(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.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/dns/armdns/recordsets_client_example_test.go b/sdk/resourcemanager/dns/armdns/recordsets_client_example_test.go new file mode 100644 index 000000000000..7ad27cf5cad5 --- /dev/null +++ b/sdk/resourcemanager/dns/armdns/recordsets_client_example_test.go @@ -0,0 +1,2082 @@ +//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 armdns_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/dns/armdns" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchARecordset.json +func ExampleRecordSetsClient_Update_patchARecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Update(ctx, "rg1", "zone1", "record1", armdns.RecordTypeA, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + Metadata: map[string]*string{ + "key2": to.Ptr("value2"), + }, + }, + }, &armdns.RecordSetsClientUpdateOptions{IfMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/A"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/A/record1"), + // Properties: &armdns.RecordSetProperties{ + // ARecords: []*armdns.ARecord{ + // { + // IPv4Address: to.Ptr("127.0.0.1"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key2": to.Ptr("value2"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchAAAARecordset.json +func ExampleRecordSetsClient_Update_patchAaaaRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Update(ctx, "rg1", "zone1", "record1", armdns.RecordTypeAAAA, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + Metadata: map[string]*string{ + "key2": to.Ptr("value2"), + }, + }, + }, &armdns.RecordSetsClientUpdateOptions{IfMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/AAAA"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/AAAA/record1"), + // Properties: &armdns.RecordSetProperties{ + // AaaaRecords: []*armdns.AaaaRecord{ + // { + // IPv6Address: to.Ptr("::1"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key2": to.Ptr("value2"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchCaaRecordset.json +func ExampleRecordSetsClient_Update_patchCaaRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Update(ctx, "rg1", "zone1", "record1", armdns.RecordTypeCAA, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + Metadata: map[string]*string{ + "key2": to.Ptr("value2"), + }, + }, + }, &armdns.RecordSetsClientUpdateOptions{IfMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/CAA"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/CAA/record1"), + // Properties: &armdns.RecordSetProperties{ + // TTL: to.Ptr[int64](3600), + // CaaRecords: []*armdns.CaaRecord{ + // { + // Flags: to.Ptr[int32](0), + // Tag: to.Ptr("issue"), + // Value: to.Ptr("ca.contoso.com"), + // }}, + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key2": to.Ptr("value2"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchCNAMERecordset.json +func ExampleRecordSetsClient_Update_patchCnameRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Update(ctx, "rg1", "zone1", "record1", armdns.RecordTypeCNAME, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + Metadata: map[string]*string{ + "key2": to.Ptr("value2"), + }, + }, + }, &armdns.RecordSetsClientUpdateOptions{IfMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/CNAME"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/CNAME/record1"), + // Properties: &armdns.RecordSetProperties{ + // CnameRecord: &armdns.CnameRecord{ + // Cname: to.Ptr("contoso.com"), + // }, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key2": to.Ptr("value2"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchMXRecordset.json +func ExampleRecordSetsClient_Update_patchMxRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Update(ctx, "rg1", "zone1", "record1", armdns.RecordTypeMX, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + Metadata: map[string]*string{ + "key2": to.Ptr("value2"), + }, + }, + }, &armdns.RecordSetsClientUpdateOptions{IfMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/MX"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/MX/record1"), + // Properties: &armdns.RecordSetProperties{ + // MxRecords: []*armdns.MxRecord{ + // { + // Exchange: to.Ptr("mail.contoso.com"), + // Preference: to.Ptr[int32](0), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key2": to.Ptr("value2"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchNSRecordset.json +func ExampleRecordSetsClient_Update_patchNsRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Update(ctx, "rg1", "zone1", "record1", armdns.RecordTypeNS, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + Metadata: map[string]*string{ + "key2": to.Ptr("value2"), + }, + }, + }, &armdns.RecordSetsClientUpdateOptions{IfMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/NS"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/NS/record1"), + // Properties: &armdns.RecordSetProperties{ + // NsRecords: []*armdns.NsRecord{ + // { + // Nsdname: to.Ptr("ns1.contoso.com"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key2": to.Ptr("value2"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchPTRRecordset.json +func ExampleRecordSetsClient_Update_patchPtrRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Update(ctx, "rg1", "0.0.127.in-addr.arpa", "1", armdns.RecordTypePTR, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + Metadata: map[string]*string{ + "key2": to.Ptr("value2"), + }, + }, + }, &armdns.RecordSetsClientUpdateOptions{IfMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/PTR"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/0.0.127.in-addr.arpa/PTR/1"), + // Properties: &armdns.RecordSetProperties{ + // PtrRecords: []*armdns.PtrRecord{ + // { + // Ptrdname: to.Ptr("localhost"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("1.0.0.127.in-addr.arpa"), + // Metadata: map[string]*string{ + // "key2": to.Ptr("value2"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchSOARecordset.json +func ExampleRecordSetsClient_Update_patchSoaRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Update(ctx, "rg1", "zone1", "@", armdns.RecordTypeSOA, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + Metadata: map[string]*string{ + "key2": to.Ptr("value2"), + }, + }, + }, &armdns.RecordSetsClientUpdateOptions{IfMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("@"), + // Type: to.Ptr("Microsoft.Network/dnsZones/SOA"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/SOA/@"), + // Properties: &armdns.RecordSetProperties{ + // SoaRecord: &armdns.SoaRecord{ + // Email: to.Ptr("hostmaster.contoso.com"), + // ExpireTime: to.Ptr[int64](2419200), + // Host: to.Ptr("ns1.contoso.com"), + // MinimumTTL: to.Ptr[int64](300), + // RefreshTime: to.Ptr[int64](3600), + // RetryTime: to.Ptr[int64](300), + // SerialNumber: to.Ptr[int64](1), + // }, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("zone1"), + // Metadata: map[string]*string{ + // "key2": to.Ptr("value2"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchSRVRecordset.json +func ExampleRecordSetsClient_Update_patchSrvRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Update(ctx, "rg1", "zone1", "record1", armdns.RecordTypeSRV, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + Metadata: map[string]*string{ + "key2": to.Ptr("value2"), + }, + }, + }, &armdns.RecordSetsClientUpdateOptions{IfMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/SRV"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/SRV/record1"), + // Properties: &armdns.RecordSetProperties{ + // SrvRecords: []*armdns.SrvRecord{ + // { + // Port: to.Ptr[int32](80), + // Priority: to.Ptr[int32](0), + // Target: to.Ptr("contoso.com"), + // Weight: to.Ptr[int32](10), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key2": to.Ptr("value2"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchTXTRecordset.json +func ExampleRecordSetsClient_Update_patchTxtRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Update(ctx, "rg1", "zone1", "record1", armdns.RecordTypeTXT, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + Metadata: map[string]*string{ + "key2": to.Ptr("value2"), + }, + }, + }, &armdns.RecordSetsClientUpdateOptions{IfMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/TXT"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/TXT/record1"), + // Properties: &armdns.RecordSetProperties{ + // TTL: to.Ptr[int64](3600), + // TxtRecords: []*armdns.TxtRecord{ + // { + // Value: []*string{ + // to.Ptr("string1"), + // to.Ptr("string2")}, + // }}, + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key2": to.Ptr("value2"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateARecordset.json +func ExampleRecordSetsClient_CreateOrUpdate_createARecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().CreateOrUpdate(ctx, "rg1", "zone1", "record1", armdns.RecordTypeA, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + ARecords: []*armdns.ARecord{ + { + IPv4Address: to.Ptr("127.0.0.1"), + }}, + TTL: to.Ptr[int64](3600), + Metadata: map[string]*string{ + "key1": to.Ptr("value1"), + }, + }, + }, &armdns.RecordSetsClientCreateOrUpdateOptions{IfMatch: nil, + IfNoneMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/A"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/A/record1"), + // Properties: &armdns.RecordSetProperties{ + // ARecords: []*armdns.ARecord{ + // { + // IPv4Address: to.Ptr("127.0.0.1"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateARecordsetAlias.json +func ExampleRecordSetsClient_CreateOrUpdate_createARecordsetWithAliasTargetResource() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().CreateOrUpdate(ctx, "rg1", "zone1", "record1", armdns.RecordTypeA, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + TTL: to.Ptr[int64](3600), + Metadata: map[string]*string{ + "key1": to.Ptr("value1"), + }, + TargetResource: &armdns.SubResource{ + ID: to.Ptr("/subscriptions/726f8cd6-6459-4db4-8e6d-2cd2716904e2/resourceGroups/test/providers/Microsoft.Network/trafficManagerProfiles/testpp2"), + }, + }, + }, &armdns.RecordSetsClientCreateOrUpdateOptions{IfMatch: nil, + IfNoneMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/A"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/A/record1"), + // Properties: &armdns.RecordSetProperties{ + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // TargetResource: &armdns.SubResource{ + // ID: to.Ptr("/subscriptions/726f8cd6-6459-4db4-8e6d-2cd2716904e2/resourceGroups/test/providers/Microsoft.Network/trafficManagerProfiles/testpp2"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateAAAARecordset.json +func ExampleRecordSetsClient_CreateOrUpdate_createAaaaRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().CreateOrUpdate(ctx, "rg1", "zone1", "record1", armdns.RecordTypeAAAA, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + AaaaRecords: []*armdns.AaaaRecord{ + { + IPv6Address: to.Ptr("::1"), + }}, + TTL: to.Ptr[int64](3600), + Metadata: map[string]*string{ + "key1": to.Ptr("value1"), + }, + }, + }, &armdns.RecordSetsClientCreateOrUpdateOptions{IfMatch: nil, + IfNoneMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/AAAA"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/AAAA/record1"), + // Properties: &armdns.RecordSetProperties{ + // AaaaRecords: []*armdns.AaaaRecord{ + // { + // IPv6Address: to.Ptr("::1"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateCaaRecordset.json +func ExampleRecordSetsClient_CreateOrUpdate_createCaaRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().CreateOrUpdate(ctx, "rg1", "zone1", "record1", armdns.RecordTypeCAA, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + TTL: to.Ptr[int64](3600), + CaaRecords: []*armdns.CaaRecord{ + { + Flags: to.Ptr[int32](0), + Tag: to.Ptr("issue"), + Value: to.Ptr("ca.contoso.com"), + }}, + Metadata: map[string]*string{ + "key1": to.Ptr("value1"), + }, + }, + }, &armdns.RecordSetsClientCreateOrUpdateOptions{IfMatch: nil, + IfNoneMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/CAA"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/CAA/record1"), + // Properties: &armdns.RecordSetProperties{ + // TTL: to.Ptr[int64](3600), + // CaaRecords: []*armdns.CaaRecord{ + // { + // Flags: to.Ptr[int32](0), + // Tag: to.Ptr("issue"), + // Value: to.Ptr("ca.contoso.com"), + // }}, + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateCNAMERecordset.json +func ExampleRecordSetsClient_CreateOrUpdate_createCnameRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().CreateOrUpdate(ctx, "rg1", "zone1", "record1", armdns.RecordTypeCNAME, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + CnameRecord: &armdns.CnameRecord{ + Cname: to.Ptr("contoso.com"), + }, + TTL: to.Ptr[int64](3600), + Metadata: map[string]*string{ + "key1": to.Ptr("value1"), + }, + }, + }, &armdns.RecordSetsClientCreateOrUpdateOptions{IfMatch: nil, + IfNoneMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/CNAME"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/CNAME/record1"), + // Properties: &armdns.RecordSetProperties{ + // CnameRecord: &armdns.CnameRecord{ + // Cname: to.Ptr("contoso.com"), + // }, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateMXRecordset.json +func ExampleRecordSetsClient_CreateOrUpdate_createMxRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().CreateOrUpdate(ctx, "rg1", "zone1", "record1", armdns.RecordTypeMX, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + MxRecords: []*armdns.MxRecord{ + { + Exchange: to.Ptr("mail.contoso.com"), + Preference: to.Ptr[int32](0), + }}, + TTL: to.Ptr[int64](3600), + Metadata: map[string]*string{ + "key1": to.Ptr("value1"), + }, + }, + }, &armdns.RecordSetsClientCreateOrUpdateOptions{IfMatch: nil, + IfNoneMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/MX"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/MX/record1"), + // Properties: &armdns.RecordSetProperties{ + // MxRecords: []*armdns.MxRecord{ + // { + // Exchange: to.Ptr("mail.contoso.com"), + // Preference: to.Ptr[int32](0), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateNSRecordset.json +func ExampleRecordSetsClient_CreateOrUpdate_createNsRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().CreateOrUpdate(ctx, "rg1", "zone1", "record1", armdns.RecordTypeNS, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + NsRecords: []*armdns.NsRecord{ + { + Nsdname: to.Ptr("ns1.contoso.com"), + }}, + TTL: to.Ptr[int64](3600), + Metadata: map[string]*string{ + "key1": to.Ptr("value1"), + }, + }, + }, &armdns.RecordSetsClientCreateOrUpdateOptions{IfMatch: nil, + IfNoneMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/NS"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/NS/record1"), + // Properties: &armdns.RecordSetProperties{ + // NsRecords: []*armdns.NsRecord{ + // { + // Nsdname: to.Ptr("ns1.contoso.com"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdatePTRRecordset.json +func ExampleRecordSetsClient_CreateOrUpdate_createPtrRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().CreateOrUpdate(ctx, "rg1", "0.0.127.in-addr.arpa", "1", armdns.RecordTypePTR, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + PtrRecords: []*armdns.PtrRecord{ + { + Ptrdname: to.Ptr("localhost"), + }}, + TTL: to.Ptr[int64](3600), + Metadata: map[string]*string{ + "key1": to.Ptr("value1"), + }, + }, + }, &armdns.RecordSetsClientCreateOrUpdateOptions{IfMatch: nil, + IfNoneMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/PTR"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/0.0.127.in-addr.arpa/PTR/1"), + // Properties: &armdns.RecordSetProperties{ + // PtrRecords: []*armdns.PtrRecord{ + // { + // Ptrdname: to.Ptr("localhost"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("1.0.0.127.in-addr.arpa"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateSOARecordset.json +func ExampleRecordSetsClient_CreateOrUpdate_createSoaRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().CreateOrUpdate(ctx, "rg1", "zone1", "@", armdns.RecordTypeSOA, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + SoaRecord: &armdns.SoaRecord{ + Email: to.Ptr("hostmaster.contoso.com"), + ExpireTime: to.Ptr[int64](2419200), + Host: to.Ptr("ns1.contoso.com"), + MinimumTTL: to.Ptr[int64](300), + RefreshTime: to.Ptr[int64](3600), + RetryTime: to.Ptr[int64](300), + SerialNumber: to.Ptr[int64](1), + }, + TTL: to.Ptr[int64](3600), + Metadata: map[string]*string{ + "key1": to.Ptr("value1"), + }, + }, + }, &armdns.RecordSetsClientCreateOrUpdateOptions{IfMatch: nil, + IfNoneMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("@"), + // Type: to.Ptr("Microsoft.Network/dnsZones/SOA"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/SOA/@"), + // Properties: &armdns.RecordSetProperties{ + // SoaRecord: &armdns.SoaRecord{ + // Email: to.Ptr("hostmaster.contoso.com"), + // ExpireTime: to.Ptr[int64](2419200), + // Host: to.Ptr("ns1.contoso.com"), + // MinimumTTL: to.Ptr[int64](300), + // RefreshTime: to.Ptr[int64](3600), + // RetryTime: to.Ptr[int64](300), + // SerialNumber: to.Ptr[int64](1), + // }, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateSRVRecordset.json +func ExampleRecordSetsClient_CreateOrUpdate_createSrvRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().CreateOrUpdate(ctx, "rg1", "zone1", "record1", armdns.RecordTypeSRV, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + SrvRecords: []*armdns.SrvRecord{ + { + Port: to.Ptr[int32](80), + Priority: to.Ptr[int32](0), + Target: to.Ptr("contoso.com"), + Weight: to.Ptr[int32](10), + }}, + TTL: to.Ptr[int64](3600), + Metadata: map[string]*string{ + "key1": to.Ptr("value1"), + }, + }, + }, &armdns.RecordSetsClientCreateOrUpdateOptions{IfMatch: nil, + IfNoneMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/SRV"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/SRV/record1"), + // Properties: &armdns.RecordSetProperties{ + // SrvRecords: []*armdns.SrvRecord{ + // { + // Port: to.Ptr[int32](80), + // Priority: to.Ptr[int32](0), + // Target: to.Ptr("contoso.com"), + // Weight: to.Ptr[int32](10), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateTXTRecordset.json +func ExampleRecordSetsClient_CreateOrUpdate_createTxtRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().CreateOrUpdate(ctx, "rg1", "zone1", "record1", armdns.RecordTypeTXT, armdns.RecordSet{ + Properties: &armdns.RecordSetProperties{ + TTL: to.Ptr[int64](3600), + TxtRecords: []*armdns.TxtRecord{ + { + Value: []*string{ + to.Ptr("string1"), + to.Ptr("string2")}, + }}, + Metadata: map[string]*string{ + "key1": to.Ptr("value1"), + }, + }, + }, &armdns.RecordSetsClientCreateOrUpdateOptions{IfMatch: nil, + IfNoneMatch: 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/TXT"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/TXT/record1"), + // Properties: &armdns.RecordSetProperties{ + // TTL: to.Ptr[int64](3600), + // TxtRecords: []*armdns.TxtRecord{ + // { + // Value: []*string{ + // to.Ptr("string1"), + // to.Ptr("string2")}, + // }}, + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json +func ExampleRecordSetsClient_Delete_deleteARecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewRecordSetsClient().Delete(ctx, "rg1", "zone1", "record1", armdns.RecordTypeA, &armdns.RecordSetsClientDeleteOptions{IfMatch: 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/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteAAAARecordset.json +func ExampleRecordSetsClient_Delete_deleteAaaaRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewRecordSetsClient().Delete(ctx, "rg1", "zone1", "record1", armdns.RecordTypeAAAA, &armdns.RecordSetsClientDeleteOptions{IfMatch: 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/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteCaaRecordset.json +func ExampleRecordSetsClient_Delete_deleteCaaRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewRecordSetsClient().Delete(ctx, "rg1", "zone1", "record1", armdns.RecordTypeCAA, &armdns.RecordSetsClientDeleteOptions{IfMatch: 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/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeletePTRRecordset.json +func ExampleRecordSetsClient_Delete_deletePtrRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewRecordSetsClient().Delete(ctx, "rg1", "0.0.127.in-addr.arpa", "1", armdns.RecordTypePTR, &armdns.RecordSetsClientDeleteOptions{IfMatch: 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/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteSRVRecordset.json +func ExampleRecordSetsClient_Delete_deleteSrvRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewRecordSetsClient().Delete(ctx, "rg1", "zone1", "record1", armdns.RecordTypeSRV, &armdns.RecordSetsClientDeleteOptions{IfMatch: 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/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteTXTRecordset.json +func ExampleRecordSetsClient_Delete_deleteTxtRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewRecordSetsClient().Delete(ctx, "rg1", "zone1", "record1", armdns.RecordTypeTXT, &armdns.RecordSetsClientDeleteOptions{IfMatch: 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/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetARecordset.json +func ExampleRecordSetsClient_Get_getARecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Get(ctx, "rg1", "zone1", "record1", armdns.RecordTypeA, 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/A"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/A/record1"), + // Properties: &armdns.RecordSetProperties{ + // ARecords: []*armdns.ARecord{ + // { + // IPv4Address: to.Ptr("127.0.0.1"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetAAAARecordset.json +func ExampleRecordSetsClient_Get_getAaaaRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Get(ctx, "rg1", "zone1", "record1", armdns.RecordTypeAAAA, 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/AAAA"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/AAAA/record1"), + // Properties: &armdns.RecordSetProperties{ + // AaaaRecords: []*armdns.AaaaRecord{ + // { + // IPv6Address: to.Ptr("::1"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetCaaRecordset.json +func ExampleRecordSetsClient_Get_getCaaRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Get(ctx, "rg1", "zone1", "record1", armdns.RecordTypeCAA, 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/CAA"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/CAA/record1"), + // Properties: &armdns.RecordSetProperties{ + // TTL: to.Ptr[int64](3600), + // CaaRecords: []*armdns.CaaRecord{ + // { + // Flags: to.Ptr[int32](0), + // Tag: to.Ptr("issue"), + // Value: to.Ptr("ca.contoso.com"), + // }}, + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetCNAMERecordset.json +func ExampleRecordSetsClient_Get_getCnameRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Get(ctx, "rg1", "zone1", "record1", armdns.RecordTypeCNAME, 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/CNAME"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/CNAME/record1"), + // Properties: &armdns.RecordSetProperties{ + // CnameRecord: &armdns.CnameRecord{ + // Cname: to.Ptr("contoso.com"), + // }, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetMXRecordset.json +func ExampleRecordSetsClient_Get_getMxRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Get(ctx, "rg1", "zone1", "record1", armdns.RecordTypeMX, 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/MX"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/MX/record1"), + // Properties: &armdns.RecordSetProperties{ + // MxRecords: []*armdns.MxRecord{ + // { + // Exchange: to.Ptr("mail.contoso.com"), + // Preference: to.Ptr[int32](0), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetNSRecordset.json +func ExampleRecordSetsClient_Get_getNsRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Get(ctx, "rg1", "zone1", "record1", armdns.RecordTypeNS, 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/NS"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/NS/record1"), + // Properties: &armdns.RecordSetProperties{ + // NsRecords: []*armdns.NsRecord{ + // { + // Nsdname: to.Ptr("ns1.contoso.com"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetPTRRecordset.json +func ExampleRecordSetsClient_Get_getPtrRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Get(ctx, "rg1", "0.0.127.in-addr.arpa", "1", armdns.RecordTypePTR, 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/PTR"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/0.0.127.in-addr.arpa/PTR/1"), + // Properties: &armdns.RecordSetProperties{ + // PtrRecords: []*armdns.PtrRecord{ + // { + // Ptrdname: to.Ptr("localhost"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("1.0.0.127.in-addr.arpa"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetSOARecordset.json +func ExampleRecordSetsClient_Get_getSoaRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Get(ctx, "rg1", "zone1", "@", armdns.RecordTypeSOA, 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("@"), + // Type: to.Ptr("Microsoft.Network/dnsZones/SOA"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/SOA/@"), + // Properties: &armdns.RecordSetProperties{ + // SoaRecord: &armdns.SoaRecord{ + // Email: to.Ptr("hostmaster.contoso.com"), + // ExpireTime: to.Ptr[int64](2419200), + // Host: to.Ptr("ns1.contoso.com"), + // MinimumTTL: to.Ptr[int64](300), + // RefreshTime: to.Ptr[int64](3600), + // RetryTime: to.Ptr[int64](300), + // SerialNumber: to.Ptr[int64](1), + // }, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetSRVRecordset.json +func ExampleRecordSetsClient_Get_getSrvRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Get(ctx, "rg1", "zone1", "record1", armdns.RecordTypeSRV, 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/SRV"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/SRV/record1"), + // Properties: &armdns.RecordSetProperties{ + // SrvRecords: []*armdns.SrvRecord{ + // { + // Port: to.Ptr[int32](80), + // Priority: to.Ptr[int32](0), + // Target: to.Ptr("contoso.com"), + // Weight: to.Ptr[int32](10), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetTXTRecordset.json +func ExampleRecordSetsClient_Get_getTxtRecordset() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecordSetsClient().Get(ctx, "rg1", "zone1", "record1", armdns.RecordTypeTXT, 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.RecordSet = armdns.RecordSet{ + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/TXT"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/TXT/record1"), + // Properties: &armdns.RecordSetProperties{ + // TTL: to.Ptr[int64](3600), + // TxtRecords: []*armdns.TxtRecord{ + // { + // Value: []*string{ + // to.Ptr("string1"), + // to.Ptr("string2")}, + // }}, + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListARecordset.json +func ExampleRecordSetsClient_NewListByTypePager_listARecordsets() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRecordSetsClient().NewListByTypePager("rg1", "zone1", armdns.RecordTypeA, &armdns.RecordSetsClientListByTypeOptions{Top: nil, + Recordsetnamesuffix: 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.RecordSetListResult = armdns.RecordSetListResult{ + // Value: []*armdns.RecordSet{ + // { + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/A"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/A/record1"), + // Properties: &armdns.RecordSetProperties{ + // ARecords: []*armdns.ARecord{ + // { + // IPv4Address: to.Ptr("127.0.0.1"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListAAAARecordset.json +func ExampleRecordSetsClient_NewListByTypePager_listAaaaRecordsets() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRecordSetsClient().NewListByTypePager("rg1", "zone1", armdns.RecordTypeAAAA, &armdns.RecordSetsClientListByTypeOptions{Top: nil, + Recordsetnamesuffix: 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.RecordSetListResult = armdns.RecordSetListResult{ + // Value: []*armdns.RecordSet{ + // { + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/AAAA"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/AAAA/record1"), + // Properties: &armdns.RecordSetProperties{ + // AaaaRecords: []*armdns.AaaaRecord{ + // { + // IPv6Address: to.Ptr("::1"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListCaaRecordset.json +func ExampleRecordSetsClient_NewListByTypePager_listCaaRecordsets() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRecordSetsClient().NewListByTypePager("rg1", "zone1", armdns.RecordTypeCAA, &armdns.RecordSetsClientListByTypeOptions{Top: nil, + Recordsetnamesuffix: 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.RecordSetListResult = armdns.RecordSetListResult{ + // Value: []*armdns.RecordSet{ + // { + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/CAA"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/CAA/record1"), + // Properties: &armdns.RecordSetProperties{ + // TTL: to.Ptr[int64](3600), + // CaaRecords: []*armdns.CaaRecord{ + // { + // Flags: to.Ptr[int32](0), + // Tag: to.Ptr("issue"), + // Value: to.Ptr("ca.contoso.com"), + // }}, + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListCNAMERecordset.json +func ExampleRecordSetsClient_NewListByTypePager_listCnameRecordsets() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRecordSetsClient().NewListByTypePager("rg1", "zone1", armdns.RecordTypeCNAME, &armdns.RecordSetsClientListByTypeOptions{Top: nil, + Recordsetnamesuffix: 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.RecordSetListResult = armdns.RecordSetListResult{ + // Value: []*armdns.RecordSet{ + // { + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/CNAME"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/CNAME/record1"), + // Properties: &armdns.RecordSetProperties{ + // CnameRecord: &armdns.CnameRecord{ + // Cname: to.Ptr("contoso.com"), + // }, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListMXRecordset.json +func ExampleRecordSetsClient_NewListByTypePager_listMxRecordsets() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRecordSetsClient().NewListByTypePager("rg1", "zone1", armdns.RecordTypeMX, &armdns.RecordSetsClientListByTypeOptions{Top: nil, + Recordsetnamesuffix: 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.RecordSetListResult = armdns.RecordSetListResult{ + // Value: []*armdns.RecordSet{ + // { + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/MX"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/MX/record1"), + // Properties: &armdns.RecordSetProperties{ + // MxRecords: []*armdns.MxRecord{ + // { + // Exchange: to.Ptr("mail.contoso.com"), + // Preference: to.Ptr[int32](0), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListNSRecordset.json +func ExampleRecordSetsClient_NewListByTypePager_listNsRecordsets() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRecordSetsClient().NewListByTypePager("rg1", "zone1", armdns.RecordTypeNS, &armdns.RecordSetsClientListByTypeOptions{Top: nil, + Recordsetnamesuffix: 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.RecordSetListResult = armdns.RecordSetListResult{ + // Value: []*armdns.RecordSet{ + // { + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/NS"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/NS/record1"), + // Properties: &armdns.RecordSetProperties{ + // NsRecords: []*armdns.NsRecord{ + // { + // Nsdname: to.Ptr("ns1.contoso.com"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListPTRRecordset.json +func ExampleRecordSetsClient_NewListByTypePager_listPtrRecordsets() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRecordSetsClient().NewListByTypePager("rg1", "0.0.127.in-addr.arpa", armdns.RecordTypePTR, &armdns.RecordSetsClientListByTypeOptions{Top: nil, + Recordsetnamesuffix: 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.RecordSetListResult = armdns.RecordSetListResult{ + // Value: []*armdns.RecordSet{ + // { + // Name: to.Ptr("1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/PTR"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/0.0.127.in-addr.arpa/PTR/1"), + // Properties: &armdns.RecordSetProperties{ + // PtrRecords: []*armdns.PtrRecord{ + // { + // Ptrdname: to.Ptr("localhost"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("1.0.0.127.in-addr.arpa"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListSOARecordset.json +func ExampleRecordSetsClient_NewListByTypePager_listSoaRecordsets() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRecordSetsClient().NewListByTypePager("rg1", "zone1", armdns.RecordTypeSOA, &armdns.RecordSetsClientListByTypeOptions{Top: nil, + Recordsetnamesuffix: 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.RecordSetListResult = armdns.RecordSetListResult{ + // Value: []*armdns.RecordSet{ + // { + // Name: to.Ptr("@"), + // Type: to.Ptr("Microsoft.Network/dnsZones/SOA"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/SOA/@"), + // Properties: &armdns.RecordSetProperties{ + // SoaRecord: &armdns.SoaRecord{ + // Email: to.Ptr("hostmaster.contoso.com"), + // ExpireTime: to.Ptr[int64](2419200), + // Host: to.Ptr("ns1.contoso.com"), + // MinimumTTL: to.Ptr[int64](300), + // RefreshTime: to.Ptr[int64](3600), + // RetryTime: to.Ptr[int64](300), + // SerialNumber: to.Ptr[int64](1), + // }, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListSRVRecordset.json +func ExampleRecordSetsClient_NewListByTypePager_listSrvRecordsets() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRecordSetsClient().NewListByTypePager("rg1", "zone1", armdns.RecordTypeSRV, &armdns.RecordSetsClientListByTypeOptions{Top: nil, + Recordsetnamesuffix: 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.RecordSetListResult = armdns.RecordSetListResult{ + // Value: []*armdns.RecordSet{ + // { + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/SRV"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/SRV/record1"), + // Properties: &armdns.RecordSetProperties{ + // SrvRecords: []*armdns.SrvRecord{ + // { + // Port: to.Ptr[int32](80), + // Priority: to.Ptr[int32](0), + // Target: to.Ptr("contoso.com"), + // Weight: to.Ptr[int32](10), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListTXTRecordset.json +func ExampleRecordSetsClient_NewListByTypePager_listTxtRecordsets() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRecordSetsClient().NewListByTypePager("rg1", "zone1", armdns.RecordTypeTXT, &armdns.RecordSetsClientListByTypeOptions{Top: nil, + Recordsetnamesuffix: 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.RecordSetListResult = armdns.RecordSetListResult{ + // Value: []*armdns.RecordSet{ + // { + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/TXT"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/TXT/record1"), + // Properties: &armdns.RecordSetProperties{ + // TTL: to.Ptr[int64](3600), + // TxtRecords: []*armdns.TxtRecord{ + // { + // Value: []*string{ + // to.Ptr("string1"), + // to.Ptr("string2")}, + // }}, + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListRecordSetsByZone.json +func ExampleRecordSetsClient_NewListByDNSZonePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRecordSetsClient().NewListByDNSZonePager("rg1", "zone1", &armdns.RecordSetsClientListByDNSZoneOptions{Top: nil, + Recordsetnamesuffix: 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.RecordSetListResult = armdns.RecordSetListResult{ + // Value: []*armdns.RecordSet{ + // { + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/CAA"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/CAA/record1"), + // Properties: &armdns.RecordSetProperties{ + // TTL: to.Ptr[int64](3600), + // CaaRecords: []*armdns.CaaRecord{ + // { + // Flags: to.Ptr[int32](0), + // Tag: to.Ptr("issue"), + // Value: to.Ptr("ca.contoso.com"), + // }}, + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // }, + // { + // Name: to.Ptr("record1"), + // Type: to.Ptr("Microsoft.Network/dnsZones/A"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/A/record1"), + // Properties: &armdns.RecordSetProperties{ + // ARecords: []*armdns.ARecord{ + // { + // IPv4Address: to.Ptr("127.0.0.1"), + // }}, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record1.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // }, + // { + // Name: to.Ptr("record2"), + // Type: to.Ptr("Microsoft.Network/dnsZones/CNAME"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1/CNAME/record2"), + // Properties: &armdns.RecordSetProperties{ + // CnameRecord: &armdns.CnameRecord{ + // Cname: to.Ptr("contoso.com"), + // }, + // TTL: to.Ptr[int64](3600), + // Fqdn: to.Ptr("record2.zone1"), + // Metadata: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/dns/armdns/zz_generated_resourcereference_client.go b/sdk/resourcemanager/dns/armdns/resourcereference_client.go similarity index 76% rename from sdk/resourcemanager/dns/armdns/zz_generated_resourcereference_client.go rename to sdk/resourcemanager/dns/armdns/resourcereference_client.go index c2f7f67e677c..c1d404ba1ead 100644 --- a/sdk/resourcemanager/dns/armdns/zz_generated_resourcereference_client.go +++ b/sdk/resourcemanager/dns/armdns/resourcereference_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 armdns @@ -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 ( // ResourceReferenceClient contains the methods for the DNSResourceReference group. // Don't use this type directly, use NewResourceReferenceClient() instead. type ResourceReferenceClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewResourceReferenceClient creates a new instance of ResourceReferenceClient with the specified values. -// subscriptionID - Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewResourceReferenceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ResourceReferenceClient, 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+".ResourceReferenceClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ResourceReferenceClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // GetByTargetResources - Returns the DNS records specified by the referencing targetResourceIds. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-05-01 -// parameters - Properties for dns resource reference request. -// options - ResourceReferenceClientGetByTargetResourcesOptions contains the optional parameters for the ResourceReferenceClient.GetByTargetResources -// method. +// - parameters - Properties for dns resource reference request. +// - options - ResourceReferenceClientGetByTargetResourcesOptions contains the optional parameters for the ResourceReferenceClient.GetByTargetResources +// method. func (client *ResourceReferenceClient) GetByTargetResources(ctx context.Context, parameters ResourceReferenceRequest, options *ResourceReferenceClientGetByTargetResourcesOptions) (ResourceReferenceClientGetByTargetResourcesResponse, error) { req, err := client.getByTargetResourcesCreateRequest(ctx, parameters, options) if err != nil { return ResourceReferenceClientGetByTargetResourcesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceReferenceClientGetByTargetResourcesResponse{}, err } @@ -82,7 +73,7 @@ func (client *ResourceReferenceClient) getByTargetResourcesCreateRequest(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.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/dns/armdns/resourcereference_client_example_test.go b/sdk/resourcemanager/dns/armdns/resourcereference_client_example_test.go new file mode 100644 index 000000000000..cc3dedce5577 --- /dev/null +++ b/sdk/resourcemanager/dns/armdns/resourcereference_client_example_test.go @@ -0,0 +1,60 @@ +//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 armdns_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/dns/armdns" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetDnsResourceReference.json +func ExampleResourceReferenceClient_GetByTargetResources() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewResourceReferenceClient().GetByTargetResources(ctx, armdns.ResourceReferenceRequest{ + Properties: &armdns.ResourceReferenceRequestProperties{ + TargetResources: []*armdns.SubResource{ + { + ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/trafficManagerProfiles/testpp2"), + }}, + }, + }, 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.ResourceReferenceResult = armdns.ResourceReferenceResult{ + // Properties: &armdns.ResourceReferenceResultProperties{ + // DNSResourceReferences: []*armdns.ResourceReference{ + // { + // DNSResources: []*armdns.SubResource{ + // { + // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/microsoft.network/dnszones/hydratest.dnszone.com5989/a/hydratestdnsrec9310"), + // }}, + // TargetResource: &armdns.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/trafficManagerProfiles/testpp2"), + // }, + // }}, + // }, + // } +} diff --git a/sdk/resourcemanager/dns/armdns/zz_generated_response_types.go b/sdk/resourcemanager/dns/armdns/response_types.go similarity index 90% rename from sdk/resourcemanager/dns/armdns/zz_generated_response_types.go rename to sdk/resourcemanager/dns/armdns/response_types.go index 75b0f90fc2c1..2823f0193016 100644 --- a/sdk/resourcemanager/dns/armdns/zz_generated_response_types.go +++ b/sdk/resourcemanager/dns/armdns/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 armdns @@ -23,17 +24,17 @@ type RecordSetsClientGetResponse struct { RecordSet } -// RecordSetsClientListAllByDNSZoneResponse contains the response from method RecordSetsClient.ListAllByDNSZone. +// RecordSetsClientListAllByDNSZoneResponse contains the response from method RecordSetsClient.NewListAllByDNSZonePager. type RecordSetsClientListAllByDNSZoneResponse struct { RecordSetListResult } -// RecordSetsClientListByDNSZoneResponse contains the response from method RecordSetsClient.ListByDNSZone. +// RecordSetsClientListByDNSZoneResponse contains the response from method RecordSetsClient.NewListByDNSZonePager. type RecordSetsClientListByDNSZoneResponse struct { RecordSetListResult } -// RecordSetsClientListByTypeResponse contains the response from method RecordSetsClient.ListByType. +// RecordSetsClientListByTypeResponse contains the response from method RecordSetsClient.NewListByTypePager. type RecordSetsClientListByTypeResponse struct { RecordSetListResult } @@ -53,7 +54,7 @@ type ZonesClientCreateOrUpdateResponse struct { Zone } -// ZonesClientDeleteResponse contains the response from method ZonesClient.Delete. +// ZonesClientDeleteResponse contains the response from method ZonesClient.BeginDelete. type ZonesClientDeleteResponse struct { // placeholder for future response values } @@ -63,12 +64,12 @@ type ZonesClientGetResponse struct { Zone } -// ZonesClientListByResourceGroupResponse contains the response from method ZonesClient.ListByResourceGroup. +// ZonesClientListByResourceGroupResponse contains the response from method ZonesClient.NewListByResourceGroupPager. type ZonesClientListByResourceGroupResponse struct { ZoneListResult } -// ZonesClientListResponse contains the response from method ZonesClient.List. +// ZonesClientListResponse contains the response from method ZonesClient.NewListPager. type ZonesClientListResponse struct { ZoneListResult } diff --git a/sdk/resourcemanager/dns/armdns/ze_generated_example_dnsresourcereference_client_test.go b/sdk/resourcemanager/dns/armdns/ze_generated_example_dnsresourcereference_client_test.go deleted file mode 100644 index 0adee515c612..000000000000 --- a/sdk/resourcemanager/dns/armdns/ze_generated_example_dnsresourcereference_client_test.go +++ /dev/null @@ -1,46 +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 armdns_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/dns/armdns" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetDnsResourceReference.json -func ExampleResourceReferenceClient_GetByTargetResources() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdns.NewResourceReferenceClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetByTargetResources(ctx, - armdns.ResourceReferenceRequest{ - Properties: &armdns.ResourceReferenceRequestProperties{ - TargetResources: []*armdns.SubResource{ - { - ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/trafficManagerProfiles/testpp2"), - }}, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/dns/armdns/ze_generated_example_recordsets_client_test.go b/sdk/resourcemanager/dns/armdns/ze_generated_example_recordsets_client_test.go deleted file mode 100644 index 4ff81a76d167..000000000000 --- a/sdk/resourcemanager/dns/armdns/ze_generated_example_recordsets_client_test.go +++ /dev/null @@ -1,162 +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 armdns_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/dns/armdns" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchARecordset.json -func ExampleRecordSetsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdns.NewRecordSetsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "rg1", - "zone1", - "record1", - armdns.RecordTypeA, - armdns.RecordSet{ - Properties: &armdns.RecordSetProperties{ - Metadata: map[string]*string{ - "key2": to.Ptr("value2"), - }, - }, - }, - &armdns.RecordSetsClientUpdateOptions{IfMatch: 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/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateARecordset.json -func ExampleRecordSetsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdns.NewRecordSetsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "rg1", - "zone1", - "record1", - armdns.RecordTypeA, - armdns.RecordSet{ - Properties: &armdns.RecordSetProperties{ - ARecords: []*armdns.ARecord{ - { - IPv4Address: to.Ptr("127.0.0.1"), - }}, - TTL: to.Ptr[int64](3600), - Metadata: map[string]*string{ - "key1": to.Ptr("value1"), - }, - }, - }, - &armdns.RecordSetsClientCreateOrUpdateOptions{IfMatch: nil, - IfNoneMatch: 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/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json -func ExampleRecordSetsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdns.NewRecordSetsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "rg1", - "zone1", - "record1", - armdns.RecordTypeA, - &armdns.RecordSetsClientDeleteOptions{IfMatch: 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/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetARecordset.json -func ExampleRecordSetsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdns.NewRecordSetsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "rg1", - "zone1", - "record1", - armdns.RecordTypeA, - 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/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListARecordset.json -func ExampleRecordSetsClient_NewListByTypePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdns.NewRecordSetsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByTypePager("rg1", - "zone1", - armdns.RecordTypeA, - &armdns.RecordSetsClientListByTypeOptions{Top: nil, - Recordsetnamesuffix: 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/dns/armdns/ze_generated_example_zones_client_test.go b/sdk/resourcemanager/dns/armdns/ze_generated_example_zones_client_test.go deleted file mode 100644 index 415e225f105d..000000000000 --- a/sdk/resourcemanager/dns/armdns/ze_generated_example_zones_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 armdns_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/dns/armdns" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateZone.json -func ExampleZonesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdns.NewZonesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "rg1", - "zone1", - armdns.Zone{ - Location: to.Ptr("Global"), - Tags: map[string]*string{ - "key1": to.Ptr("value1"), - }, - }, - &armdns.ZonesClientCreateOrUpdateOptions{IfMatch: nil, - IfNoneMatch: 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/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteZone.json -func ExampleZonesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdns.NewZonesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "rg1", - "zone1", - &armdns.ZonesClientBeginDeleteOptions{IfMatch: 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/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetZone.json -func ExampleZonesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdns.NewZonesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "rg1", - "zone1", - 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/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchZone.json -func ExampleZonesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdns.NewZonesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "rg1", - "zone1", - armdns.ZoneUpdate{ - Tags: map[string]*string{ - "key2": to.Ptr("value2"), - }, - }, - &armdns.ZonesClientUpdateOptions{IfMatch: 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/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListZonesByResourceGroup.json -func ExampleZonesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdns.NewZonesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("rg1", - &armdns.ZonesClientListByResourceGroupOptions{Top: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListZonesBySubscription.json -func ExampleZonesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdns.NewZonesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(&armdns.ZonesClientListOptions{Top: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/dns/armdns/zz_generated_zones_client.go b/sdk/resourcemanager/dns/armdns/zones_client.go similarity index 85% rename from sdk/resourcemanager/dns/armdns/zz_generated_zones_client.go rename to sdk/resourcemanager/dns/armdns/zones_client.go index 72da125f7ef5..91e9e8b9036c 100644 --- a/sdk/resourcemanager/dns/armdns/zz_generated_zones_client.go +++ b/sdk/resourcemanager/dns/armdns/zones_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 armdns @@ -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" @@ -26,48 +25,40 @@ import ( // ZonesClient contains the methods for the Zones group. // Don't use this type directly, use NewZonesClient() instead. type ZonesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewZonesClient creates a new instance of ZonesClient with the specified values. -// subscriptionID - Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewZonesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ZonesClient, 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+".ZonesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ZonesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Creates or updates a DNS zone. Does not modify DNS records within the zone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-05-01 -// resourceGroupName - The name of the resource group. -// zoneName - The name of the DNS zone (without a terminating dot). -// parameters - Parameters supplied to the CreateOrUpdate operation. -// options - ZonesClientCreateOrUpdateOptions contains the optional parameters for the ZonesClient.CreateOrUpdate method. +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - parameters - Parameters supplied to the CreateOrUpdate operation. +// - options - ZonesClientCreateOrUpdateOptions contains the optional parameters for the ZonesClient.CreateOrUpdate method. func (client *ZonesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, zoneName string, parameters Zone, options *ZonesClientCreateOrUpdateOptions) (ZonesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, zoneName, parameters, options) if err != nil { return ZonesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ZonesClientCreateOrUpdateResponse{}, err } @@ -92,7 +83,7 @@ func (client *ZonesClient) createOrUpdateCreateRequest(ctx context.Context, reso 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 } @@ -120,31 +111,33 @@ func (client *ZonesClient) createOrUpdateHandleResponse(resp *http.Response) (Zo // BeginDelete - Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-05-01 -// resourceGroupName - The name of the resource group. -// zoneName - The name of the DNS zone (without a terminating dot). -// options - ZonesClientBeginDeleteOptions contains the optional parameters for the ZonesClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - options - ZonesClientBeginDeleteOptions contains the optional parameters for the ZonesClient.BeginDelete method. func (client *ZonesClient) BeginDelete(ctx context.Context, resourceGroupName string, zoneName string, options *ZonesClientBeginDeleteOptions) (*runtime.Poller[ZonesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, zoneName, options) if err != nil { return nil, err } - return runtime.NewPoller[ZonesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[ZonesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ZonesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ZonesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-05-01 func (client *ZonesClient) deleteOperation(ctx context.Context, resourceGroupName string, zoneName string, options *ZonesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, zoneName, 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 } @@ -169,7 +162,7 @@ func (client *ZonesClient) deleteCreateRequest(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.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,16 +178,17 @@ func (client *ZonesClient) deleteCreateRequest(ctx context.Context, resourceGrou // Get - Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-05-01 -// resourceGroupName - The name of the resource group. -// zoneName - The name of the DNS zone (without a terminating dot). -// options - ZonesClientGetOptions contains the optional parameters for the ZonesClient.Get method. +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - options - ZonesClientGetOptions contains the optional parameters for the ZonesClient.Get method. func (client *ZonesClient) Get(ctx context.Context, resourceGroupName string, zoneName string, options *ZonesClientGetOptions) (ZonesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, zoneName, options) if err != nil { return ZonesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ZonesClientGetResponse{}, err } @@ -219,7 +213,7 @@ func (client *ZonesClient) getCreateRequest(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.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 } @@ -240,9 +234,9 @@ func (client *ZonesClient) getHandleResponse(resp *http.Response) (ZonesClientGe } // NewListPager - Lists the DNS zones in all resource groups in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-05-01 -// options - ZonesClientListOptions contains the optional parameters for the ZonesClient.List method. +// - options - ZonesClientListOptions contains the optional parameters for the ZonesClient.NewListPager method. func (client *ZonesClient) NewListPager(options *ZonesClientListOptions) *runtime.Pager[ZonesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ZonesClientListResponse]{ More: func(page ZonesClientListResponse) bool { @@ -259,7 +253,7 @@ func (client *ZonesClient) NewListPager(options *ZonesClientListOptions) *runtim if err != nil { return ZonesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ZonesClientListResponse{}, err } @@ -278,7 +272,7 @@ func (client *ZonesClient) listCreateRequest(ctx context.Context, options *Zones 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 } @@ -302,11 +296,11 @@ func (client *ZonesClient) listHandleResponse(resp *http.Response) (ZonesClientL } // NewListByResourceGroupPager - Lists the DNS zones within a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-05-01 -// resourceGroupName - The name of the resource group. -// options - ZonesClientListByResourceGroupOptions contains the optional parameters for the ZonesClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. +// - options - ZonesClientListByResourceGroupOptions contains the optional parameters for the ZonesClient.NewListByResourceGroupPager +// method. func (client *ZonesClient) NewListByResourceGroupPager(resourceGroupName string, options *ZonesClientListByResourceGroupOptions) *runtime.Pager[ZonesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[ZonesClientListByResourceGroupResponse]{ More: func(page ZonesClientListByResourceGroupResponse) bool { @@ -323,7 +317,7 @@ func (client *ZonesClient) NewListByResourceGroupPager(resourceGroupName string, if err != nil { return ZonesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ZonesClientListByResourceGroupResponse{}, err } @@ -346,7 +340,7 @@ func (client *ZonesClient) listByResourceGroupCreateRequest(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 } @@ -371,17 +365,18 @@ func (client *ZonesClient) listByResourceGroupHandleResponse(resp *http.Response // Update - Updates a DNS zone. Does not modify DNS records within the zone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-05-01 -// resourceGroupName - The name of the resource group. -// zoneName - The name of the DNS zone (without a terminating dot). -// parameters - Parameters supplied to the Update operation. -// options - ZonesClientUpdateOptions contains the optional parameters for the ZonesClient.Update method. +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - parameters - Parameters supplied to the Update operation. +// - options - ZonesClientUpdateOptions contains the optional parameters for the ZonesClient.Update method. func (client *ZonesClient) Update(ctx context.Context, resourceGroupName string, zoneName string, parameters ZoneUpdate, options *ZonesClientUpdateOptions) (ZonesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, zoneName, parameters, options) if err != nil { return ZonesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ZonesClientUpdateResponse{}, err } @@ -406,7 +401,7 @@ func (client *ZonesClient) updateCreateRequest(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.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/dns/armdns/zones_client_example_test.go b/sdk/resourcemanager/dns/armdns/zones_client_example_test.go new file mode 100644 index 000000000000..5ea55b369314 --- /dev/null +++ b/sdk/resourcemanager/dns/armdns/zones_client_example_test.go @@ -0,0 +1,295 @@ +//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 armdns_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/dns/armdns" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateZone.json +func ExampleZonesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewZonesClient().CreateOrUpdate(ctx, "rg1", "zone1", armdns.Zone{ + Location: to.Ptr("Global"), + Tags: map[string]*string{ + "key1": to.Ptr("value1"), + }, + }, &armdns.ZonesClientCreateOrUpdateOptions{IfMatch: nil, + IfNoneMatch: 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.Zone = armdns.Zone{ + // Name: to.Ptr("zone1"), + // Type: to.Ptr("Microsoft.Network/dnsZones"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1"), + // Location: to.Ptr("global"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdns.ZoneProperties{ + // MaxNumberOfRecordSets: to.Ptr[int64](5000), + // NameServers: []*string{ + // to.Ptr("ns1-01.azure-dns.com"), + // to.Ptr("ns2-01.azure-dns.net"), + // to.Ptr("ns3-01.azure-dns.org"), + // to.Ptr("ns4-01.azure-dns.info")}, + // NumberOfRecordSets: to.Ptr[int64](2), + // ZoneType: to.Ptr(armdns.ZoneTypePublic), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteZone.json +func ExampleZonesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewZonesClient().BeginDelete(ctx, "rg1", "zone1", &armdns.ZonesClientBeginDeleteOptions{IfMatch: 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/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetZone.json +func ExampleZonesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewZonesClient().Get(ctx, "rg1", "zone1", 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.Zone = armdns.Zone{ + // Name: to.Ptr("zone1"), + // Type: to.Ptr("Microsoft.Network/dnsZones"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1"), + // Location: to.Ptr("global"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdns.ZoneProperties{ + // MaxNumberOfRecordSets: to.Ptr[int64](5000), + // NameServers: []*string{ + // to.Ptr("ns1-01.azure-dns.com"), + // to.Ptr("ns2-01.azure-dns.net"), + // to.Ptr("ns3-01.azure-dns.org"), + // to.Ptr("ns4-01.azure-dns.info")}, + // NumberOfRecordSets: to.Ptr[int64](2), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchZone.json +func ExampleZonesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewZonesClient().Update(ctx, "rg1", "zone1", armdns.ZoneUpdate{ + Tags: map[string]*string{ + "key2": to.Ptr("value2"), + }, + }, &armdns.ZonesClientUpdateOptions{IfMatch: 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.Zone = armdns.Zone{ + // Name: to.Ptr("zone1"), + // Type: to.Ptr("Microsoft.Network/dnsZones"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1"), + // Location: to.Ptr("global"), + // Tags: map[string]*string{ + // "key2": to.Ptr("value2"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdns.ZoneProperties{ + // MaxNumberOfRecordSets: to.Ptr[int64](5000), + // NameServers: []*string{ + // to.Ptr("ns1-01.azure-dns.com"), + // to.Ptr("ns2-01.azure-dns.net"), + // to.Ptr("ns3-01.azure-dns.org"), + // to.Ptr("ns4-01.azure-dns.info")}, + // NumberOfRecordSets: to.Ptr[int64](2), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListZonesByResourceGroup.json +func ExampleZonesClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewZonesClient().NewListByResourceGroupPager("rg1", &armdns.ZonesClientListByResourceGroupOptions{Top: 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.ZoneListResult = armdns.ZoneListResult{ + // Value: []*armdns.Zone{ + // { + // Name: to.Ptr("zone1"), + // Type: to.Ptr("Microsoft.Network/dnsZones"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1"), + // Location: to.Ptr("global"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdns.ZoneProperties{ + // MaxNumberOfRecordSets: to.Ptr[int64](5000), + // NameServers: []*string{ + // to.Ptr("ns1-01.azure-dns.com"), + // to.Ptr("ns2-01.azure-dns.net"), + // to.Ptr("ns3-01.azure-dns.org"), + // to.Ptr("ns4-01.azure-dns.info")}, + // NumberOfRecordSets: to.Ptr[int64](2), + // }, + // }, + // { + // Name: to.Ptr("zone2"), + // Type: to.Ptr("Microsoft.Network/dnsZones"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone2"), + // Location: to.Ptr("global"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdns.ZoneProperties{ + // MaxNumberOfRecordSets: to.Ptr[int64](5000), + // NameServers: []*string{ + // to.Ptr("ns1-02.azure-dns.com"), + // to.Ptr("ns2-02.azure-dns.net"), + // to.Ptr("ns3-02.azure-dns.org"), + // to.Ptr("ns4-02.azure-dns.info")}, + // NumberOfRecordSets: to.Ptr[int64](300), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListZonesBySubscription.json +func ExampleZonesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdns.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewZonesClient().NewListPager(&armdns.ZonesClientListOptions{Top: 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.ZoneListResult = armdns.ZoneListResult{ + // Value: []*armdns.Zone{ + // { + // Name: to.Ptr("zone1"), + // Type: to.Ptr("Microsoft.Network/dnsZones"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/dnsZones/zone1"), + // Location: to.Ptr("global"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdns.ZoneProperties{ + // MaxNumberOfRecordSets: to.Ptr[int64](5000), + // NameServers: []*string{ + // to.Ptr("ns1-01.azure-dns.com"), + // to.Ptr("ns2-01.azure-dns.net"), + // to.Ptr("ns3-01.azure-dns.org"), + // to.Ptr("ns4-01.azure-dns.info")}, + // NumberOfRecordSets: to.Ptr[int64](2), + // }, + // }, + // { + // Name: to.Ptr("zone2"), + // Type: to.Ptr("Microsoft.Network/dnsZones"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/dnsZones/zone2"), + // Location: to.Ptr("global"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdns.ZoneProperties{ + // MaxNumberOfRecordSets: to.Ptr[int64](5000), + // NameServers: []*string{ + // to.Ptr("ns1-02.azure-dns.com"), + // to.Ptr("ns2-02.azure-dns.net"), + // to.Ptr("ns3-02.azure-dns.org"), + // to.Ptr("ns4-02.azure-dns.info")}, + // NumberOfRecordSets: to.Ptr[int64](300), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/dns/armdns/zz_generated_models_serde.go b/sdk/resourcemanager/dns/armdns/zz_generated_models_serde.go deleted file mode 100644 index 9e93a4ecb78a..000000000000 --- a/sdk/resourcemanager/dns/armdns/zz_generated_models_serde.go +++ /dev/null @@ -1,115 +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 armdns - -import ( - "encoding/json" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type RecordSet. -func (r RecordSet) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "etag", r.Etag) - populate(objectMap, "id", r.ID) - populate(objectMap, "name", r.Name) - populate(objectMap, "properties", r.Properties) - populate(objectMap, "type", r.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type RecordSetProperties. -func (r RecordSetProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "ARecords", r.ARecords) - populate(objectMap, "AAAARecords", r.AaaaRecords) - populate(objectMap, "caaRecords", r.CaaRecords) - populate(objectMap, "CNAMERecord", r.CnameRecord) - populate(objectMap, "fqdn", r.Fqdn) - populate(objectMap, "metadata", r.Metadata) - populate(objectMap, "MXRecords", r.MxRecords) - populate(objectMap, "NSRecords", r.NsRecords) - populate(objectMap, "provisioningState", r.ProvisioningState) - populate(objectMap, "PTRRecords", r.PtrRecords) - populate(objectMap, "SOARecord", r.SoaRecord) - populate(objectMap, "SRVRecords", r.SrvRecords) - populate(objectMap, "TTL", r.TTL) - populate(objectMap, "targetResource", r.TargetResource) - populate(objectMap, "TXTRecords", r.TxtRecords) - 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, "tags", r.Tags) - populate(objectMap, "type", r.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ResourceReferenceRequestProperties. -func (r ResourceReferenceRequestProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "targetResources", r.TargetResources) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TxtRecord. -func (t TxtRecord) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "value", t.Value) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Zone. -func (z Zone) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "etag", z.Etag) - populate(objectMap, "id", z.ID) - populate(objectMap, "location", z.Location) - populate(objectMap, "name", z.Name) - populate(objectMap, "properties", z.Properties) - populate(objectMap, "tags", z.Tags) - populate(objectMap, "type", z.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ZoneProperties. -func (z ZoneProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "maxNumberOfRecordSets", z.MaxNumberOfRecordSets) - populate(objectMap, "maxNumberOfRecordsPerRecordSet", z.MaxNumberOfRecordsPerRecordSet) - populate(objectMap, "nameServers", z.NameServers) - populate(objectMap, "numberOfRecordSets", z.NumberOfRecordSets) - populate(objectMap, "registrationVirtualNetworks", z.RegistrationVirtualNetworks) - populate(objectMap, "resolutionVirtualNetworks", z.ResolutionVirtualNetworks) - populate(objectMap, "zoneType", z.ZoneType) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ZoneUpdate. -func (z ZoneUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", z.Tags) - 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 - } -} diff --git a/sdk/resourcemanager/dnsresolver/armdnsresolver/CHANGELOG.md b/sdk/resourcemanager/dnsresolver/armdnsresolver/CHANGELOG.md index 33cc57a613a5..9bd7dc18b0b8 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/CHANGELOG.md +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-09-15) ### Breaking Changes diff --git a/sdk/resourcemanager/dnsresolver/armdnsresolver/README.md b/sdk/resourcemanager/dnsresolver/armdnsresolver/README.md index 42ba2d55a9ac..d6de7275e0d2 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/README.md +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/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 DNS Private Resolver 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 DNS Private Resolver 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 := armdnsresolver.NewOutboundEndpointsClient(, cred, nil) +clientFactory, err := armdnsresolver.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 := armdnsresolver.NewOutboundEndpointsClient(, cred, &options) +clientFactory, err := armdnsresolver.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.NewDNSResolversClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/dnsresolver/armdnsresolver/autorest.md b/sdk/resourcemanager/dnsresolver/armdnsresolver/autorest.md index 347a625efffc..294144e16f8b 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/autorest.md +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/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/dnsresolver/armdnsresolver/client_factory.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/client_factory.go new file mode 100644 index 000000000000..1816140001ed --- /dev/null +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/client_factory.go @@ -0,0 +1,69 @@ +//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 armdnsresolver + +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) NewDNSResolversClient() *DNSResolversClient { + subClient, _ := NewDNSResolversClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewInboundEndpointsClient() *InboundEndpointsClient { + subClient, _ := NewInboundEndpointsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOutboundEndpointsClient() *OutboundEndpointsClient { + subClient, _ := NewOutboundEndpointsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDNSForwardingRulesetsClient() *DNSForwardingRulesetsClient { + subClient, _ := NewDNSForwardingRulesetsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewForwardingRulesClient() *ForwardingRulesClient { + subClient, _ := NewForwardingRulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVirtualNetworkLinksClient() *VirtualNetworkLinksClient { + subClient, _ := NewVirtualNetworkLinksClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/dnsresolver/armdnsresolver/constants.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/constants.go index 38c23e7913f2..5407856daded 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/constants.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/constants.go @@ -11,7 +11,7 @@ package armdnsresolver const ( moduleName = "armdnsresolver" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/dnsresolver/armdnsresolver/dnsforwardingrulesets_client.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/dnsforwardingrulesets_client.go index 9971907c74d6..a987fa7a6a39 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/dnsforwardingrulesets_client.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/dnsforwardingrulesets_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 ( // DNSForwardingRulesetsClient contains the methods for the DNSForwardingRulesets group. // Don't use this type directly, use NewDNSForwardingRulesetsClient() instead. type DNSForwardingRulesetsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDNSForwardingRulesetsClient creates a new instance of DNSForwardingRulesetsClient 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 NewDNSForwardingRulesetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DNSForwardingRulesetsClient, 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+".DNSForwardingRulesetsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DNSForwardingRulesetsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a DNS forwarding ruleset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsForwardingRulesetName - The name of the DNS forwarding ruleset. -// parameters - Parameters supplied to the CreateOrUpdate operation. -// options - DNSForwardingRulesetsClientBeginCreateOrUpdateOptions contains the optional parameters for the DNSForwardingRulesetsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsForwardingRulesetName - The name of the DNS forwarding ruleset. +// - parameters - Parameters supplied to the CreateOrUpdate operation. +// - options - DNSForwardingRulesetsClientBeginCreateOrUpdateOptions contains the optional parameters for the DNSForwardingRulesetsClient.BeginCreateOrUpdate +// method. func (client *DNSForwardingRulesetsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, parameters DNSForwardingRuleset, options *DNSForwardingRulesetsClientBeginCreateOrUpdateOptions) (*runtime.Poller[DNSForwardingRulesetsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, dnsForwardingRulesetName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[DNSForwardingRulesetsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[DNSForwardingRulesetsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DNSForwardingRulesetsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DNSForwardingRulesetsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a DNS forwarding ruleset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 func (client *DNSForwardingRulesetsClient) createOrUpdate(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, parameters DNSForwardingRuleset, options *DNSForwardingRulesetsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, dnsForwardingRulesetName, 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 *DNSForwardingRulesetsClient) createOrUpdateCreateRequest(ctx conte return nil, errors.New("parameter dnsForwardingRulesetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dnsForwardingRulesetName}", url.PathEscape(dnsForwardingRulesetName)) - 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 } @@ -129,33 +120,35 @@ func (client *DNSForwardingRulesetsClient) createOrUpdateCreateRequest(ctx conte // BeginDelete - Deletes a DNS forwarding ruleset. WARNING: This operation cannot be undone. All forwarding rules within the // ruleset will be deleted. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsForwardingRulesetName - The name of the DNS forwarding ruleset. -// options - DNSForwardingRulesetsClientBeginDeleteOptions contains the optional parameters for the DNSForwardingRulesetsClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsForwardingRulesetName - The name of the DNS forwarding ruleset. +// - options - DNSForwardingRulesetsClientBeginDeleteOptions contains the optional parameters for the DNSForwardingRulesetsClient.BeginDelete +// method. func (client *DNSForwardingRulesetsClient) BeginDelete(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, options *DNSForwardingRulesetsClientBeginDeleteOptions) (*runtime.Poller[DNSForwardingRulesetsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, dnsForwardingRulesetName, options) if err != nil { return nil, err } - return runtime.NewPoller[DNSForwardingRulesetsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[DNSForwardingRulesetsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DNSForwardingRulesetsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DNSForwardingRulesetsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a DNS forwarding ruleset. WARNING: This operation cannot be undone. All forwarding rules within the ruleset // will be deleted. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 func (client *DNSForwardingRulesetsClient) deleteOperation(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, options *DNSForwardingRulesetsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, dnsForwardingRulesetName, 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 +173,7 @@ func (client *DNSForwardingRulesetsClient) deleteCreateRequest(ctx context.Conte return nil, errors.New("parameter dnsForwardingRulesetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dnsForwardingRulesetName}", url.PathEscape(dnsForwardingRulesetName)) - 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 } @@ -196,17 +189,18 @@ func (client *DNSForwardingRulesetsClient) deleteCreateRequest(ctx context.Conte // Get - Gets a DNS forwarding ruleset properties. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsForwardingRulesetName - The name of the DNS forwarding ruleset. -// options - DNSForwardingRulesetsClientGetOptions contains the optional parameters for the DNSForwardingRulesetsClient.Get -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsForwardingRulesetName - The name of the DNS forwarding ruleset. +// - options - DNSForwardingRulesetsClientGetOptions contains the optional parameters for the DNSForwardingRulesetsClient.Get +// method. func (client *DNSForwardingRulesetsClient) Get(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, options *DNSForwardingRulesetsClientGetOptions) (DNSForwardingRulesetsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, dnsForwardingRulesetName, options) if err != nil { return DNSForwardingRulesetsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DNSForwardingRulesetsClientGetResponse{}, err } @@ -231,7 +225,7 @@ func (client *DNSForwardingRulesetsClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter dnsForwardingRulesetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dnsForwardingRulesetName}", url.PathEscape(dnsForwardingRulesetName)) - 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,9 +246,10 @@ func (client *DNSForwardingRulesetsClient) getHandleResponse(resp *http.Response } // NewListPager - Lists DNS forwarding rulesets in all resource groups of a subscription. +// // Generated from API version 2022-07-01 -// options - DNSForwardingRulesetsClientListOptions contains the optional parameters for the DNSForwardingRulesetsClient.List -// method. +// - options - DNSForwardingRulesetsClientListOptions contains the optional parameters for the DNSForwardingRulesetsClient.NewListPager +// method. func (client *DNSForwardingRulesetsClient) NewListPager(options *DNSForwardingRulesetsClientListOptions) *runtime.Pager[DNSForwardingRulesetsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[DNSForwardingRulesetsClientListResponse]{ More: func(page DNSForwardingRulesetsClientListResponse) bool { @@ -271,7 +266,7 @@ func (client *DNSForwardingRulesetsClient) NewListPager(options *DNSForwardingRu if err != nil { return DNSForwardingRulesetsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DNSForwardingRulesetsClientListResponse{}, err } @@ -290,7 +285,7 @@ func (client *DNSForwardingRulesetsClient) 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 } @@ -314,10 +309,11 @@ func (client *DNSForwardingRulesetsClient) listHandleResponse(resp *http.Respons } // NewListByResourceGroupPager - Lists DNS forwarding rulesets within a resource group. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - DNSForwardingRulesetsClientListByResourceGroupOptions contains the optional parameters for the DNSForwardingRulesetsClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - DNSForwardingRulesetsClientListByResourceGroupOptions contains the optional parameters for the DNSForwardingRulesetsClient.NewListByResourceGroupPager +// method. func (client *DNSForwardingRulesetsClient) NewListByResourceGroupPager(resourceGroupName string, options *DNSForwardingRulesetsClientListByResourceGroupOptions) *runtime.Pager[DNSForwardingRulesetsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[DNSForwardingRulesetsClientListByResourceGroupResponse]{ More: func(page DNSForwardingRulesetsClientListByResourceGroupResponse) bool { @@ -334,7 +330,7 @@ func (client *DNSForwardingRulesetsClient) NewListByResourceGroupPager(resourceG if err != nil { return DNSForwardingRulesetsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DNSForwardingRulesetsClientListByResourceGroupResponse{}, err } @@ -357,7 +353,7 @@ func (client *DNSForwardingRulesetsClient) 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 } @@ -381,11 +377,12 @@ func (client *DNSForwardingRulesetsClient) listByResourceGroupHandleResponse(res } // NewListByVirtualNetworkPager - Lists DNS forwarding ruleset resource IDs attached to a virtual network. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// virtualNetworkName - The name of the virtual network. -// options - DNSForwardingRulesetsClientListByVirtualNetworkOptions contains the optional parameters for the DNSForwardingRulesetsClient.ListByVirtualNetwork -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualNetworkName - The name of the virtual network. +// - options - DNSForwardingRulesetsClientListByVirtualNetworkOptions contains the optional parameters for the DNSForwardingRulesetsClient.NewListByVirtualNetworkPager +// method. func (client *DNSForwardingRulesetsClient) NewListByVirtualNetworkPager(resourceGroupName string, virtualNetworkName string, options *DNSForwardingRulesetsClientListByVirtualNetworkOptions) *runtime.Pager[DNSForwardingRulesetsClientListByVirtualNetworkResponse] { return runtime.NewPager(runtime.PagingHandler[DNSForwardingRulesetsClientListByVirtualNetworkResponse]{ More: func(page DNSForwardingRulesetsClientListByVirtualNetworkResponse) bool { @@ -402,7 +399,7 @@ func (client *DNSForwardingRulesetsClient) NewListByVirtualNetworkPager(resource if err != nil { return DNSForwardingRulesetsClientListByVirtualNetworkResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DNSForwardingRulesetsClientListByVirtualNetworkResponse{}, err } @@ -429,7 +426,7 @@ func (client *DNSForwardingRulesetsClient) listByVirtualNetworkCreateRequest(ctx return nil, errors.New("parameter virtualNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkName}", url.PathEscape(virtualNetworkName)) - 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 } @@ -454,33 +451,35 @@ func (client *DNSForwardingRulesetsClient) listByVirtualNetworkHandleResponse(re // BeginUpdate - Updates a DNS forwarding ruleset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsForwardingRulesetName - The name of the DNS forwarding ruleset. -// parameters - Parameters supplied to the Update operation. -// options - DNSForwardingRulesetsClientBeginUpdateOptions contains the optional parameters for the DNSForwardingRulesetsClient.BeginUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsForwardingRulesetName - The name of the DNS forwarding ruleset. +// - parameters - Parameters supplied to the Update operation. +// - options - DNSForwardingRulesetsClientBeginUpdateOptions contains the optional parameters for the DNSForwardingRulesetsClient.BeginUpdate +// method. func (client *DNSForwardingRulesetsClient) BeginUpdate(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, parameters DNSForwardingRulesetPatch, options *DNSForwardingRulesetsClientBeginUpdateOptions) (*runtime.Poller[DNSForwardingRulesetsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, dnsForwardingRulesetName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[DNSForwardingRulesetsClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[DNSForwardingRulesetsClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DNSForwardingRulesetsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DNSForwardingRulesetsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates a DNS forwarding ruleset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 func (client *DNSForwardingRulesetsClient) update(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, parameters DNSForwardingRulesetPatch, options *DNSForwardingRulesetsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, dnsForwardingRulesetName, 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 } @@ -505,7 +504,7 @@ func (client *DNSForwardingRulesetsClient) updateCreateRequest(ctx context.Conte return nil, errors.New("parameter dnsForwardingRulesetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dnsForwardingRulesetName}", url.PathEscape(dnsForwardingRulesetName)) - 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/dnsresolver/armdnsresolver/dnsforwardingrulesets_client_example_test.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/dnsforwardingrulesets_client_example_test.go index 8aec477decbc..e307ac0cadc3 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/dnsforwardingrulesets_client_example_test.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/dnsforwardingrulesets_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 armdnsresolver_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dnsresolver/armdnsresolver" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_Put.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_Put.json func ExampleDNSForwardingRulesetsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewDNSForwardingRulesetsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "sampleResourceGroup", "samplednsForwardingRuleset", armdnsresolver.DNSForwardingRuleset{ + poller, err := clientFactory.NewDNSForwardingRulesetsClient().BeginCreateOrUpdate(ctx, "sampleResourceGroup", "samplednsForwardingRuleset", armdnsresolver.DNSForwardingRuleset{ Location: to.Ptr("westus2"), Tags: map[string]*string{ "key1": to.Ptr("value1"), @@ -52,22 +53,50 @@ func ExampleDNSForwardingRulesetsClient_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.DNSForwardingRuleset = armdnsresolver.DNSForwardingRuleset{ + // Name: to.Ptr("sampleDnsForwardingRuleset"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRulesets/sampleDnsForwardingRuleset"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.DNSForwardingRulesetProperties{ + // DNSResolverOutboundEndpoints: []*armdnsresolver.SubResource{ + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint0"), + // }, + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint1"), + // }}, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("a7e1a32c-498c-401c-a805-5bc3518257b8"), + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-03T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-04T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_Patch.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_Patch.json func ExampleDNSForwardingRulesetsClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewDNSForwardingRulesetsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", armdnsresolver.DNSForwardingRulesetPatch{ + poller, err := clientFactory.NewDNSForwardingRulesetsClient().BeginUpdate(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", armdnsresolver.DNSForwardingRulesetPatch{ Tags: map[string]*string{ "key1": to.Ptr("value1"), }, @@ -79,22 +108,50 @@ func ExampleDNSForwardingRulesetsClient_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.DNSForwardingRuleset = armdnsresolver.DNSForwardingRuleset{ + // Name: to.Ptr("sampleDnsForwardingRuleset"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRulesets/sampleDnsForwardingRuleset"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.DNSForwardingRulesetProperties{ + // DNSResolverOutboundEndpoints: []*armdnsresolver.SubResource{ + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint0"), + // }, + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint1"), + // }}, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("a7e1a32c-498c-401c-a805-5bc3518257b8"), + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-03T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-04T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_Delete.json func ExampleDNSForwardingRulesetsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewDNSForwardingRulesetsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "sampleResourceGroup", "samplednsForwardingRulesetName", &armdnsresolver.DNSForwardingRulesetsClientBeginDeleteOptions{IfMatch: nil}) + poller, err := clientFactory.NewDNSForwardingRulesetsClient().BeginDelete(ctx, "sampleResourceGroup", "samplednsForwardingRulesetName", &armdnsresolver.DNSForwardingRulesetsClientBeginDeleteOptions{IfMatch: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -104,93 +161,249 @@ func ExampleDNSForwardingRulesetsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_Get.json func ExampleDNSForwardingRulesetsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewDNSForwardingRulesetsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", nil) + res, err := clientFactory.NewDNSForwardingRulesetsClient().Get(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", 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.DNSForwardingRuleset = armdnsresolver.DNSForwardingRuleset{ + // Name: to.Ptr("sampleDnsForwardingRuleset"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRulesets/sampleDnsForwardingRuleset"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.DNSForwardingRulesetProperties{ + // DNSResolverOutboundEndpoints: []*armdnsresolver.SubResource{ + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint0"), + // }, + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint1"), + // }}, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("a7e1a32c-498c-401c-a805-5bc3518257b8"), + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-03T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-04T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_ListByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_ListByResourceGroup.json func ExampleDNSForwardingRulesetsClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewDNSForwardingRulesetsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("sampleResourceGroup", &armdnsresolver.DNSForwardingRulesetsClientListByResourceGroupOptions{Top: nil}) + pager := clientFactory.NewDNSForwardingRulesetsClient().NewListByResourceGroupPager("sampleResourceGroup", &armdnsresolver.DNSForwardingRulesetsClientListByResourceGroupOptions{Top: 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.DNSForwardingRulesetListResult = armdnsresolver.DNSForwardingRulesetListResult{ + // Value: []*armdnsresolver.DNSForwardingRuleset{ + // { + // Name: to.Ptr("sampleDnsForwardingRuleset"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRulesets/sampleDnsForwardingRuleset"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.DNSForwardingRulesetProperties{ + // DNSResolverOutboundEndpoints: []*armdnsresolver.SubResource{ + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint0"), + // }, + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint1"), + // }}, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("a7e1a32c-498c-401c-a805-5bc3518257b8"), + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-03T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-04T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // }, + // { + // Name: to.Ptr("sampleDnsForwardingRuleset"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRulesets/sampleDnsForwardingRuleset1"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.DNSForwardingRulesetProperties{ + // DNSResolverOutboundEndpoints: []*armdnsresolver.SubResource{ + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint2"), + // }, + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint3"), + // }}, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("c2aed17a-708d-48d1-89c3-d6a9b648d222"), + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-04T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-05T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_ListBySubscription.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_ListBySubscription.json func ExampleDNSForwardingRulesetsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewDNSForwardingRulesetsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(&armdnsresolver.DNSForwardingRulesetsClientListOptions{Top: nil}) + pager := clientFactory.NewDNSForwardingRulesetsClient().NewListPager(&armdnsresolver.DNSForwardingRulesetsClientListOptions{Top: 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.DNSForwardingRulesetListResult = armdnsresolver.DNSForwardingRulesetListResult{ + // Value: []*armdnsresolver.DNSForwardingRuleset{ + // { + // Name: to.Ptr("sampleDnsForwardingRuleset"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRulesets/sampleDnsForwardingRuleset"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.DNSForwardingRulesetProperties{ + // DNSResolverOutboundEndpoints: []*armdnsresolver.SubResource{ + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint0"), + // }, + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint1"), + // }}, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("a7e1a32c-498c-401c-a805-5bc3518257b8"), + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-03T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-04T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // }, + // { + // Name: to.Ptr("sampleDnsForwardingRuleset"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRulesets/sampleDnsForwardingRuleset1"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.DNSForwardingRulesetProperties{ + // DNSResolverOutboundEndpoints: []*armdnsresolver.SubResource{ + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint2"), + // }, + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint3"), + // }}, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("a7e1a32c-498c-401c-a805-5bc3518257b8"), + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-04T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-05T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_ListByVirtualNetwork.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_ListByVirtualNetwork.json func ExampleDNSForwardingRulesetsClient_NewListByVirtualNetworkPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewDNSForwardingRulesetsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByVirtualNetworkPager("sampleResourceGroup", "sampleVirtualNetwork", &armdnsresolver.DNSForwardingRulesetsClientListByVirtualNetworkOptions{Top: nil}) + pager := clientFactory.NewDNSForwardingRulesetsClient().NewListByVirtualNetworkPager("sampleResourceGroup", "sampleVirtualNetwork", &armdnsresolver.DNSForwardingRulesetsClientListByVirtualNetworkOptions{Top: 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.VirtualNetworkDNSForwardingRulesetListResult = armdnsresolver.VirtualNetworkDNSForwardingRulesetListResult{ + // Value: []*armdnsresolver.VirtualNetworkDNSForwardingRuleset{ + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRulesets/sampleDnsForwardingRuleset"), + // Properties: &armdnsresolver.VirtualNetworkLinkSubResourceProperties{ + // VirtualNetworkLink: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRuleset/sampleDnsForwardingRuleset/virtualNetworkLinks/sampleVirtualNetworkLink"), + // }, + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/dnsresolver/armdnsresolver/dnsresolvers_client.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/dnsresolvers_client.go index 76af1377fabb..cb91f96859f4 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/dnsresolvers_client.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/dnsresolvers_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 ( // DNSResolversClient contains the methods for the DNSResolvers group. // Don't use this type directly, use NewDNSResolversClient() instead. type DNSResolversClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDNSResolversClient creates a new instance of DNSResolversClient 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 NewDNSResolversClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DNSResolversClient, 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+".DNSResolversClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DNSResolversClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a DNS resolver. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsResolverName - The name of the DNS resolver. -// parameters - Parameters supplied to the CreateOrUpdate operation. -// options - DNSResolversClientBeginCreateOrUpdateOptions contains the optional parameters for the DNSResolversClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsResolverName - The name of the DNS resolver. +// - parameters - Parameters supplied to the CreateOrUpdate operation. +// - options - DNSResolversClientBeginCreateOrUpdateOptions contains the optional parameters for the DNSResolversClient.BeginCreateOrUpdate +// method. func (client *DNSResolversClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, dnsResolverName string, parameters DNSResolver, options *DNSResolversClientBeginCreateOrUpdateOptions) (*runtime.Poller[DNSResolversClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, dnsResolverName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[DNSResolversClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[DNSResolversClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DNSResolversClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DNSResolversClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a DNS resolver. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 func (client *DNSResolversClient) createOrUpdate(ctx context.Context, resourceGroupName string, dnsResolverName string, parameters DNSResolver, options *DNSResolversClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, dnsResolverName, 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 *DNSResolversClient) createOrUpdateCreateRequest(ctx context.Contex return nil, errors.New("parameter dnsResolverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dnsResolverName}", url.PathEscape(dnsResolverName)) - 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,32 +119,34 @@ func (client *DNSResolversClient) createOrUpdateCreateRequest(ctx context.Contex // BeginDelete - Deletes a DNS resolver. WARNING: This operation cannot be undone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsResolverName - The name of the DNS resolver. -// options - DNSResolversClientBeginDeleteOptions contains the optional parameters for the DNSResolversClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsResolverName - The name of the DNS resolver. +// - options - DNSResolversClientBeginDeleteOptions contains the optional parameters for the DNSResolversClient.BeginDelete +// method. func (client *DNSResolversClient) BeginDelete(ctx context.Context, resourceGroupName string, dnsResolverName string, options *DNSResolversClientBeginDeleteOptions) (*runtime.Poller[DNSResolversClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, dnsResolverName, options) if err != nil { return nil, err } - return runtime.NewPoller[DNSResolversClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[DNSResolversClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DNSResolversClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DNSResolversClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a DNS resolver. WARNING: This operation cannot be undone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 func (client *DNSResolversClient) deleteOperation(ctx context.Context, resourceGroupName string, dnsResolverName string, options *DNSResolversClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, dnsResolverName, 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 *DNSResolversClient) deleteCreateRequest(ctx context.Context, resou return nil, errors.New("parameter dnsResolverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dnsResolverName}", url.PathEscape(dnsResolverName)) - 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 } @@ -194,16 +187,17 @@ func (client *DNSResolversClient) deleteCreateRequest(ctx context.Context, resou // Get - Gets properties of a DNS resolver. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsResolverName - The name of the DNS resolver. -// options - DNSResolversClientGetOptions contains the optional parameters for the DNSResolversClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsResolverName - The name of the DNS resolver. +// - options - DNSResolversClientGetOptions contains the optional parameters for the DNSResolversClient.Get method. func (client *DNSResolversClient) Get(ctx context.Context, resourceGroupName string, dnsResolverName string, options *DNSResolversClientGetOptions) (DNSResolversClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, dnsResolverName, options) if err != nil { return DNSResolversClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DNSResolversClientGetResponse{}, err } @@ -228,7 +222,7 @@ func (client *DNSResolversClient) getCreateRequest(ctx context.Context, resource return nil, errors.New("parameter dnsResolverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dnsResolverName}", url.PathEscape(dnsResolverName)) - 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 } @@ -249,8 +243,9 @@ func (client *DNSResolversClient) getHandleResponse(resp *http.Response) (DNSRes } // NewListPager - Lists DNS resolvers in all resource groups of a subscription. +// // Generated from API version 2022-07-01 -// options - DNSResolversClientListOptions contains the optional parameters for the DNSResolversClient.List method. +// - options - DNSResolversClientListOptions contains the optional parameters for the DNSResolversClient.NewListPager method. func (client *DNSResolversClient) NewListPager(options *DNSResolversClientListOptions) *runtime.Pager[DNSResolversClientListResponse] { return runtime.NewPager(runtime.PagingHandler[DNSResolversClientListResponse]{ More: func(page DNSResolversClientListResponse) bool { @@ -267,7 +262,7 @@ func (client *DNSResolversClient) NewListPager(options *DNSResolversClientListOp if err != nil { return DNSResolversClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DNSResolversClientListResponse{}, err } @@ -286,7 +281,7 @@ func (client *DNSResolversClient) 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 } @@ -310,10 +305,11 @@ func (client *DNSResolversClient) listHandleResponse(resp *http.Response) (DNSRe } // NewListByResourceGroupPager - Lists DNS resolvers within a resource group. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - DNSResolversClientListByResourceGroupOptions contains the optional parameters for the DNSResolversClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - DNSResolversClientListByResourceGroupOptions contains the optional parameters for the DNSResolversClient.NewListByResourceGroupPager +// method. func (client *DNSResolversClient) NewListByResourceGroupPager(resourceGroupName string, options *DNSResolversClientListByResourceGroupOptions) *runtime.Pager[DNSResolversClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[DNSResolversClientListByResourceGroupResponse]{ More: func(page DNSResolversClientListByResourceGroupResponse) bool { @@ -330,7 +326,7 @@ func (client *DNSResolversClient) NewListByResourceGroupPager(resourceGroupName if err != nil { return DNSResolversClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DNSResolversClientListByResourceGroupResponse{}, err } @@ -353,7 +349,7 @@ func (client *DNSResolversClient) listByResourceGroupCreateRequest(ctx context.C 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 } @@ -377,11 +373,12 @@ func (client *DNSResolversClient) listByResourceGroupHandleResponse(resp *http.R } // NewListByVirtualNetworkPager - Lists DNS resolver resource IDs linked to a virtual network. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// virtualNetworkName - The name of the virtual network. -// options - DNSResolversClientListByVirtualNetworkOptions contains the optional parameters for the DNSResolversClient.ListByVirtualNetwork -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualNetworkName - The name of the virtual network. +// - options - DNSResolversClientListByVirtualNetworkOptions contains the optional parameters for the DNSResolversClient.NewListByVirtualNetworkPager +// method. func (client *DNSResolversClient) NewListByVirtualNetworkPager(resourceGroupName string, virtualNetworkName string, options *DNSResolversClientListByVirtualNetworkOptions) *runtime.Pager[DNSResolversClientListByVirtualNetworkResponse] { return runtime.NewPager(runtime.PagingHandler[DNSResolversClientListByVirtualNetworkResponse]{ More: func(page DNSResolversClientListByVirtualNetworkResponse) bool { @@ -398,7 +395,7 @@ func (client *DNSResolversClient) NewListByVirtualNetworkPager(resourceGroupName if err != nil { return DNSResolversClientListByVirtualNetworkResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DNSResolversClientListByVirtualNetworkResponse{}, err } @@ -425,7 +422,7 @@ func (client *DNSResolversClient) listByVirtualNetworkCreateRequest(ctx context. return nil, errors.New("parameter virtualNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkName}", url.PathEscape(virtualNetworkName)) - 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 } @@ -450,33 +447,35 @@ func (client *DNSResolversClient) listByVirtualNetworkHandleResponse(resp *http. // BeginUpdate - Updates a DNS resolver. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsResolverName - The name of the DNS resolver. -// parameters - Parameters supplied to the Update operation. -// options - DNSResolversClientBeginUpdateOptions contains the optional parameters for the DNSResolversClient.BeginUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsResolverName - The name of the DNS resolver. +// - parameters - Parameters supplied to the Update operation. +// - options - DNSResolversClientBeginUpdateOptions contains the optional parameters for the DNSResolversClient.BeginUpdate +// method. func (client *DNSResolversClient) BeginUpdate(ctx context.Context, resourceGroupName string, dnsResolverName string, parameters Patch, options *DNSResolversClientBeginUpdateOptions) (*runtime.Poller[DNSResolversClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, dnsResolverName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[DNSResolversClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[DNSResolversClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DNSResolversClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DNSResolversClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates a DNS resolver. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 func (client *DNSResolversClient) update(ctx context.Context, resourceGroupName string, dnsResolverName string, parameters Patch, options *DNSResolversClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, dnsResolverName, 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 } @@ -501,7 +500,7 @@ func (client *DNSResolversClient) updateCreateRequest(ctx context.Context, resou return nil, errors.New("parameter dnsResolverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dnsResolverName}", url.PathEscape(dnsResolverName)) - 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/dnsresolver/armdnsresolver/dnsresolvers_client_example_test.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/dnsresolvers_client_example_test.go index 7054683255c8..01458e4dd415 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/dnsresolvers_client_example_test.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/dnsresolvers_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 armdnsresolver_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dnsresolver/armdnsresolver" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_Put.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_Put.json func ExampleDNSResolversClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewDNSResolversClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "sampleResourceGroup", "sampleDnsResolver", armdnsresolver.DNSResolver{ + poller, err := clientFactory.NewDNSResolversClient().BeginCreateOrUpdate(ctx, "sampleResourceGroup", "sampleDnsResolver", armdnsresolver.DNSResolver{ Location: to.Ptr("westus2"), Tags: map[string]*string{ "key1": to.Ptr("value1"), @@ -48,22 +49,47 @@ func ExampleDNSResolversClient_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.DNSResolver = armdnsresolver.DNSResolver{ + // Name: to.Ptr("sampleDnsResolver"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.Properties{ + // DNSResolverState: to.Ptr(armdnsresolver.DNSResolverStateConnected), + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("b6b2d964-8588-4e3a-a7fe-8a5b7fe8eca5"), + // VirtualNetwork: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/cbb1387e-4b03-44f2-ad41-58d4677b9873/resourceGroups/virtualNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_Patch.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_Patch.json func ExampleDNSResolversClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewDNSResolversClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "sampleResourceGroup", "sampleDnsResolver", armdnsresolver.Patch{ + poller, err := clientFactory.NewDNSResolversClient().BeginUpdate(ctx, "sampleResourceGroup", "sampleDnsResolver", armdnsresolver.Patch{ Tags: map[string]*string{ "key1": to.Ptr("value1"), }, @@ -75,22 +101,47 @@ func ExampleDNSResolversClient_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.DNSResolver = armdnsresolver.DNSResolver{ + // Name: to.Ptr("sampleDnsResolver"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.Properties{ + // DNSResolverState: to.Ptr(armdnsresolver.DNSResolverStateConnected), + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("b6b2d964-8588-4e3a-a7fe-8a5b7fe8eca5"), + // VirtualNetwork: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/cbb1387e-4b03-44f2-ad41-58d4677b9873/resourceGroups/virtualNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_Delete.json func ExampleDNSResolversClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewDNSResolversClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "sampleResourceGroup", "sampleDnsResolver", &armdnsresolver.DNSResolversClientBeginDeleteOptions{IfMatch: nil}) + poller, err := clientFactory.NewDNSResolversClient().BeginDelete(ctx, "sampleResourceGroup", "sampleDnsResolver", &armdnsresolver.DNSResolversClientBeginDeleteOptions{IfMatch: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -100,93 +151,229 @@ func ExampleDNSResolversClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_Get.json func ExampleDNSResolversClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewDNSResolversClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "sampleResourceGroup", "sampleDnsResolver", nil) + res, err := clientFactory.NewDNSResolversClient().Get(ctx, "sampleResourceGroup", "sampleDnsResolver", 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.DNSResolver = armdnsresolver.DNSResolver{ + // Name: to.Ptr("sampleDnsResolver"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.Properties{ + // DNSResolverState: to.Ptr(armdnsresolver.DNSResolverStateConnected), + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("a7e1a32c-498c-401c-a805-5bc3518257b8"), + // VirtualNetwork: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/cbb1387e-4b03-44f2-ad41-58d4677b9873/resourceGroups/virtualNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-03T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-04T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_ListByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_ListByResourceGroup.json func ExampleDNSResolversClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewDNSResolversClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("sampleResourceGroup", &armdnsresolver.DNSResolversClientListByResourceGroupOptions{Top: nil}) + pager := clientFactory.NewDNSResolversClient().NewListByResourceGroupPager("sampleResourceGroup", &armdnsresolver.DNSResolversClientListByResourceGroupOptions{Top: 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 = armdnsresolver.ListResult{ + // Value: []*armdnsresolver.DNSResolver{ + // { + // Name: to.Ptr("sampleDnsResolver1"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver1"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.Properties{ + // DNSResolverState: to.Ptr(armdnsresolver.DNSResolverStateConnected), + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("ad9c8da4-3bb2-4821-a878-c2cb07b01fb6"), + // VirtualNetwork: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/cbb1387e-4b03-44f2-ad41-58d4677b9873/resourceGroups/virtualNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork1"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // }, + // { + // Name: to.Ptr("sampleDnsResolver2"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver2"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.Properties{ + // DNSResolverState: to.Ptr(armdnsresolver.DNSResolverStateConnected), + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("b6b2d964-8588-4e3a-a7fe-8a5b7fe8eca5"), + // VirtualNetwork: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/cbb1387e-4b03-44f2-ad41-58d4677b9873/resourceGroups/virtualNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork2"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-03T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-04T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_ListBySubscription.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_ListBySubscription.json func ExampleDNSResolversClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewDNSResolversClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(&armdnsresolver.DNSResolversClientListOptions{Top: nil}) + pager := clientFactory.NewDNSResolversClient().NewListPager(&armdnsresolver.DNSResolversClientListOptions{Top: 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 = armdnsresolver.ListResult{ + // Value: []*armdnsresolver.DNSResolver{ + // { + // Name: to.Ptr("sampleDnsResolver1"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver1"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.Properties{ + // DNSResolverState: to.Ptr(armdnsresolver.DNSResolverStateConnected), + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("ad9c8da4-3bb2-4821-a878-c2cb07b01fb6"), + // VirtualNetwork: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/cbb1387e-4b03-44f2-ad41-58d4677b9873/resourceGroups/virtualNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork1"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // }, + // { + // Name: to.Ptr("sampleDnsResolver2"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver2"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.Properties{ + // DNSResolverState: to.Ptr(armdnsresolver.DNSResolverStateConnected), + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("b6b2d964-8588-4e3a-a7fe-8a5b7fe8eca5"), + // VirtualNetwork: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/cbb1387e-4b03-44f2-ad41-58d4677b9873/resourceGroups/virtualNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork2"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_ListByVirtualNetwork.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_ListByVirtualNetwork.json func ExampleDNSResolversClient_NewListByVirtualNetworkPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewDNSResolversClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByVirtualNetworkPager("sampleResourceGroup", "sampleVirtualNetwork", &armdnsresolver.DNSResolversClientListByVirtualNetworkOptions{Top: nil}) + pager := clientFactory.NewDNSResolversClient().NewListByVirtualNetworkPager("sampleResourceGroup", "sampleVirtualNetwork", &armdnsresolver.DNSResolversClientListByVirtualNetworkOptions{Top: 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.SubResourceListResult = armdnsresolver.SubResourceListResult{ + // Value: []*armdnsresolver.SubResource{ + // { + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver1"), + // }}, + // } } } diff --git a/sdk/resourcemanager/dnsresolver/armdnsresolver/forwardingrules_client.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/forwardingrules_client.go index 3f91b0799b40..6975df452753 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/forwardingrules_client.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/forwardingrules_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 ( // ForwardingRulesClient contains the methods for the ForwardingRules group. // Don't use this type directly, use NewForwardingRulesClient() instead. type ForwardingRulesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewForwardingRulesClient creates a new instance of ForwardingRulesClient 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 NewForwardingRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ForwardingRulesClient, 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+".ForwardingRulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ForwardingRulesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Creates or updates a forwarding rule in a DNS forwarding ruleset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsForwardingRulesetName - The name of the DNS forwarding ruleset. -// forwardingRuleName - The name of the forwarding rule. -// parameters - Parameters supplied to the CreateOrUpdate operation. -// options - ForwardingRulesClientCreateOrUpdateOptions contains the optional parameters for the ForwardingRulesClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsForwardingRulesetName - The name of the DNS forwarding ruleset. +// - forwardingRuleName - The name of the forwarding rule. +// - parameters - Parameters supplied to the CreateOrUpdate operation. +// - options - ForwardingRulesClientCreateOrUpdateOptions contains the optional parameters for the ForwardingRulesClient.CreateOrUpdate +// method. func (client *ForwardingRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, forwardingRuleName string, parameters ForwardingRule, options *ForwardingRulesClientCreateOrUpdateOptions) (ForwardingRulesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, dnsForwardingRulesetName, forwardingRuleName, parameters, options) if err != nil { return ForwardingRulesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ForwardingRulesClientCreateOrUpdateResponse{}, err } @@ -99,7 +89,7 @@ func (client *ForwardingRulesClient) createOrUpdateCreateRequest(ctx context.Con return nil, errors.New("parameter forwardingRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{forwardingRuleName}", url.PathEscape(forwardingRuleName)) - 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 +117,18 @@ func (client *ForwardingRulesClient) createOrUpdateHandleResponse(resp *http.Res // Delete - Deletes a forwarding rule in a DNS forwarding ruleset. WARNING: This operation cannot be undone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsForwardingRulesetName - The name of the DNS forwarding ruleset. -// forwardingRuleName - The name of the forwarding rule. -// options - ForwardingRulesClientDeleteOptions contains the optional parameters for the ForwardingRulesClient.Delete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsForwardingRulesetName - The name of the DNS forwarding ruleset. +// - forwardingRuleName - The name of the forwarding rule. +// - options - ForwardingRulesClientDeleteOptions contains the optional parameters for the ForwardingRulesClient.Delete method. func (client *ForwardingRulesClient) Delete(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, forwardingRuleName string, options *ForwardingRulesClientDeleteOptions) (ForwardingRulesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, dnsForwardingRulesetName, forwardingRuleName, options) if err != nil { return ForwardingRulesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ForwardingRulesClientDeleteResponse{}, err } @@ -166,7 +157,7 @@ func (client *ForwardingRulesClient) deleteCreateRequest(ctx context.Context, re return nil, errors.New("parameter forwardingRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{forwardingRuleName}", url.PathEscape(forwardingRuleName)) - 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,17 +173,18 @@ func (client *ForwardingRulesClient) deleteCreateRequest(ctx context.Context, re // Get - Gets properties of a forwarding rule in a DNS forwarding ruleset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsForwardingRulesetName - The name of the DNS forwarding ruleset. -// forwardingRuleName - The name of the forwarding rule. -// options - ForwardingRulesClientGetOptions contains the optional parameters for the ForwardingRulesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsForwardingRulesetName - The name of the DNS forwarding ruleset. +// - forwardingRuleName - The name of the forwarding rule. +// - options - ForwardingRulesClientGetOptions contains the optional parameters for the ForwardingRulesClient.Get method. func (client *ForwardingRulesClient) Get(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, forwardingRuleName string, options *ForwardingRulesClientGetOptions) (ForwardingRulesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, dnsForwardingRulesetName, forwardingRuleName, options) if err != nil { return ForwardingRulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ForwardingRulesClientGetResponse{}, err } @@ -221,7 +213,7 @@ func (client *ForwardingRulesClient) getCreateRequest(ctx context.Context, resou return nil, errors.New("parameter forwardingRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{forwardingRuleName}", url.PathEscape(forwardingRuleName)) - 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 +234,12 @@ func (client *ForwardingRulesClient) getHandleResponse(resp *http.Response) (For } // NewListPager - Lists forwarding rules in a DNS forwarding ruleset. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsForwardingRulesetName - The name of the DNS forwarding ruleset. -// options - ForwardingRulesClientListOptions contains the optional parameters for the ForwardingRulesClient.List method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsForwardingRulesetName - The name of the DNS forwarding ruleset. +// - options - ForwardingRulesClientListOptions contains the optional parameters for the ForwardingRulesClient.NewListPager +// method. func (client *ForwardingRulesClient) NewListPager(resourceGroupName string, dnsForwardingRulesetName string, options *ForwardingRulesClientListOptions) *runtime.Pager[ForwardingRulesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ForwardingRulesClientListResponse]{ More: func(page ForwardingRulesClientListResponse) bool { @@ -262,7 +256,7 @@ func (client *ForwardingRulesClient) NewListPager(resourceGroupName string, dnsF if err != nil { return ForwardingRulesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ForwardingRulesClientListResponse{}, err } @@ -289,7 +283,7 @@ func (client *ForwardingRulesClient) listCreateRequest(ctx context.Context, reso return nil, errors.New("parameter dnsForwardingRulesetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dnsForwardingRulesetName}", url.PathEscape(dnsForwardingRulesetName)) - 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 } @@ -314,18 +308,19 @@ func (client *ForwardingRulesClient) listHandleResponse(resp *http.Response) (Fo // Update - Updates a forwarding rule in a DNS forwarding ruleset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsForwardingRulesetName - The name of the DNS forwarding ruleset. -// forwardingRuleName - The name of the forwarding rule. -// parameters - Parameters supplied to the Update operation. -// options - ForwardingRulesClientUpdateOptions contains the optional parameters for the ForwardingRulesClient.Update method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsForwardingRulesetName - The name of the DNS forwarding ruleset. +// - forwardingRuleName - The name of the forwarding rule. +// - parameters - Parameters supplied to the Update operation. +// - options - ForwardingRulesClientUpdateOptions contains the optional parameters for the ForwardingRulesClient.Update method. func (client *ForwardingRulesClient) Update(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, forwardingRuleName string, parameters ForwardingRulePatch, options *ForwardingRulesClientUpdateOptions) (ForwardingRulesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, dnsForwardingRulesetName, forwardingRuleName, parameters, options) if err != nil { return ForwardingRulesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ForwardingRulesClientUpdateResponse{}, err } @@ -354,7 +349,7 @@ func (client *ForwardingRulesClient) updateCreateRequest(ctx context.Context, re return nil, errors.New("parameter forwardingRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{forwardingRuleName}", url.PathEscape(forwardingRuleName)) - 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/dnsresolver/armdnsresolver/forwardingrules_client_example_test.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/forwardingrules_client_example_test.go index 7987b01968ae..d64dcc477d93 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/forwardingrules_client_example_test.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/forwardingrules_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 armdnsresolver_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dnsresolver/armdnsresolver" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/ForwardingRule_Put.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/ForwardingRule_Put.json func ExampleForwardingRulesClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewForwardingRulesClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleForwardingRule", armdnsresolver.ForwardingRule{ + res, err := clientFactory.NewForwardingRulesClient().CreateOrUpdate(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleForwardingRule", armdnsresolver.ForwardingRule{ Properties: &armdnsresolver.ForwardingRuleProperties{ DomainName: to.Ptr("contoso.com."), ForwardingRuleState: to.Ptr(armdnsresolver.ForwardingRuleStateEnabled), @@ -51,22 +52,52 @@ func ExampleForwardingRulesClient_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.ForwardingRule = armdnsresolver.ForwardingRule{ + // Name: to.Ptr("sampleForwardingRule"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets/forwardingRules"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRulesets/sampleDnsForwardingRuleset/forwardingRules/sampleForwardingRule"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.ForwardingRuleProperties{ + // DomainName: to.Ptr("contoso.com."), + // ForwardingRuleState: to.Ptr(armdnsresolver.ForwardingRuleStateEnabled), + // Metadata: map[string]*string{ + // "additionalProp1": to.Ptr("value1"), + // }, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // TargetDNSServers: []*armdnsresolver.TargetDNSServer{ + // { + // IPAddress: to.Ptr("10.0.0.1"), + // Port: to.Ptr[int32](53), + // }, + // { + // IPAddress: to.Ptr("10.0.0.2"), + // Port: to.Ptr[int32](53), + // }}, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/ForwardingRule_Patch.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/ForwardingRule_Patch.json func ExampleForwardingRulesClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewForwardingRulesClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleForwardingRule", armdnsresolver.ForwardingRulePatch{ + res, err := clientFactory.NewForwardingRulesClient().Update(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleForwardingRule", armdnsresolver.ForwardingRulePatch{ Properties: &armdnsresolver.ForwardingRulePatchProperties{ ForwardingRuleState: to.Ptr(armdnsresolver.ForwardingRuleStateDisabled), Metadata: map[string]*string{ @@ -77,66 +108,188 @@ func ExampleForwardingRulesClient_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.ForwardingRule = armdnsresolver.ForwardingRule{ + // Name: to.Ptr("sampleForwardingRule"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets/forwardingRules"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRulesets/sampleDnsForwardingRuleset/forwardingRules/sampleForwardingRule"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.ForwardingRuleProperties{ + // DomainName: to.Ptr("contoso.com."), + // ForwardingRuleState: to.Ptr(armdnsresolver.ForwardingRuleStateDisabled), + // Metadata: map[string]*string{ + // "additionalProp2": to.Ptr("value2"), + // }, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // TargetDNSServers: []*armdnsresolver.TargetDNSServer{ + // { + // IPAddress: to.Ptr("10.0.0.1"), + // Port: to.Ptr[int32](53), + // }, + // { + // IPAddress: to.Ptr("10.0.0.2"), + // Port: to.Ptr[int32](53), + // }}, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/ForwardingRule_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/ForwardingRule_Delete.json func ExampleForwardingRulesClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewForwardingRulesClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleForwardingRule", &armdnsresolver.ForwardingRulesClientDeleteOptions{IfMatch: nil}) + _, err = clientFactory.NewForwardingRulesClient().Delete(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleForwardingRule", &armdnsresolver.ForwardingRulesClientDeleteOptions{IfMatch: 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/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/ForwardingRule_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/ForwardingRule_Get.json func ExampleForwardingRulesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewForwardingRulesClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleForwardingRule", nil) + res, err := clientFactory.NewForwardingRulesClient().Get(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleForwardingRule", 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.ForwardingRule = armdnsresolver.ForwardingRule{ + // Name: to.Ptr("sampleForwardingRule"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets/forwardingRules"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRulesets/sampleDnsForwardingRuleset/forwardingRules/sampleForwardingRule"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.ForwardingRuleProperties{ + // DomainName: to.Ptr("contoso.com."), + // ForwardingRuleState: to.Ptr(armdnsresolver.ForwardingRuleStateEnabled), + // Metadata: map[string]*string{ + // "additionalProp1": to.Ptr("value1"), + // }, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // TargetDNSServers: []*armdnsresolver.TargetDNSServer{ + // { + // IPAddress: to.Ptr("10.0.0.1"), + // Port: to.Ptr[int32](53), + // }, + // { + // IPAddress: to.Ptr("10.0.0.2"), + // Port: to.Ptr[int32](53), + // }}, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/ForwardingRule_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/ForwardingRule_List.json func ExampleForwardingRulesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewForwardingRulesClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("sampleResourceGroup", "sampleDnsForwardingRuleset", &armdnsresolver.ForwardingRulesClientListOptions{Top: nil}) + pager := clientFactory.NewForwardingRulesClient().NewListPager("sampleResourceGroup", "sampleDnsForwardingRuleset", &armdnsresolver.ForwardingRulesClientListOptions{Top: 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.ForwardingRuleListResult = armdnsresolver.ForwardingRuleListResult{ + // Value: []*armdnsresolver.ForwardingRule{ + // { + // Name: to.Ptr("sampleForwardingRule"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets/forwardingRules"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRulesets/sampleDnsForwardingRuleset/forwardingRules/sampleForwardingRule"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.ForwardingRuleProperties{ + // DomainName: to.Ptr("contoso.com."), + // ForwardingRuleState: to.Ptr(armdnsresolver.ForwardingRuleStateEnabled), + // Metadata: map[string]*string{ + // "additionalProp1": to.Ptr("value1"), + // }, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // TargetDNSServers: []*armdnsresolver.TargetDNSServer{ + // { + // IPAddress: to.Ptr("10.0.0.1"), + // Port: to.Ptr[int32](53), + // }, + // { + // IPAddress: to.Ptr("10.0.0.2"), + // Port: to.Ptr[int32](53), + // }}, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // }, + // { + // Name: to.Ptr("sampleForwardingRule1"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets/forwardingRules"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRulesets/sampleDnsForwardingRuleset/forwardingRules/sampleForwardingRule1"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.ForwardingRuleProperties{ + // DomainName: to.Ptr("foobar.com."), + // ForwardingRuleState: to.Ptr(armdnsresolver.ForwardingRuleStateEnabled), + // Metadata: map[string]*string{ + // "additionalProp1": to.Ptr("value1"), + // }, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // TargetDNSServers: []*armdnsresolver.TargetDNSServer{ + // { + // IPAddress: to.Ptr("10.0.0.3"), + // Port: to.Ptr[int32](53), + // }, + // { + // IPAddress: to.Ptr("10.0.0.4"), + // Port: to.Ptr[int32](53), + // }}, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/dnsresolver/armdnsresolver/go.mod b/sdk/resourcemanager/dnsresolver/armdnsresolver/go.mod index 30af7258d984..22af952ea539 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/go.mod +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dnsresolver/armdnsr 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/dnsresolver/armdnsresolver/go.sum b/sdk/resourcemanager/dnsresolver/armdnsresolver/go.sum index 8828b17b1853..8ba445a8c4da 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/go.sum +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/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/dnsresolver/armdnsresolver/inboundendpoints_client.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/inboundendpoints_client.go index d8a74b0013f4..88a184d57532 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/inboundendpoints_client.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/inboundendpoints_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,65 +25,58 @@ import ( // InboundEndpointsClient contains the methods for the InboundEndpoints group. // Don't use this type directly, use NewInboundEndpointsClient() instead. type InboundEndpointsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewInboundEndpointsClient creates a new instance of InboundEndpointsClient 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 NewInboundEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*InboundEndpointsClient, 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+".InboundEndpointsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &InboundEndpointsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates an inbound endpoint for a DNS resolver. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsResolverName - The name of the DNS resolver. -// inboundEndpointName - The name of the inbound endpoint for the DNS resolver. -// parameters - Parameters supplied to the CreateOrUpdate operation. -// options - InboundEndpointsClientBeginCreateOrUpdateOptions contains the optional parameters for the InboundEndpointsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsResolverName - The name of the DNS resolver. +// - inboundEndpointName - The name of the inbound endpoint for the DNS resolver. +// - parameters - Parameters supplied to the CreateOrUpdate operation. +// - options - InboundEndpointsClientBeginCreateOrUpdateOptions contains the optional parameters for the InboundEndpointsClient.BeginCreateOrUpdate +// method. func (client *InboundEndpointsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, dnsResolverName string, inboundEndpointName string, parameters InboundEndpoint, options *InboundEndpointsClientBeginCreateOrUpdateOptions) (*runtime.Poller[InboundEndpointsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, dnsResolverName, inboundEndpointName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[InboundEndpointsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[InboundEndpointsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[InboundEndpointsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[InboundEndpointsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates an inbound endpoint for a DNS resolver. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 func (client *InboundEndpointsClient) createOrUpdate(ctx context.Context, resourceGroupName string, dnsResolverName string, inboundEndpointName string, parameters InboundEndpoint, options *InboundEndpointsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, dnsResolverName, inboundEndpointName, 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 } @@ -114,7 +105,7 @@ func (client *InboundEndpointsClient) createOrUpdateCreateRequest(ctx context.Co return nil, errors.New("parameter inboundEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{inboundEndpointName}", url.PathEscape(inboundEndpointName)) - 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 } @@ -133,33 +124,35 @@ func (client *InboundEndpointsClient) createOrUpdateCreateRequest(ctx context.Co // BeginDelete - Deletes an inbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsResolverName - The name of the DNS resolver. -// inboundEndpointName - The name of the inbound endpoint for the DNS resolver. -// options - InboundEndpointsClientBeginDeleteOptions contains the optional parameters for the InboundEndpointsClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsResolverName - The name of the DNS resolver. +// - inboundEndpointName - The name of the inbound endpoint for the DNS resolver. +// - options - InboundEndpointsClientBeginDeleteOptions contains the optional parameters for the InboundEndpointsClient.BeginDelete +// method. func (client *InboundEndpointsClient) BeginDelete(ctx context.Context, resourceGroupName string, dnsResolverName string, inboundEndpointName string, options *InboundEndpointsClientBeginDeleteOptions) (*runtime.Poller[InboundEndpointsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, dnsResolverName, inboundEndpointName, options) if err != nil { return nil, err } - return runtime.NewPoller[InboundEndpointsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[InboundEndpointsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[InboundEndpointsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[InboundEndpointsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes an inbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 func (client *InboundEndpointsClient) deleteOperation(ctx context.Context, resourceGroupName string, dnsResolverName string, inboundEndpointName string, options *InboundEndpointsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, dnsResolverName, inboundEndpointName, 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 } @@ -188,7 +181,7 @@ func (client *InboundEndpointsClient) deleteCreateRequest(ctx context.Context, r return nil, errors.New("parameter inboundEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{inboundEndpointName}", url.PathEscape(inboundEndpointName)) - 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 } @@ -204,17 +197,18 @@ func (client *InboundEndpointsClient) deleteCreateRequest(ctx context.Context, r // Get - Gets properties of an inbound endpoint for a DNS resolver. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsResolverName - The name of the DNS resolver. -// inboundEndpointName - The name of the inbound endpoint for the DNS resolver. -// options - InboundEndpointsClientGetOptions contains the optional parameters for the InboundEndpointsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsResolverName - The name of the DNS resolver. +// - inboundEndpointName - The name of the inbound endpoint for the DNS resolver. +// - options - InboundEndpointsClientGetOptions contains the optional parameters for the InboundEndpointsClient.Get method. func (client *InboundEndpointsClient) Get(ctx context.Context, resourceGroupName string, dnsResolverName string, inboundEndpointName string, options *InboundEndpointsClientGetOptions) (InboundEndpointsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, dnsResolverName, inboundEndpointName, options) if err != nil { return InboundEndpointsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return InboundEndpointsClientGetResponse{}, err } @@ -243,7 +237,7 @@ func (client *InboundEndpointsClient) getCreateRequest(ctx context.Context, reso return nil, errors.New("parameter inboundEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{inboundEndpointName}", url.PathEscape(inboundEndpointName)) - 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 } @@ -264,10 +258,12 @@ func (client *InboundEndpointsClient) getHandleResponse(resp *http.Response) (In } // NewListPager - Lists inbound endpoints for a DNS resolver. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsResolverName - The name of the DNS resolver. -// options - InboundEndpointsClientListOptions contains the optional parameters for the InboundEndpointsClient.List method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsResolverName - The name of the DNS resolver. +// - options - InboundEndpointsClientListOptions contains the optional parameters for the InboundEndpointsClient.NewListPager +// method. func (client *InboundEndpointsClient) NewListPager(resourceGroupName string, dnsResolverName string, options *InboundEndpointsClientListOptions) *runtime.Pager[InboundEndpointsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[InboundEndpointsClientListResponse]{ More: func(page InboundEndpointsClientListResponse) bool { @@ -284,7 +280,7 @@ func (client *InboundEndpointsClient) NewListPager(resourceGroupName string, dns if err != nil { return InboundEndpointsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return InboundEndpointsClientListResponse{}, err } @@ -311,7 +307,7 @@ func (client *InboundEndpointsClient) listCreateRequest(ctx context.Context, res return nil, errors.New("parameter dnsResolverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dnsResolverName}", url.PathEscape(dnsResolverName)) - 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 +332,36 @@ func (client *InboundEndpointsClient) listHandleResponse(resp *http.Response) (I // BeginUpdate - Updates an inbound endpoint for a DNS resolver. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsResolverName - The name of the DNS resolver. -// inboundEndpointName - The name of the inbound endpoint for the DNS resolver. -// parameters - Parameters supplied to the Update operation. -// options - InboundEndpointsClientBeginUpdateOptions contains the optional parameters for the InboundEndpointsClient.BeginUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsResolverName - The name of the DNS resolver. +// - inboundEndpointName - The name of the inbound endpoint for the DNS resolver. +// - parameters - Parameters supplied to the Update operation. +// - options - InboundEndpointsClientBeginUpdateOptions contains the optional parameters for the InboundEndpointsClient.BeginUpdate +// method. func (client *InboundEndpointsClient) BeginUpdate(ctx context.Context, resourceGroupName string, dnsResolverName string, inboundEndpointName string, parameters InboundEndpointPatch, options *InboundEndpointsClientBeginUpdateOptions) (*runtime.Poller[InboundEndpointsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, dnsResolverName, inboundEndpointName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[InboundEndpointsClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[InboundEndpointsClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[InboundEndpointsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[InboundEndpointsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates an inbound endpoint for a DNS resolver. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 func (client *InboundEndpointsClient) update(ctx context.Context, resourceGroupName string, dnsResolverName string, inboundEndpointName string, parameters InboundEndpointPatch, options *InboundEndpointsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, dnsResolverName, inboundEndpointName, 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 } @@ -392,7 +390,7 @@ func (client *InboundEndpointsClient) updateCreateRequest(ctx context.Context, r return nil, errors.New("parameter inboundEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{inboundEndpointName}", url.PathEscape(inboundEndpointName)) - 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/dnsresolver/armdnsresolver/inboundendpoints_client_example_test.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/inboundendpoints_client_example_test.go index 789d9ae9615f..9f351b04ac8e 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/inboundendpoints_client_example_test.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/inboundendpoints_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 armdnsresolver_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dnsresolver/armdnsresolver" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/InboundEndpoint_Put.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/InboundEndpoint_Put.json func ExampleInboundEndpointsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewInboundEndpointsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleInboundEndpoint", armdnsresolver.InboundEndpoint{ + poller, err := clientFactory.NewInboundEndpointsClient().BeginCreateOrUpdate(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleInboundEndpoint", armdnsresolver.InboundEndpoint{ Location: to.Ptr("westus2"), Tags: map[string]*string{ "key1": to.Ptr("value1"), @@ -52,22 +53,51 @@ func ExampleInboundEndpointsClient_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.InboundEndpoint = armdnsresolver.InboundEndpoint{ + // Name: to.Ptr("sampleInboundEndpoint"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers/inboundEndpoints"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/inboundEndpoints/sampleInboundEndpoint"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.InboundEndpointProperties{ + // IPConfigurations: []*armdnsresolver.IPConfiguration{ + // { + // PrivateIPAddress: to.Ptr("255.255.255.255"), + // PrivateIPAllocationMethod: to.Ptr(armdnsresolver.IPAllocationMethodDynamic), + // Subnet: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet"), + // }, + // }}, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("87b3e20a-5833-4c40-8ad7-c5160bb1c5bd"), + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/InboundEndpoint_Patch.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/InboundEndpoint_Patch.json func ExampleInboundEndpointsClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewInboundEndpointsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleInboundEndpoint", armdnsresolver.InboundEndpointPatch{ + poller, err := clientFactory.NewInboundEndpointsClient().BeginUpdate(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleInboundEndpoint", armdnsresolver.InboundEndpointPatch{ Tags: map[string]*string{ "key1": to.Ptr("value1"), }, @@ -79,22 +109,51 @@ func ExampleInboundEndpointsClient_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.InboundEndpoint = armdnsresolver.InboundEndpoint{ + // Name: to.Ptr("sampleInboundEndpoint"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers/inboundEndpoints"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/inboundEndpoints/sampleInboundEndpoint"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.InboundEndpointProperties{ + // IPConfigurations: []*armdnsresolver.IPConfiguration{ + // { + // PrivateIPAddress: to.Ptr("255.255.255.255"), + // PrivateIPAllocationMethod: to.Ptr(armdnsresolver.IPAllocationMethodDynamic), + // Subnet: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet"), + // }, + // }}, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("87b3e20a-5833-4c40-8ad7-c5160bb1c5bd"), + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/InboundEndpoint_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/InboundEndpoint_Delete.json func ExampleInboundEndpointsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewInboundEndpointsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleInboundEndpoint", &armdnsresolver.InboundEndpointsClientBeginDeleteOptions{IfMatch: nil}) + poller, err := clientFactory.NewInboundEndpointsClient().BeginDelete(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleInboundEndpoint", &armdnsresolver.InboundEndpointsClientBeginDeleteOptions{IfMatch: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -104,45 +163,134 @@ func ExampleInboundEndpointsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/InboundEndpoint_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/InboundEndpoint_Get.json func ExampleInboundEndpointsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewInboundEndpointsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleInboundEndpoint", nil) + res, err := clientFactory.NewInboundEndpointsClient().Get(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleInboundEndpoint", 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.InboundEndpoint = armdnsresolver.InboundEndpoint{ + // Name: to.Ptr("sampleInboundEndpoint"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers/inboundEndpoints"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/inboundEndpoints/sampleInboundEndpoint"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.InboundEndpointProperties{ + // IPConfigurations: []*armdnsresolver.IPConfiguration{ + // { + // PrivateIPAddress: to.Ptr("255.255.255.255"), + // PrivateIPAllocationMethod: to.Ptr(armdnsresolver.IPAllocationMethodDynamic), + // Subnet: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet"), + // }, + // }}, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("b6b2d964-8588-4e3a-a7fe-8a5b7fe8eca5"), + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/InboundEndpoint_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/InboundEndpoint_List.json func ExampleInboundEndpointsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewInboundEndpointsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("sampleResourceGroup", "sampleDnsResolver", &armdnsresolver.InboundEndpointsClientListOptions{Top: nil}) + pager := clientFactory.NewInboundEndpointsClient().NewListPager("sampleResourceGroup", "sampleDnsResolver", &armdnsresolver.InboundEndpointsClientListOptions{Top: 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.InboundEndpointListResult = armdnsresolver.InboundEndpointListResult{ + // Value: []*armdnsresolver.InboundEndpoint{ + // { + // Name: to.Ptr("sampleInboundEndpoint1"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers/inboundEndpoints"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/inboundEndpoints/sampleInboundEndpoint1"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.InboundEndpointProperties{ + // IPConfigurations: []*armdnsresolver.IPConfiguration{ + // { + // PrivateIPAddress: to.Ptr("255.1.255.1"), + // PrivateIPAllocationMethod: to.Ptr(armdnsresolver.IPAllocationMethodDynamic), + // Subnet: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet1"), + // }, + // }}, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("b6b2d964-8588-4e3a-a7fe-8a5b7fe8eca5"), + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // }, + // { + // Name: to.Ptr("sampleInboundEndpoint2"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers/inboundEndpoints"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/inboundEndpoints/sampleInboundEndpoint2"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.InboundEndpointProperties{ + // IPConfigurations: []*armdnsresolver.IPConfiguration{ + // { + // PrivateIPAddress: to.Ptr("1.1.255.1"), + // PrivateIPAllocationMethod: to.Ptr(armdnsresolver.IPAllocationMethodDynamic), + // Subnet: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet1"), + // }, + // }}, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("87b3e20a-5833-4c40-8ad7-c5160bb1c5bd"), + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-03T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/dnsresolver/armdnsresolver/models.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/models.go index e8ba10647011..07a4413a02ec 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/models.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/models.go @@ -108,21 +108,22 @@ type DNSForwardingRulesetsClientGetOptions struct { // placeholder for future optional parameters } -// DNSForwardingRulesetsClientListByResourceGroupOptions contains the optional parameters for the DNSForwardingRulesetsClient.ListByResourceGroup +// DNSForwardingRulesetsClientListByResourceGroupOptions contains the optional parameters for the DNSForwardingRulesetsClient.NewListByResourceGroupPager // method. type DNSForwardingRulesetsClientListByResourceGroupOptions struct { // The maximum number of results to return. If not specified, returns up to 100 results. Top *int32 } -// DNSForwardingRulesetsClientListByVirtualNetworkOptions contains the optional parameters for the DNSForwardingRulesetsClient.ListByVirtualNetwork +// DNSForwardingRulesetsClientListByVirtualNetworkOptions contains the optional parameters for the DNSForwardingRulesetsClient.NewListByVirtualNetworkPager // method. type DNSForwardingRulesetsClientListByVirtualNetworkOptions struct { // The maximum number of results to return. If not specified, returns up to 100 results. Top *int32 } -// DNSForwardingRulesetsClientListOptions contains the optional parameters for the DNSForwardingRulesetsClient.List method. +// DNSForwardingRulesetsClientListOptions contains the optional parameters for the DNSForwardingRulesetsClient.NewListPager +// method. type DNSForwardingRulesetsClientListOptions struct { // The maximum number of results to return. If not specified, returns up to 100 results. Top *int32 @@ -190,21 +191,21 @@ type DNSResolversClientGetOptions struct { // placeholder for future optional parameters } -// DNSResolversClientListByResourceGroupOptions contains the optional parameters for the DNSResolversClient.ListByResourceGroup +// DNSResolversClientListByResourceGroupOptions contains the optional parameters for the DNSResolversClient.NewListByResourceGroupPager // method. type DNSResolversClientListByResourceGroupOptions struct { // The maximum number of results to return. If not specified, returns up to 100 results. Top *int32 } -// DNSResolversClientListByVirtualNetworkOptions contains the optional parameters for the DNSResolversClient.ListByVirtualNetwork +// DNSResolversClientListByVirtualNetworkOptions contains the optional parameters for the DNSResolversClient.NewListByVirtualNetworkPager // method. type DNSResolversClientListByVirtualNetworkOptions struct { // The maximum number of results to return. If not specified, returns up to 100 results. Top *int32 } -// DNSResolversClientListOptions contains the optional parameters for the DNSResolversClient.List method. +// DNSResolversClientListOptions contains the optional parameters for the DNSResolversClient.NewListPager method. type DNSResolversClientListOptions struct { // The maximum number of results to return. If not specified, returns up to 100 results. Top *int32 @@ -299,7 +300,7 @@ type ForwardingRulesClientGetOptions struct { // placeholder for future optional parameters } -// ForwardingRulesClientListOptions contains the optional parameters for the ForwardingRulesClient.List method. +// ForwardingRulesClientListOptions contains the optional parameters for the ForwardingRulesClient.NewListPager method. type ForwardingRulesClientListOptions struct { // The maximum number of results to return. If not specified, returns up to 100 results. Top *int32 @@ -414,7 +415,7 @@ type InboundEndpointsClientGetOptions struct { // placeholder for future optional parameters } -// InboundEndpointsClientListOptions contains the optional parameters for the InboundEndpointsClient.List method. +// InboundEndpointsClientListOptions contains the optional parameters for the InboundEndpointsClient.NewListPager method. type InboundEndpointsClientListOptions struct { // The maximum number of results to return. If not specified, returns up to 100 results. Top *int32 @@ -521,7 +522,7 @@ type OutboundEndpointsClientGetOptions struct { // placeholder for future optional parameters } -// OutboundEndpointsClientListOptions contains the optional parameters for the OutboundEndpointsClient.List method. +// OutboundEndpointsClientListOptions contains the optional parameters for the OutboundEndpointsClient.NewListPager method. type OutboundEndpointsClientListOptions struct { // The maximum number of results to return. If not specified, returns up to 100 results. Top *int32 @@ -713,7 +714,7 @@ type VirtualNetworkLinksClientGetOptions struct { // placeholder for future optional parameters } -// VirtualNetworkLinksClientListOptions contains the optional parameters for the VirtualNetworkLinksClient.List method. +// VirtualNetworkLinksClientListOptions contains the optional parameters for the VirtualNetworkLinksClient.NewListPager method. type VirtualNetworkLinksClientListOptions struct { // The maximum number of results to return. If not specified, returns up to 100 results. Top *int32 diff --git a/sdk/resourcemanager/dnsresolver/armdnsresolver/models_serde.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/models_serde.go index 3440ba51051b..89ea5be2b6f5 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/models_serde.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type DNSForwardingRuleset. func (d DNSForwardingRuleset) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", d.Etag) populate(objectMap, "id", d.ID) populate(objectMap, "location", d.Location) @@ -73,7 +73,7 @@ func (d *DNSForwardingRuleset) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DNSForwardingRulesetListResult. func (d DNSForwardingRulesetListResult) 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) @@ -104,7 +104,7 @@ func (d *DNSForwardingRulesetListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DNSForwardingRulesetPatch. func (d DNSForwardingRulesetPatch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "dnsResolverOutboundEndpoints", d.DNSResolverOutboundEndpoints) populate(objectMap, "tags", d.Tags) return json.Marshal(objectMap) @@ -135,7 +135,7 @@ func (d *DNSForwardingRulesetPatch) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DNSForwardingRulesetProperties. func (d DNSForwardingRulesetProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "dnsResolverOutboundEndpoints", d.DNSResolverOutboundEndpoints) populate(objectMap, "provisioningState", d.ProvisioningState) populate(objectMap, "resourceGuid", d.ResourceGUID) @@ -170,7 +170,7 @@ func (d *DNSForwardingRulesetProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DNSResolver. func (d DNSResolver) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", d.Etag) populate(objectMap, "id", d.ID) populate(objectMap, "location", d.Location) @@ -225,7 +225,7 @@ func (d *DNSResolver) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ForwardingRule. func (f ForwardingRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", f.Etag) populate(objectMap, "id", f.ID) populate(objectMap, "name", f.Name) @@ -272,7 +272,7 @@ func (f *ForwardingRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ForwardingRuleListResult. func (f ForwardingRuleListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", f.NextLink) populate(objectMap, "value", f.Value) return json.Marshal(objectMap) @@ -303,7 +303,7 @@ func (f *ForwardingRuleListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ForwardingRulePatch. func (f ForwardingRulePatch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", f.Properties) return json.Marshal(objectMap) } @@ -330,7 +330,7 @@ func (f *ForwardingRulePatch) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ForwardingRulePatchProperties. func (f ForwardingRulePatchProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "forwardingRuleState", f.ForwardingRuleState) populate(objectMap, "metadata", f.Metadata) populate(objectMap, "targetDnsServers", f.TargetDNSServers) @@ -365,7 +365,7 @@ func (f *ForwardingRulePatchProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ForwardingRuleProperties. func (f ForwardingRuleProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "domainName", f.DomainName) populate(objectMap, "forwardingRuleState", f.ForwardingRuleState) populate(objectMap, "metadata", f.Metadata) @@ -408,7 +408,7 @@ func (f *ForwardingRuleProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IPConfiguration. func (i IPConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "privateIpAddress", i.PrivateIPAddress) populate(objectMap, "privateIpAllocationMethod", i.PrivateIPAllocationMethod) populate(objectMap, "subnet", i.Subnet) @@ -443,7 +443,7 @@ func (i *IPConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InboundEndpoint. func (i InboundEndpoint) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", i.Etag) populate(objectMap, "id", i.ID) populate(objectMap, "location", i.Location) @@ -498,7 +498,7 @@ func (i *InboundEndpoint) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InboundEndpointListResult. func (i InboundEndpointListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", i.NextLink) populate(objectMap, "value", i.Value) return json.Marshal(objectMap) @@ -529,7 +529,7 @@ func (i *InboundEndpointListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InboundEndpointPatch. func (i InboundEndpointPatch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "tags", i.Tags) return json.Marshal(objectMap) } @@ -556,7 +556,7 @@ func (i *InboundEndpointPatch) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InboundEndpointProperties. func (i InboundEndpointProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "ipConfigurations", i.IPConfigurations) populate(objectMap, "provisioningState", i.ProvisioningState) populate(objectMap, "resourceGuid", i.ResourceGUID) @@ -591,7 +591,7 @@ func (i *InboundEndpointProperties) 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) @@ -622,7 +622,7 @@ func (l *ListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OutboundEndpoint. func (o OutboundEndpoint) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", o.Etag) populate(objectMap, "id", o.ID) populate(objectMap, "location", o.Location) @@ -677,7 +677,7 @@ func (o *OutboundEndpoint) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OutboundEndpointListResult. func (o OutboundEndpointListResult) 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) @@ -708,7 +708,7 @@ func (o *OutboundEndpointListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OutboundEndpointPatch. func (o OutboundEndpointPatch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "tags", o.Tags) return json.Marshal(objectMap) } @@ -735,7 +735,7 @@ func (o *OutboundEndpointPatch) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OutboundEndpointProperties. func (o OutboundEndpointProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "provisioningState", o.ProvisioningState) populate(objectMap, "resourceGuid", o.ResourceGUID) populate(objectMap, "subnet", o.Subnet) @@ -770,7 +770,7 @@ func (o *OutboundEndpointProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Patch. func (p Patch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "tags", p.Tags) return json.Marshal(objectMap) } @@ -797,7 +797,7 @@ func (p *Patch) 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, "dnsResolverState", p.DNSResolverState) populate(objectMap, "provisioningState", p.ProvisioningState) populate(objectMap, "resourceGuid", p.ResourceGUID) @@ -836,7 +836,7 @@ func (p *Properties) 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) } @@ -863,7 +863,7 @@ func (s *SubResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SubResourceListResult. func (s SubResourceListResult) 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) @@ -894,7 +894,7 @@ func (s *SubResourceListResult) 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) @@ -941,7 +941,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TargetDNSServer. func (t TargetDNSServer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "ipAddress", t.IPAddress) populate(objectMap, "port", t.Port) return json.Marshal(objectMap) @@ -972,7 +972,7 @@ func (t *TargetDNSServer) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualNetworkDNSForwardingRuleset. func (v VirtualNetworkDNSForwardingRuleset) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", v.ID) populate(objectMap, "properties", v.Properties) return json.Marshal(objectMap) @@ -1003,7 +1003,7 @@ func (v *VirtualNetworkDNSForwardingRuleset) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualNetworkDNSForwardingRulesetListResult. func (v VirtualNetworkDNSForwardingRulesetListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", v.NextLink) populate(objectMap, "value", v.Value) return json.Marshal(objectMap) @@ -1034,7 +1034,7 @@ func (v *VirtualNetworkDNSForwardingRulesetListResult) UnmarshalJSON(data []byte // MarshalJSON implements the json.Marshaller interface for type VirtualNetworkLink. func (v VirtualNetworkLink) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", v.Etag) populate(objectMap, "id", v.ID) populate(objectMap, "name", v.Name) @@ -1081,7 +1081,7 @@ func (v *VirtualNetworkLink) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualNetworkLinkListResult. func (v VirtualNetworkLinkListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", v.NextLink) populate(objectMap, "value", v.Value) return json.Marshal(objectMap) @@ -1112,7 +1112,7 @@ func (v *VirtualNetworkLinkListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualNetworkLinkPatch. func (v VirtualNetworkLinkPatch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", v.Properties) return json.Marshal(objectMap) } @@ -1139,7 +1139,7 @@ func (v *VirtualNetworkLinkPatch) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualNetworkLinkPatchProperties. func (v VirtualNetworkLinkPatchProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "metadata", v.Metadata) return json.Marshal(objectMap) } @@ -1166,7 +1166,7 @@ func (v *VirtualNetworkLinkPatchProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualNetworkLinkProperties. func (v VirtualNetworkLinkProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "metadata", v.Metadata) populate(objectMap, "provisioningState", v.ProvisioningState) populate(objectMap, "virtualNetwork", v.VirtualNetwork) @@ -1201,7 +1201,7 @@ func (v *VirtualNetworkLinkProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualNetworkLinkSubResourceProperties. func (v VirtualNetworkLinkSubResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "virtualNetworkLink", v.VirtualNetworkLink) return json.Marshal(objectMap) } @@ -1226,7 +1226,7 @@ func (v *VirtualNetworkLinkSubResourceProperties) UnmarshalJSON(data []byte) err 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) { @@ -1236,7 +1236,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/dnsresolver/armdnsresolver/outboundendpoints_client.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/outboundendpoints_client.go index 14c65d2a8971..247ebd8c842d 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/outboundendpoints_client.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/outboundendpoints_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,65 +25,58 @@ import ( // OutboundEndpointsClient contains the methods for the OutboundEndpoints group. // Don't use this type directly, use NewOutboundEndpointsClient() instead. type OutboundEndpointsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewOutboundEndpointsClient creates a new instance of OutboundEndpointsClient 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 NewOutboundEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OutboundEndpointsClient, 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+".OutboundEndpointsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OutboundEndpointsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates an outbound endpoint for a DNS resolver. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsResolverName - The name of the DNS resolver. -// outboundEndpointName - The name of the outbound endpoint for the DNS resolver. -// parameters - Parameters supplied to the CreateOrUpdate operation. -// options - OutboundEndpointsClientBeginCreateOrUpdateOptions contains the optional parameters for the OutboundEndpointsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsResolverName - The name of the DNS resolver. +// - outboundEndpointName - The name of the outbound endpoint for the DNS resolver. +// - parameters - Parameters supplied to the CreateOrUpdate operation. +// - options - OutboundEndpointsClientBeginCreateOrUpdateOptions contains the optional parameters for the OutboundEndpointsClient.BeginCreateOrUpdate +// method. func (client *OutboundEndpointsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, dnsResolverName string, outboundEndpointName string, parameters OutboundEndpoint, options *OutboundEndpointsClientBeginCreateOrUpdateOptions) (*runtime.Poller[OutboundEndpointsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, dnsResolverName, outboundEndpointName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[OutboundEndpointsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[OutboundEndpointsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[OutboundEndpointsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[OutboundEndpointsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates an outbound endpoint for a DNS resolver. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 func (client *OutboundEndpointsClient) createOrUpdate(ctx context.Context, resourceGroupName string, dnsResolverName string, outboundEndpointName string, parameters OutboundEndpoint, options *OutboundEndpointsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, dnsResolverName, outboundEndpointName, 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 } @@ -114,7 +105,7 @@ func (client *OutboundEndpointsClient) createOrUpdateCreateRequest(ctx context.C return nil, errors.New("parameter outboundEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{outboundEndpointName}", url.PathEscape(outboundEndpointName)) - 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 } @@ -133,33 +124,35 @@ func (client *OutboundEndpointsClient) createOrUpdateCreateRequest(ctx context.C // BeginDelete - Deletes an outbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsResolverName - The name of the DNS resolver. -// outboundEndpointName - The name of the outbound endpoint for the DNS resolver. -// options - OutboundEndpointsClientBeginDeleteOptions contains the optional parameters for the OutboundEndpointsClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsResolverName - The name of the DNS resolver. +// - outboundEndpointName - The name of the outbound endpoint for the DNS resolver. +// - options - OutboundEndpointsClientBeginDeleteOptions contains the optional parameters for the OutboundEndpointsClient.BeginDelete +// method. func (client *OutboundEndpointsClient) BeginDelete(ctx context.Context, resourceGroupName string, dnsResolverName string, outboundEndpointName string, options *OutboundEndpointsClientBeginDeleteOptions) (*runtime.Poller[OutboundEndpointsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, dnsResolverName, outboundEndpointName, options) if err != nil { return nil, err } - return runtime.NewPoller[OutboundEndpointsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[OutboundEndpointsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[OutboundEndpointsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[OutboundEndpointsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes an outbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 func (client *OutboundEndpointsClient) deleteOperation(ctx context.Context, resourceGroupName string, dnsResolverName string, outboundEndpointName string, options *OutboundEndpointsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, dnsResolverName, outboundEndpointName, 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 } @@ -188,7 +181,7 @@ func (client *OutboundEndpointsClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter outboundEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{outboundEndpointName}", url.PathEscape(outboundEndpointName)) - 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 } @@ -204,17 +197,18 @@ func (client *OutboundEndpointsClient) deleteCreateRequest(ctx context.Context, // Get - Gets properties of an outbound endpoint for a DNS resolver. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsResolverName - The name of the DNS resolver. -// outboundEndpointName - The name of the outbound endpoint for the DNS resolver. -// options - OutboundEndpointsClientGetOptions contains the optional parameters for the OutboundEndpointsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsResolverName - The name of the DNS resolver. +// - outboundEndpointName - The name of the outbound endpoint for the DNS resolver. +// - options - OutboundEndpointsClientGetOptions contains the optional parameters for the OutboundEndpointsClient.Get method. func (client *OutboundEndpointsClient) Get(ctx context.Context, resourceGroupName string, dnsResolverName string, outboundEndpointName string, options *OutboundEndpointsClientGetOptions) (OutboundEndpointsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, dnsResolverName, outboundEndpointName, options) if err != nil { return OutboundEndpointsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OutboundEndpointsClientGetResponse{}, err } @@ -243,7 +237,7 @@ func (client *OutboundEndpointsClient) getCreateRequest(ctx context.Context, res return nil, errors.New("parameter outboundEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{outboundEndpointName}", url.PathEscape(outboundEndpointName)) - 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 } @@ -264,10 +258,12 @@ func (client *OutboundEndpointsClient) getHandleResponse(resp *http.Response) (O } // NewListPager - Lists outbound endpoints for a DNS resolver. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsResolverName - The name of the DNS resolver. -// options - OutboundEndpointsClientListOptions contains the optional parameters for the OutboundEndpointsClient.List method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsResolverName - The name of the DNS resolver. +// - options - OutboundEndpointsClientListOptions contains the optional parameters for the OutboundEndpointsClient.NewListPager +// method. func (client *OutboundEndpointsClient) NewListPager(resourceGroupName string, dnsResolverName string, options *OutboundEndpointsClientListOptions) *runtime.Pager[OutboundEndpointsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OutboundEndpointsClientListResponse]{ More: func(page OutboundEndpointsClientListResponse) bool { @@ -284,7 +280,7 @@ func (client *OutboundEndpointsClient) NewListPager(resourceGroupName string, dn if err != nil { return OutboundEndpointsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OutboundEndpointsClientListResponse{}, err } @@ -311,7 +307,7 @@ func (client *OutboundEndpointsClient) listCreateRequest(ctx context.Context, re return nil, errors.New("parameter dnsResolverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dnsResolverName}", url.PathEscape(dnsResolverName)) - 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 +332,36 @@ func (client *OutboundEndpointsClient) listHandleResponse(resp *http.Response) ( // BeginUpdate - Updates an outbound endpoint for a DNS resolver. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsResolverName - The name of the DNS resolver. -// outboundEndpointName - The name of the outbound endpoint for the DNS resolver. -// parameters - Parameters supplied to the Update operation. -// options - OutboundEndpointsClientBeginUpdateOptions contains the optional parameters for the OutboundEndpointsClient.BeginUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsResolverName - The name of the DNS resolver. +// - outboundEndpointName - The name of the outbound endpoint for the DNS resolver. +// - parameters - Parameters supplied to the Update operation. +// - options - OutboundEndpointsClientBeginUpdateOptions contains the optional parameters for the OutboundEndpointsClient.BeginUpdate +// method. func (client *OutboundEndpointsClient) BeginUpdate(ctx context.Context, resourceGroupName string, dnsResolverName string, outboundEndpointName string, parameters OutboundEndpointPatch, options *OutboundEndpointsClientBeginUpdateOptions) (*runtime.Poller[OutboundEndpointsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, dnsResolverName, outboundEndpointName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[OutboundEndpointsClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[OutboundEndpointsClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[OutboundEndpointsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[OutboundEndpointsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates an outbound endpoint for a DNS resolver. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 func (client *OutboundEndpointsClient) update(ctx context.Context, resourceGroupName string, dnsResolverName string, outboundEndpointName string, parameters OutboundEndpointPatch, options *OutboundEndpointsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, dnsResolverName, outboundEndpointName, 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 } @@ -392,7 +390,7 @@ func (client *OutboundEndpointsClient) updateCreateRequest(ctx context.Context, return nil, errors.New("parameter outboundEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{outboundEndpointName}", url.PathEscape(outboundEndpointName)) - 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/dnsresolver/armdnsresolver/outboundendpoints_client_example_test.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/outboundendpoints_client_example_test.go index a03835a58738..8fa591e9ddf3 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/outboundendpoints_client_example_test.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/outboundendpoints_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 armdnsresolver_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dnsresolver/armdnsresolver" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/OutboundEndpoint_Put.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/OutboundEndpoint_Put.json func ExampleOutboundEndpointsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewOutboundEndpointsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleOutboundEndpoint", armdnsresolver.OutboundEndpoint{ + poller, err := clientFactory.NewOutboundEndpointsClient().BeginCreateOrUpdate(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleOutboundEndpoint", armdnsresolver.OutboundEndpoint{ Location: to.Ptr("westus2"), Tags: map[string]*string{ "key1": to.Ptr("value1"), @@ -48,22 +49,46 @@ func ExampleOutboundEndpointsClient_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.OutboundEndpoint = armdnsresolver.OutboundEndpoint{ + // Name: to.Ptr("sampleOutboundEndpoint"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers/outboundEndpoints"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/outboundEndpoints/sampleOutboundEndpoint"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.OutboundEndpointProperties{ + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("87b3e20a-5833-4c40-8ad7-c5160bb1c5bd"), + // Subnet: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/OutboundEndpoint_Patch.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/OutboundEndpoint_Patch.json func ExampleOutboundEndpointsClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewOutboundEndpointsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleOutboundEndpoint", armdnsresolver.OutboundEndpointPatch{ + poller, err := clientFactory.NewOutboundEndpointsClient().BeginUpdate(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleOutboundEndpoint", armdnsresolver.OutboundEndpointPatch{ Tags: map[string]*string{ "key1": to.Ptr("value1"), }, @@ -75,22 +100,46 @@ func ExampleOutboundEndpointsClient_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.OutboundEndpoint = armdnsresolver.OutboundEndpoint{ + // Name: to.Ptr("sampleOutboundEndpoint"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers/outboundEndpoints"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/outboundEndpoints/sampleOutboundEndpoint"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.OutboundEndpointProperties{ + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("b4d35f41-0c70-4ec7-bb3e-0cd9f8b7e4be"), + // Subnet: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/OutboundEndpoint_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/OutboundEndpoint_Delete.json func ExampleOutboundEndpointsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewOutboundEndpointsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleOutboundEndpoint", &armdnsresolver.OutboundEndpointsClientBeginDeleteOptions{IfMatch: nil}) + poller, err := clientFactory.NewOutboundEndpointsClient().BeginDelete(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleOutboundEndpoint", &armdnsresolver.OutboundEndpointsClientBeginDeleteOptions{IfMatch: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -100,45 +149,119 @@ func ExampleOutboundEndpointsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/OutboundEndpoint_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/OutboundEndpoint_Get.json func ExampleOutboundEndpointsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewOutboundEndpointsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleOutboundEndpoint", nil) + res, err := clientFactory.NewOutboundEndpointsClient().Get(ctx, "sampleResourceGroup", "sampleDnsResolver", "sampleOutboundEndpoint", 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.OutboundEndpoint = armdnsresolver.OutboundEndpoint{ + // Name: to.Ptr("sampleOutboundEndpoint"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers/outboundEndpoints"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/outboundEndpoints/sampleOutboundEndpoint"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.OutboundEndpointProperties{ + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("b4d35f41-0c70-4ec7-bb3e-0cd9f8b7e4be"), + // Subnet: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/OutboundEndpoint_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/OutboundEndpoint_List.json func ExampleOutboundEndpointsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewOutboundEndpointsClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("sampleResourceGroup", "sampleDnsResolver", &armdnsresolver.OutboundEndpointsClientListOptions{Top: nil}) + pager := clientFactory.NewOutboundEndpointsClient().NewListPager("sampleResourceGroup", "sampleDnsResolver", &armdnsresolver.OutboundEndpointsClientListOptions{Top: 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.OutboundEndpointListResult = armdnsresolver.OutboundEndpointListResult{ + // Value: []*armdnsresolver.OutboundEndpoint{ + // { + // Name: to.Ptr("sampleOutboundEndpoint"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers/outboundEndpoints"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/outboundEndpoints/sampleOutboundEndpoint"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.OutboundEndpointProperties{ + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("b4d35f41-0c70-4ec7-bb3e-0cd9f8b7e4be"), + // Subnet: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // }, + // { + // Name: to.Ptr("sampleOutboundEndpoint1"), + // Type: to.Ptr("Microsoft.Network/dnsResolvers/outboundEndpoints"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/outboundEndpoints/sampleOutboundEndpoint1"), + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.OutboundEndpointProperties{ + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // ResourceGUID: to.Ptr("b4d35f41-0c70-4ec7-bb3e-0cd9f8b7e4be"), + // Subnet: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet1"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/dnsresolver/armdnsresolver/response_types.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/response_types.go index ff0d4d4ceda3..c10708bd0f3c 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/response_types.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/response_types.go @@ -9,12 +9,12 @@ package armdnsresolver -// DNSForwardingRulesetsClientCreateOrUpdateResponse contains the response from method DNSForwardingRulesetsClient.CreateOrUpdate. +// DNSForwardingRulesetsClientCreateOrUpdateResponse contains the response from method DNSForwardingRulesetsClient.BeginCreateOrUpdate. type DNSForwardingRulesetsClientCreateOrUpdateResponse struct { DNSForwardingRuleset } -// DNSForwardingRulesetsClientDeleteResponse contains the response from method DNSForwardingRulesetsClient.Delete. +// DNSForwardingRulesetsClientDeleteResponse contains the response from method DNSForwardingRulesetsClient.BeginDelete. type DNSForwardingRulesetsClientDeleteResponse struct { // placeholder for future response values } @@ -24,32 +24,32 @@ type DNSForwardingRulesetsClientGetResponse struct { DNSForwardingRuleset } -// DNSForwardingRulesetsClientListByResourceGroupResponse contains the response from method DNSForwardingRulesetsClient.ListByResourceGroup. +// DNSForwardingRulesetsClientListByResourceGroupResponse contains the response from method DNSForwardingRulesetsClient.NewListByResourceGroupPager. type DNSForwardingRulesetsClientListByResourceGroupResponse struct { DNSForwardingRulesetListResult } -// DNSForwardingRulesetsClientListByVirtualNetworkResponse contains the response from method DNSForwardingRulesetsClient.ListByVirtualNetwork. +// DNSForwardingRulesetsClientListByVirtualNetworkResponse contains the response from method DNSForwardingRulesetsClient.NewListByVirtualNetworkPager. type DNSForwardingRulesetsClientListByVirtualNetworkResponse struct { VirtualNetworkDNSForwardingRulesetListResult } -// DNSForwardingRulesetsClientListResponse contains the response from method DNSForwardingRulesetsClient.List. +// DNSForwardingRulesetsClientListResponse contains the response from method DNSForwardingRulesetsClient.NewListPager. type DNSForwardingRulesetsClientListResponse struct { DNSForwardingRulesetListResult } -// DNSForwardingRulesetsClientUpdateResponse contains the response from method DNSForwardingRulesetsClient.Update. +// DNSForwardingRulesetsClientUpdateResponse contains the response from method DNSForwardingRulesetsClient.BeginUpdate. type DNSForwardingRulesetsClientUpdateResponse struct { DNSForwardingRuleset } -// DNSResolversClientCreateOrUpdateResponse contains the response from method DNSResolversClient.CreateOrUpdate. +// DNSResolversClientCreateOrUpdateResponse contains the response from method DNSResolversClient.BeginCreateOrUpdate. type DNSResolversClientCreateOrUpdateResponse struct { DNSResolver } -// DNSResolversClientDeleteResponse contains the response from method DNSResolversClient.Delete. +// DNSResolversClientDeleteResponse contains the response from method DNSResolversClient.BeginDelete. type DNSResolversClientDeleteResponse struct { // placeholder for future response values } @@ -59,22 +59,22 @@ type DNSResolversClientGetResponse struct { DNSResolver } -// DNSResolversClientListByResourceGroupResponse contains the response from method DNSResolversClient.ListByResourceGroup. +// DNSResolversClientListByResourceGroupResponse contains the response from method DNSResolversClient.NewListByResourceGroupPager. type DNSResolversClientListByResourceGroupResponse struct { ListResult } -// DNSResolversClientListByVirtualNetworkResponse contains the response from method DNSResolversClient.ListByVirtualNetwork. +// DNSResolversClientListByVirtualNetworkResponse contains the response from method DNSResolversClient.NewListByVirtualNetworkPager. type DNSResolversClientListByVirtualNetworkResponse struct { SubResourceListResult } -// DNSResolversClientListResponse contains the response from method DNSResolversClient.List. +// DNSResolversClientListResponse contains the response from method DNSResolversClient.NewListPager. type DNSResolversClientListResponse struct { ListResult } -// DNSResolversClientUpdateResponse contains the response from method DNSResolversClient.Update. +// DNSResolversClientUpdateResponse contains the response from method DNSResolversClient.BeginUpdate. type DNSResolversClientUpdateResponse struct { DNSResolver } @@ -94,7 +94,7 @@ type ForwardingRulesClientGetResponse struct { ForwardingRule } -// ForwardingRulesClientListResponse contains the response from method ForwardingRulesClient.List. +// ForwardingRulesClientListResponse contains the response from method ForwardingRulesClient.NewListPager. type ForwardingRulesClientListResponse struct { ForwardingRuleListResult } @@ -104,12 +104,12 @@ type ForwardingRulesClientUpdateResponse struct { ForwardingRule } -// InboundEndpointsClientCreateOrUpdateResponse contains the response from method InboundEndpointsClient.CreateOrUpdate. +// InboundEndpointsClientCreateOrUpdateResponse contains the response from method InboundEndpointsClient.BeginCreateOrUpdate. type InboundEndpointsClientCreateOrUpdateResponse struct { InboundEndpoint } -// InboundEndpointsClientDeleteResponse contains the response from method InboundEndpointsClient.Delete. +// InboundEndpointsClientDeleteResponse contains the response from method InboundEndpointsClient.BeginDelete. type InboundEndpointsClientDeleteResponse struct { // placeholder for future response values } @@ -119,22 +119,22 @@ type InboundEndpointsClientGetResponse struct { InboundEndpoint } -// InboundEndpointsClientListResponse contains the response from method InboundEndpointsClient.List. +// InboundEndpointsClientListResponse contains the response from method InboundEndpointsClient.NewListPager. type InboundEndpointsClientListResponse struct { InboundEndpointListResult } -// InboundEndpointsClientUpdateResponse contains the response from method InboundEndpointsClient.Update. +// InboundEndpointsClientUpdateResponse contains the response from method InboundEndpointsClient.BeginUpdate. type InboundEndpointsClientUpdateResponse struct { InboundEndpoint } -// OutboundEndpointsClientCreateOrUpdateResponse contains the response from method OutboundEndpointsClient.CreateOrUpdate. +// OutboundEndpointsClientCreateOrUpdateResponse contains the response from method OutboundEndpointsClient.BeginCreateOrUpdate. type OutboundEndpointsClientCreateOrUpdateResponse struct { OutboundEndpoint } -// OutboundEndpointsClientDeleteResponse contains the response from method OutboundEndpointsClient.Delete. +// OutboundEndpointsClientDeleteResponse contains the response from method OutboundEndpointsClient.BeginDelete. type OutboundEndpointsClientDeleteResponse struct { // placeholder for future response values } @@ -144,22 +144,22 @@ type OutboundEndpointsClientGetResponse struct { OutboundEndpoint } -// OutboundEndpointsClientListResponse contains the response from method OutboundEndpointsClient.List. +// OutboundEndpointsClientListResponse contains the response from method OutboundEndpointsClient.NewListPager. type OutboundEndpointsClientListResponse struct { OutboundEndpointListResult } -// OutboundEndpointsClientUpdateResponse contains the response from method OutboundEndpointsClient.Update. +// OutboundEndpointsClientUpdateResponse contains the response from method OutboundEndpointsClient.BeginUpdate. type OutboundEndpointsClientUpdateResponse struct { OutboundEndpoint } -// VirtualNetworkLinksClientCreateOrUpdateResponse contains the response from method VirtualNetworkLinksClient.CreateOrUpdate. +// VirtualNetworkLinksClientCreateOrUpdateResponse contains the response from method VirtualNetworkLinksClient.BeginCreateOrUpdate. type VirtualNetworkLinksClientCreateOrUpdateResponse struct { VirtualNetworkLink } -// VirtualNetworkLinksClientDeleteResponse contains the response from method VirtualNetworkLinksClient.Delete. +// VirtualNetworkLinksClientDeleteResponse contains the response from method VirtualNetworkLinksClient.BeginDelete. type VirtualNetworkLinksClientDeleteResponse struct { // placeholder for future response values } @@ -169,12 +169,12 @@ type VirtualNetworkLinksClientGetResponse struct { VirtualNetworkLink } -// VirtualNetworkLinksClientListResponse contains the response from method VirtualNetworkLinksClient.List. +// VirtualNetworkLinksClientListResponse contains the response from method VirtualNetworkLinksClient.NewListPager. type VirtualNetworkLinksClientListResponse struct { VirtualNetworkLinkListResult } -// VirtualNetworkLinksClientUpdateResponse contains the response from method VirtualNetworkLinksClient.Update. +// VirtualNetworkLinksClientUpdateResponse contains the response from method VirtualNetworkLinksClient.BeginUpdate. type VirtualNetworkLinksClientUpdateResponse struct { VirtualNetworkLink } diff --git a/sdk/resourcemanager/dnsresolver/armdnsresolver/time_rfc3339.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/time_rfc3339.go index c8304c552848..3a2c6cda3649 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/time_rfc3339.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/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/dnsresolver/armdnsresolver/virtualnetworklinks_client.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/virtualnetworklinks_client.go index fc9f3f1c9ed2..643b97411b94 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/virtualnetworklinks_client.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/virtualnetworklinks_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,65 +25,58 @@ import ( // VirtualNetworkLinksClient contains the methods for the VirtualNetworkLinks group. // Don't use this type directly, use NewVirtualNetworkLinksClient() instead. type VirtualNetworkLinksClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVirtualNetworkLinksClient creates a new instance of VirtualNetworkLinksClient 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 NewVirtualNetworkLinksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualNetworkLinksClient, 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+".VirtualNetworkLinksClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VirtualNetworkLinksClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a virtual network link to a DNS forwarding ruleset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsForwardingRulesetName - The name of the DNS forwarding ruleset. -// virtualNetworkLinkName - The name of the virtual network link. -// parameters - Parameters supplied to the CreateOrUpdate operation. -// options - VirtualNetworkLinksClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualNetworkLinksClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsForwardingRulesetName - The name of the DNS forwarding ruleset. +// - virtualNetworkLinkName - The name of the virtual network link. +// - parameters - Parameters supplied to the CreateOrUpdate operation. +// - options - VirtualNetworkLinksClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualNetworkLinksClient.BeginCreateOrUpdate +// method. func (client *VirtualNetworkLinksClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, virtualNetworkLinkName string, parameters VirtualNetworkLink, options *VirtualNetworkLinksClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualNetworkLinksClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, dnsForwardingRulesetName, virtualNetworkLinkName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualNetworkLinksClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualNetworkLinksClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualNetworkLinksClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualNetworkLinksClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a virtual network link to a DNS forwarding ruleset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 func (client *VirtualNetworkLinksClient) createOrUpdate(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, virtualNetworkLinkName string, parameters VirtualNetworkLink, options *VirtualNetworkLinksClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, dnsForwardingRulesetName, virtualNetworkLinkName, 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 } @@ -114,7 +105,7 @@ func (client *VirtualNetworkLinksClient) createOrUpdateCreateRequest(ctx context return nil, errors.New("parameter virtualNetworkLinkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkLinkName}", url.PathEscape(virtualNetworkLinkName)) - 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 } @@ -133,33 +124,35 @@ func (client *VirtualNetworkLinksClient) createOrUpdateCreateRequest(ctx context // BeginDelete - Deletes a virtual network link to a DNS forwarding ruleset. WARNING: This operation cannot be undone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsForwardingRulesetName - The name of the DNS forwarding ruleset. -// virtualNetworkLinkName - The name of the virtual network link. -// options - VirtualNetworkLinksClientBeginDeleteOptions contains the optional parameters for the VirtualNetworkLinksClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsForwardingRulesetName - The name of the DNS forwarding ruleset. +// - virtualNetworkLinkName - The name of the virtual network link. +// - options - VirtualNetworkLinksClientBeginDeleteOptions contains the optional parameters for the VirtualNetworkLinksClient.BeginDelete +// method. func (client *VirtualNetworkLinksClient) BeginDelete(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, virtualNetworkLinkName string, options *VirtualNetworkLinksClientBeginDeleteOptions) (*runtime.Poller[VirtualNetworkLinksClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, dnsForwardingRulesetName, virtualNetworkLinkName, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualNetworkLinksClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualNetworkLinksClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualNetworkLinksClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualNetworkLinksClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a virtual network link to a DNS forwarding ruleset. WARNING: This operation cannot be undone. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 func (client *VirtualNetworkLinksClient) deleteOperation(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, virtualNetworkLinkName string, options *VirtualNetworkLinksClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, dnsForwardingRulesetName, virtualNetworkLinkName, 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 } @@ -188,7 +181,7 @@ func (client *VirtualNetworkLinksClient) deleteCreateRequest(ctx context.Context return nil, errors.New("parameter virtualNetworkLinkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkLinkName}", url.PathEscape(virtualNetworkLinkName)) - 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 } @@ -204,17 +197,18 @@ func (client *VirtualNetworkLinksClient) deleteCreateRequest(ctx context.Context // Get - Gets properties of a virtual network link to a DNS forwarding ruleset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsForwardingRulesetName - The name of the DNS forwarding ruleset. -// virtualNetworkLinkName - The name of the virtual network link. -// options - VirtualNetworkLinksClientGetOptions contains the optional parameters for the VirtualNetworkLinksClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsForwardingRulesetName - The name of the DNS forwarding ruleset. +// - virtualNetworkLinkName - The name of the virtual network link. +// - options - VirtualNetworkLinksClientGetOptions contains the optional parameters for the VirtualNetworkLinksClient.Get method. func (client *VirtualNetworkLinksClient) Get(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, virtualNetworkLinkName string, options *VirtualNetworkLinksClientGetOptions) (VirtualNetworkLinksClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, dnsForwardingRulesetName, virtualNetworkLinkName, options) if err != nil { return VirtualNetworkLinksClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualNetworkLinksClientGetResponse{}, err } @@ -243,7 +237,7 @@ func (client *VirtualNetworkLinksClient) getCreateRequest(ctx context.Context, r return nil, errors.New("parameter virtualNetworkLinkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkLinkName}", url.PathEscape(virtualNetworkLinkName)) - 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 } @@ -264,11 +258,12 @@ func (client *VirtualNetworkLinksClient) getHandleResponse(resp *http.Response) } // NewListPager - Lists virtual network links to a DNS forwarding ruleset. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsForwardingRulesetName - The name of the DNS forwarding ruleset. -// options - VirtualNetworkLinksClientListOptions contains the optional parameters for the VirtualNetworkLinksClient.List -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsForwardingRulesetName - The name of the DNS forwarding ruleset. +// - options - VirtualNetworkLinksClientListOptions contains the optional parameters for the VirtualNetworkLinksClient.NewListPager +// method. func (client *VirtualNetworkLinksClient) NewListPager(resourceGroupName string, dnsForwardingRulesetName string, options *VirtualNetworkLinksClientListOptions) *runtime.Pager[VirtualNetworkLinksClientListResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualNetworkLinksClientListResponse]{ More: func(page VirtualNetworkLinksClientListResponse) bool { @@ -285,7 +280,7 @@ func (client *VirtualNetworkLinksClient) NewListPager(resourceGroupName string, if err != nil { return VirtualNetworkLinksClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualNetworkLinksClientListResponse{}, err } @@ -312,7 +307,7 @@ func (client *VirtualNetworkLinksClient) listCreateRequest(ctx context.Context, return nil, errors.New("parameter dnsForwardingRulesetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dnsForwardingRulesetName}", url.PathEscape(dnsForwardingRulesetName)) - 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 } @@ -337,34 +332,36 @@ func (client *VirtualNetworkLinksClient) listHandleResponse(resp *http.Response) // BeginUpdate - Updates a virtual network link to a DNS forwarding ruleset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// dnsForwardingRulesetName - The name of the DNS forwarding ruleset. -// virtualNetworkLinkName - The name of the virtual network link. -// parameters - Parameters supplied to the Update operation. -// options - VirtualNetworkLinksClientBeginUpdateOptions contains the optional parameters for the VirtualNetworkLinksClient.BeginUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dnsForwardingRulesetName - The name of the DNS forwarding ruleset. +// - virtualNetworkLinkName - The name of the virtual network link. +// - parameters - Parameters supplied to the Update operation. +// - options - VirtualNetworkLinksClientBeginUpdateOptions contains the optional parameters for the VirtualNetworkLinksClient.BeginUpdate +// method. func (client *VirtualNetworkLinksClient) BeginUpdate(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, virtualNetworkLinkName string, parameters VirtualNetworkLinkPatch, options *VirtualNetworkLinksClientBeginUpdateOptions) (*runtime.Poller[VirtualNetworkLinksClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, dnsForwardingRulesetName, virtualNetworkLinkName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualNetworkLinksClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualNetworkLinksClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualNetworkLinksClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualNetworkLinksClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates a virtual network link to a DNS forwarding ruleset. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01 func (client *VirtualNetworkLinksClient) update(ctx context.Context, resourceGroupName string, dnsForwardingRulesetName string, virtualNetworkLinkName string, parameters VirtualNetworkLinkPatch, options *VirtualNetworkLinksClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, dnsForwardingRulesetName, virtualNetworkLinkName, 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 } @@ -393,7 +390,7 @@ func (client *VirtualNetworkLinksClient) updateCreateRequest(ctx context.Context return nil, errors.New("parameter virtualNetworkLinkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkLinkName}", url.PathEscape(virtualNetworkLinkName)) - 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/dnsresolver/armdnsresolver/virtualnetworklinks_client_example_test.go b/sdk/resourcemanager/dnsresolver/armdnsresolver/virtualnetworklinks_client_example_test.go index e578d1c46dc3..f02b75d579e6 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/virtualnetworklinks_client_example_test.go +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/virtualnetworklinks_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 armdnsresolver_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dnsresolver/armdnsresolver" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/VirtualNetworkLink_Put.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/VirtualNetworkLink_Put.json func ExampleVirtualNetworkLinksClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewVirtualNetworkLinksClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleVirtualNetworkLink", armdnsresolver.VirtualNetworkLink{ + poller, err := clientFactory.NewVirtualNetworkLinksClient().BeginCreateOrUpdate(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleVirtualNetworkLink", armdnsresolver.VirtualNetworkLink{ Properties: &armdnsresolver.VirtualNetworkLinkProperties{ Metadata: map[string]*string{ "additionalProp1": to.Ptr("value1"), @@ -47,22 +48,44 @@ func ExampleVirtualNetworkLinksClient_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.VirtualNetworkLink = armdnsresolver.VirtualNetworkLink{ + // Name: to.Ptr("sampleVirtualNetworkLink"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets/virtualNetworkLinks"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRuleset/sampleDnsForwardingRuleset/virtualNetworkLinks/sampleVirtualNetworkLink"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.VirtualNetworkLinkProperties{ + // Metadata: map[string]*string{ + // "additionalProp1": to.Ptr("value1"), + // }, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // VirtualNetwork: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/VirtualNetworkLink_Patch.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/VirtualNetworkLink_Patch.json func ExampleVirtualNetworkLinksClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewVirtualNetworkLinksClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleVirtualNetworkLink", armdnsresolver.VirtualNetworkLinkPatch{ + poller, err := clientFactory.NewVirtualNetworkLinksClient().BeginUpdate(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleVirtualNetworkLink", armdnsresolver.VirtualNetworkLinkPatch{ Properties: &armdnsresolver.VirtualNetworkLinkPatchProperties{ Metadata: map[string]*string{ "additionalProp1": to.Ptr("value1"), @@ -76,22 +99,44 @@ func ExampleVirtualNetworkLinksClient_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.VirtualNetworkLink = armdnsresolver.VirtualNetworkLink{ + // Name: to.Ptr("sampleVirtualNetworkLink"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets/virtualNetworkLinks"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRuleset/sampleDnsForwardingRuleset/virtualNetworkLinks/sampleVirtualNetworkLink"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.VirtualNetworkLinkProperties{ + // Metadata: map[string]*string{ + // "additionalProp1": to.Ptr("value1"), + // }, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // VirtualNetwork: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/VirtualNetworkLink_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/VirtualNetworkLink_Delete.json func ExampleVirtualNetworkLinksClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewVirtualNetworkLinksClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleVirtualNetworkLink", &armdnsresolver.VirtualNetworkLinksClientBeginDeleteOptions{IfMatch: nil}) + poller, err := clientFactory.NewVirtualNetworkLinksClient().BeginDelete(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleVirtualNetworkLink", &armdnsresolver.VirtualNetworkLinksClientBeginDeleteOptions{IfMatch: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -101,45 +146,92 @@ func ExampleVirtualNetworkLinksClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/VirtualNetworkLink_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/VirtualNetworkLink_Get.json func ExampleVirtualNetworkLinksClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewVirtualNetworkLinksClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleVirtualNetworkLink", nil) + res, err := clientFactory.NewVirtualNetworkLinksClient().Get(ctx, "sampleResourceGroup", "sampleDnsForwardingRuleset", "sampleVirtualNetworkLink", 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.VirtualNetworkLink = armdnsresolver.VirtualNetworkLink{ + // Name: to.Ptr("sampleVirtualNetworkLink"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets/virtualNetworkLinks"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRuleset/sampleDnsForwardingRuleset/virtualNetworkLinks/sampleVirtualNetworkLink"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.VirtualNetworkLinkProperties{ + // Metadata: map[string]*string{ + // "additionalProp1": to.Ptr("value1"), + // }, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // VirtualNetwork: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/VirtualNetworkLink_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b749953e21e5c3f275d839862323920ef7bf716e/specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/VirtualNetworkLink_List.json func ExampleVirtualNetworkLinksClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdnsresolver.NewVirtualNetworkLinksClient("abdd4249-9f34-4cc6-8e42-c2e32110603e", cred, nil) + clientFactory, err := armdnsresolver.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("sampleResourceGroup", "sampleDnsForwardingRuleset", &armdnsresolver.VirtualNetworkLinksClientListOptions{Top: nil}) + pager := clientFactory.NewVirtualNetworkLinksClient().NewListPager("sampleResourceGroup", "sampleDnsForwardingRuleset", &armdnsresolver.VirtualNetworkLinksClientListOptions{Top: 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.VirtualNetworkLinkListResult = armdnsresolver.VirtualNetworkLinkListResult{ + // Value: []*armdnsresolver.VirtualNetworkLink{ + // { + // Name: to.Ptr("sampleVirtualNetworkLink"), + // Type: to.Ptr("Microsoft.Network/dnsForwardingRulesets/virtualNetworkLinks"), + // ID: to.Ptr("/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsForwardingRuleset/sampleDnsForwardingRuleset/virtualNetworkLinks/sampleVirtualNetworkLink"), + // Etag: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Properties: &armdnsresolver.VirtualNetworkLinkProperties{ + // Metadata: map[string]*string{ + // "additionalProp1": to.Ptr("value1"), + // }, + // ProvisioningState: to.Ptr(armdnsresolver.ProvisioningStateSucceeded), + // VirtualNetwork: &armdnsresolver.SubResource{ + // ID: to.Ptr("/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork"), + // }, + // }, + // SystemData: &armdnsresolver.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T01:01:01.1075056Z"); return t}()), + // CreatedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T02:03:01.1974346Z"); return t}()), + // LastModifiedByType: to.Ptr(armdnsresolver.CreatedByTypeApplication), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/domainservices/armdomainservices/CHANGELOG.md b/sdk/resourcemanager/domainservices/armdomainservices/CHANGELOG.md index 0f6eb6606da3..49fc56c1f46f 100644 --- a/sdk/resourcemanager/domainservices/armdomainservices/CHANGELOG.md +++ b/sdk/resourcemanager/domainservices/armdomainservices/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-28) +### 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/domainservices/armdomainservices` 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/domainservices/armdomainservices/README.md b/sdk/resourcemanager/domainservices/armdomainservices/README.md index 72d34b7aa982..4f4ab5fa133e 100644 --- a/sdk/resourcemanager/domainservices/armdomainservices/README.md +++ b/sdk/resourcemanager/domainservices/armdomainservices/README.md @@ -1,8 +1,8 @@ -# Azure Domain Services Module for Go +# Azure Domain Services Module for Go [![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/domainservices/armdomainservices)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/domainservices/armdomainservices) -The `armdomainservices` module provides operations for working with Azure Domain Services . +The `armdomainservices` module provides operations for working with Azure Domain Services. [Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/domainservices/armdomainservices) @@ -17,7 +17,7 @@ The `armdomainservices` module provides operations for working with Azure Domain This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. -Install the Azure Domain Services module: +Install the Azure Domain Services module: ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/domainservices/armdomainservices @@ -25,7 +25,7 @@ go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/domainservices/armd ## Authorization -When creating a client, you will need to provide a credential for authenticating with Azure Domain Services . The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. +When creating a client, you will need to provide a credential for authenticating with Azure Domain Services. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. ```go cred, err := azidentity.NewDefaultAzureCredential(nil) @@ -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 Domain 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 Domain 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 := armdomainservices.NewOuContainerClient(, cred, nil) +clientFactory, err := armdomainservices.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,13 +49,21 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armdomainservices.NewOuContainerClient(, cred, &options) +clientFactory, err := armdomainservices.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.NewDomainServiceOperationsClient() ``` ## Provide Feedback If you encounter bugs or have suggestions, please -[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Domain Services ` label. +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Domain Services` label. # Contributing diff --git a/sdk/resourcemanager/domainservices/armdomainservices/autorest.md b/sdk/resourcemanager/domainservices/armdomainservices/autorest.md index 32ec46be3360..7914251ed611 100644 --- a/sdk/resourcemanager/domainservices/armdomainservices/autorest.md +++ b/sdk/resourcemanager/domainservices/armdomainservices/autorest.md @@ -8,5 +8,5 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/domainservices/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/domainservices/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/domainservices/armdomainservices/zz_generated_client.go b/sdk/resourcemanager/domainservices/armdomainservices/client.go similarity index 84% rename from sdk/resourcemanager/domainservices/armdomainservices/zz_generated_client.go rename to sdk/resourcemanager/domainservices/armdomainservices/client.go index 65e8fe83021c..c82b19410e66 100644 --- a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_client.go +++ b/sdk/resourcemanager/domainservices/armdomainservices/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 armdomainservices @@ -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 ( // Client contains the methods for the DomainServices 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 the 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 the 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 } @@ -59,20 +49,21 @@ func NewClient(subscriptionID string, credential azcore.TokenCredential, options // the specific service already exists, then any patchable properties will be updated and any immutable // properties will remain unchanged. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// domainServiceName - The name of the domain service. -// domainService - Properties supplied to the Create or Update a Domain Service operation. -// options - ClientBeginCreateOrUpdateOptions contains the optional parameters for the Client.BeginCreateOrUpdate method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - domainServiceName - The name of the domain service. +// - domainService - Properties supplied to the Create or Update a Domain Service operation. +// - options - ClientBeginCreateOrUpdateOptions contains the optional parameters for the Client.BeginCreateOrUpdate method. func (client *Client) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, domainServiceName string, domainService DomainService, options *ClientBeginCreateOrUpdateOptions) (*runtime.Poller[ClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, domainServiceName, domainService, 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) } } @@ -80,13 +71,14 @@ func (client *Client) BeginCreateOrUpdate(ctx context.Context, resourceGroupName // specific service already exists, then any patchable properties will be updated and any immutable // properties will remain unchanged. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *Client) createOrUpdate(ctx context.Context, resourceGroupName string, domainServiceName string, domainService DomainService, options *ClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, domainServiceName, domainService, 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 } @@ -111,7 +103,7 @@ func (client *Client) createOrUpdateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter domainServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{domainServiceName}", url.PathEscape(domainServiceName)) - 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 } @@ -124,31 +116,33 @@ func (client *Client) createOrUpdateCreateRequest(ctx context.Context, resourceG // BeginDelete - The Delete Domain Service operation deletes an existing Domain Service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// domainServiceName - The name of the domain service. -// options - ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - domainServiceName - The name of the domain service. +// - options - ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. func (client *Client) BeginDelete(ctx context.Context, resourceGroupName string, domainServiceName string, options *ClientBeginDeleteOptions) (*runtime.Poller[ClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, domainServiceName, options) if err != nil { return nil, err } - return runtime.NewPoller[ClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[ClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - The Delete Domain Service operation deletes an existing Domain Service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *Client) deleteOperation(ctx context.Context, resourceGroupName string, domainServiceName string, options *ClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, domainServiceName, 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 } @@ -173,7 +167,7 @@ func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName return nil, errors.New("parameter domainServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{domainServiceName}", url.PathEscape(domainServiceName)) - 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 } @@ -186,16 +180,17 @@ func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName // Get - The Get Domain Service operation retrieves a json representation of the Domain Service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// domainServiceName - The name of the domain service. -// options - ClientGetOptions contains the optional parameters for the Client.Get method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - domainServiceName - The name of the domain service. +// - options - ClientGetOptions contains the optional parameters for the Client.Get method. func (client *Client) Get(ctx context.Context, resourceGroupName string, domainServiceName string, options *ClientGetOptions) (ClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, domainServiceName, 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 } @@ -220,7 +215,7 @@ func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName st return nil, errors.New("parameter domainServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{domainServiceName}", url.PathEscape(domainServiceName)) - 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,9 +237,9 @@ func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, // NewListPager - The List Domain Services in Subscription operation lists all the domain services available under the given // subscription (and across all resource groups within that subscription). -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// options - ClientListOptions contains the optional parameters for the Client.List method. +// - options - ClientListOptions contains the optional parameters for the Client.NewListPager method. func (client *Client) NewListPager(options *ClientListOptions) *runtime.Pager[ClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ClientListResponse]{ More: func(page ClientListResponse) bool { @@ -261,7 +256,7 @@ func (client *Client) NewListPager(options *ClientListOptions) *runtime.Pager[Cl 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 } @@ -280,7 +275,7 @@ func (client *Client) listCreateRequest(ctx context.Context, options *ClientList 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 } @@ -302,10 +297,11 @@ func (client *Client) listHandleResponse(resp *http.Response) (ClientListRespons // NewListByResourceGroupPager - The List Domain Services in Resource Group operation lists all the domain services available // under the 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 within the user's subscription. The name is case insensitive. -// options - ClientListByResourceGroupOptions contains the optional parameters for the Client.ListByResourceGroup method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - options - ClientListByResourceGroupOptions contains the optional parameters for the Client.NewListByResourceGroupPager +// method. func (client *Client) NewListByResourceGroupPager(resourceGroupName string, options *ClientListByResourceGroupOptions) *runtime.Pager[ClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[ClientListByResourceGroupResponse]{ More: func(page ClientListByResourceGroupResponse) bool { @@ -322,7 +318,7 @@ func (client *Client) NewListByResourceGroupPager(resourceGroupName string, opti if err != nil { return ClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientListByResourceGroupResponse{}, err } @@ -345,7 +341,7 @@ func (client *Client) listByResourceGroupCreateRequest(ctx context.Context, reso 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 } @@ -368,33 +364,35 @@ func (client *Client) listByResourceGroupHandleResponse(resp *http.Response) (Cl // BeginUpdate - The Update Domain Service operation can be used to update the existing deployment. The update call only supports // the properties listed in the PATCH body. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// domainServiceName - The name of the domain service. -// domainService - Properties supplied to the Update a Domain Service operation. -// options - ClientBeginUpdateOptions contains the optional parameters for the Client.BeginUpdate method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - domainServiceName - The name of the domain service. +// - domainService - Properties supplied to the Update a Domain Service operation. +// - options - ClientBeginUpdateOptions contains the optional parameters for the Client.BeginUpdate method. func (client *Client) BeginUpdate(ctx context.Context, resourceGroupName string, domainServiceName string, domainService DomainService, options *ClientBeginUpdateOptions) (*runtime.Poller[ClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, domainServiceName, domainService, 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 - The Update Domain Service operation can be used to update the existing deployment. The update call only supports // the properties listed in the PATCH body. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *Client) update(ctx context.Context, resourceGroupName string, domainServiceName string, domainService DomainService, options *ClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, domainServiceName, domainService, 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 } @@ -419,7 +417,7 @@ func (client *Client) updateCreateRequest(ctx context.Context, resourceGroupName return nil, errors.New("parameter domainServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{domainServiceName}", url.PathEscape(domainServiceName)) - 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/domainservices/armdomainservices/client_example_test.go b/sdk/resourcemanager/domainservices/armdomainservices/client_example_test.go new file mode 100644 index 000000000000..5e522d53ceb5 --- /dev/null +++ b/sdk/resourcemanager/domainservices/armdomainservices/client_example_test.go @@ -0,0 +1,540 @@ +//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 armdomainservices_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/domainservices/armdomainservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListDomainServicesBySubscription.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 := armdomainservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewClient().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.DomainServiceListResult = armdomainservices.DomainServiceListResult{ + // Value: []*armdomainservices.DomainService{ + // { + // Name: to.Ptr("TestDomainService.com"), + // Type: to.Ptr("Microsoft.AAD/DomainServices"), + // ID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestResourceGroup/providers/Microsoft.AAD/DomainServices/TestDomainService.com"), + // Properties: &armdomainservices.DomainServiceProperties{ + // DeploymentID: to.Ptr("4a619871-0150-41c4-aeb4-0b10deb7940a"), + // DomainName: to.Ptr("TestDomainService.com"), + // DomainSecuritySettings: &armdomainservices.DomainSecuritySettings{ + // NtlmV1: to.Ptr(armdomainservices.NtlmV1Enabled), + // SyncNtlmPasswords: to.Ptr(armdomainservices.SyncNtlmPasswordsEnabled), + // TLSV1: to.Ptr(armdomainservices.TLSV1Disabled), + // }, + // FilteredSync: to.Ptr(armdomainservices.FilteredSyncEnabled), + // LdapsSettings: &armdomainservices.LdapsSettings{ + // CertificateNotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-15T21:43:21Z"); return t}()), + // CertificateThumbprint: to.Ptr("9154A390F0C387D679E0DD040701745CDFED67F3"), + // ExternalAccess: to.Ptr(armdomainservices.ExternalAccessEnabled), + // Ldaps: to.Ptr(armdomainservices.LdapsEnabled), + // PublicCertificate: to.Ptr("MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w..."), + // }, + // NotificationSettings: &armdomainservices.NotificationSettings{ + // AdditionalRecipients: []*string{ + // to.Ptr("jicha@microsoft.com"), + // to.Ptr("caalmont@microsoft.com")}, + // NotifyDcAdmins: to.Ptr(armdomainservices.NotifyDcAdminsEnabled), + // NotifyGlobalAdmins: to.Ptr(armdomainservices.NotifyGlobalAdminsEnabled), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ReplicaSets: []*armdomainservices.ReplicaSet{ + // { + // DomainControllerIPAddress: []*string{ + // to.Ptr("10.0.0.1"), + // to.Ptr("10.0.0.2")}, + // ExternalAccessIPAddress: to.Ptr("13.64.148.151"), + // HealthAlerts: []*armdomainservices.HealthAlert{ + // { + // Name: to.Ptr("The managed domain is experiencing a network error"), + // ID: to.Ptr("AADDS104"), + // Issue: to.Ptr("Microsoft is unable to reach the domain controllers for this managed domain. This may happen if a network security group (NSG) configured on your virtual network blocks access to the managed domain. Another possible reason is if there is a user defined route that blocks incoming traffic from the internet."), + // LastDetected: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-18T17:46:39.2697888Z"); return t}()), + // Raised: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-18T01:55:40.7834289Z"); return t}()), + // ResolutionURI: to.Ptr("https://aka.ms/aadds-neterr"), + // Severity: to.Ptr("2"), + // }}, + // HealthLastEvaluated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2018-02-15T21:43:21Z"); return t}()), + // HealthMonitors: []*armdomainservices.HealthMonitor{ + // { + // Name: to.Ptr("Backup"), + // ID: to.Ptr("AADDS501"), + // Details: to.Ptr("Last backed up on Tue, 18 Sep 2018 03:37:04 GMT"), + // }, + // { + // Name: to.Ptr("Synchronization with Azure AD"), + // ID: to.Ptr("AADDS500"), + // Details: to.Ptr("Synchronized on Tue, 18 Sep 2018 16:47:57 GMT."), + // }}, + // Location: to.Ptr("West US"), + // ReplicaSetID: to.Ptr("4a619871-0150-41c4-aeb4-0b10deb7940a"), + // ServiceStatus: to.Ptr("Running"), + // SubnetID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS"), + // VnetSiteID: to.Ptr("99083198-a39c-469f-972d-59017e7f078c"), + // }}, + // SyncOwner: to.Ptr("4a619871-0150-41c4-aeb4-0b10deb7940a"), + // TenantID: to.Ptr("3f8cd22c-7b32-48aa-a01c-f533133b1def"), + // Version: to.Ptr[int32](2), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListDomainServicesByResourceGroup.json +func ExampleClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdomainservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewClient().NewListByResourceGroupPager("TestResourceGroup", 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.DomainServiceListResult = armdomainservices.DomainServiceListResult{ + // Value: []*armdomainservices.DomainService{ + // { + // Name: to.Ptr("TestDomainService.com"), + // Type: to.Ptr("Microsoft.AAD/DomainServices"), + // ID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestResourceGroup/providers/Microsoft.AAD/DomainServices/TestDomainService.com"), + // Properties: &armdomainservices.DomainServiceProperties{ + // DeploymentID: to.Ptr("4a619871-0150-41c4-aeb4-0b10deb7940a"), + // DomainName: to.Ptr("TestDomainService.com"), + // DomainSecuritySettings: &armdomainservices.DomainSecuritySettings{ + // NtlmV1: to.Ptr(armdomainservices.NtlmV1Enabled), + // SyncNtlmPasswords: to.Ptr(armdomainservices.SyncNtlmPasswordsEnabled), + // TLSV1: to.Ptr(armdomainservices.TLSV1Disabled), + // }, + // FilteredSync: to.Ptr(armdomainservices.FilteredSyncEnabled), + // LdapsSettings: &armdomainservices.LdapsSettings{ + // CertificateNotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-15T21:43:21Z"); return t}()), + // CertificateThumbprint: to.Ptr("9154A390F0C387D679E0DD040701745CDFED67F3"), + // ExternalAccess: to.Ptr(armdomainservices.ExternalAccessEnabled), + // Ldaps: to.Ptr(armdomainservices.LdapsEnabled), + // PublicCertificate: to.Ptr("MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w..."), + // }, + // NotificationSettings: &armdomainservices.NotificationSettings{ + // AdditionalRecipients: []*string{ + // to.Ptr("jicha@microsoft.com"), + // to.Ptr("caalmont@microsoft.com")}, + // NotifyDcAdmins: to.Ptr(armdomainservices.NotifyDcAdminsEnabled), + // NotifyGlobalAdmins: to.Ptr(armdomainservices.NotifyGlobalAdminsEnabled), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ReplicaSets: []*armdomainservices.ReplicaSet{ + // { + // DomainControllerIPAddress: []*string{ + // to.Ptr("10.0.0.1"), + // to.Ptr("10.0.0.2")}, + // ExternalAccessIPAddress: to.Ptr("13.64.148.151"), + // HealthAlerts: []*armdomainservices.HealthAlert{ + // { + // Name: to.Ptr("The managed domain is experiencing a network error"), + // ID: to.Ptr("AADDS104"), + // Issue: to.Ptr("Microsoft is unable to reach the domain controllers for this managed domain. This may happen if a network security group (NSG) configured on your virtual network blocks access to the managed domain. Another possible reason is if there is a user defined route that blocks incoming traffic from the internet."), + // LastDetected: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-18T17:46:39.2697888Z"); return t}()), + // Raised: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-18T01:55:40.7834289Z"); return t}()), + // ResolutionURI: to.Ptr("https://aka.ms/aadds-neterr"), + // Severity: to.Ptr("2"), + // }}, + // HealthLastEvaluated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2018-02-15T21:43:21Z"); return t}()), + // HealthMonitors: []*armdomainservices.HealthMonitor{ + // { + // Name: to.Ptr("Backup"), + // ID: to.Ptr("AADDS501"), + // Details: to.Ptr("Last backed up on Tue, 18 Sep 2018 03:37:04 GMT"), + // }, + // { + // Name: to.Ptr("Synchronization with Azure AD"), + // ID: to.Ptr("AADDS500"), + // Details: to.Ptr("Synchronized on Tue, 18 Sep 2018 16:47:57 GMT."), + // }}, + // Location: to.Ptr("West US"), + // ReplicaSetID: to.Ptr("4a619871-0150-41c4-aeb4-0b10deb7940a"), + // ServiceStatus: to.Ptr("Running"), + // SubnetID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS"), + // VnetSiteID: to.Ptr("99083198-a39c-469f-972d-59017e7f078c"), + // }}, + // SyncOwner: to.Ptr("4a619871-0150-41c4-aeb4-0b10deb7940a"), + // TenantID: to.Ptr("3f8cd22c-7b32-48aa-a01c-f533133b1def"), + // Version: to.Ptr[int32](2), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/CreateDomainService.json +func ExampleClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdomainservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewClient().BeginCreateOrUpdate(ctx, "TestResourceGroup", "TestDomainService.com", armdomainservices.DomainService{ + Properties: &armdomainservices.DomainServiceProperties{ + DomainName: to.Ptr("TestDomainService.com"), + DomainSecuritySettings: &armdomainservices.DomainSecuritySettings{ + NtlmV1: to.Ptr(armdomainservices.NtlmV1Enabled), + SyncNtlmPasswords: to.Ptr(armdomainservices.SyncNtlmPasswordsEnabled), + TLSV1: to.Ptr(armdomainservices.TLSV1Disabled), + }, + FilteredSync: to.Ptr(armdomainservices.FilteredSyncEnabled), + LdapsSettings: &armdomainservices.LdapsSettings{ + ExternalAccess: to.Ptr(armdomainservices.ExternalAccessEnabled), + Ldaps: to.Ptr(armdomainservices.LdapsEnabled), + PfxCertificate: to.Ptr("MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w..."), + PfxCertificatePassword: to.Ptr(""), + }, + NotificationSettings: &armdomainservices.NotificationSettings{ + AdditionalRecipients: []*string{ + to.Ptr("jicha@microsoft.com"), + to.Ptr("caalmont@microsoft.com")}, + NotifyDcAdmins: to.Ptr(armdomainservices.NotifyDcAdminsEnabled), + NotifyGlobalAdmins: to.Ptr(armdomainservices.NotifyGlobalAdminsEnabled), + }, + ReplicaSets: []*armdomainservices.ReplicaSet{ + { + Location: to.Ptr("West US"), + SubnetID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS"), + }}, + }, + }, 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.DomainService = armdomainservices.DomainService{ + // Name: to.Ptr("TestDomainService.com"), + // Type: to.Ptr("Microsoft.AAD/DomainServices"), + // ID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestResourceGroup/providers/Microsoft.AAD/DomainServices/TestDomainService.com"), + // Properties: &armdomainservices.DomainServiceProperties{ + // DeploymentID: to.Ptr("4a619871-0150-41c4-aeb4-0b10deb7940a"), + // DomainName: to.Ptr("TestDomainService.com"), + // DomainSecuritySettings: &armdomainservices.DomainSecuritySettings{ + // NtlmV1: to.Ptr(armdomainservices.NtlmV1Enabled), + // SyncNtlmPasswords: to.Ptr(armdomainservices.SyncNtlmPasswordsEnabled), + // TLSV1: to.Ptr(armdomainservices.TLSV1Disabled), + // }, + // FilteredSync: to.Ptr(armdomainservices.FilteredSyncEnabled), + // LdapsSettings: &armdomainservices.LdapsSettings{ + // CertificateNotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-15T21:43:21Z"); return t}()), + // CertificateThumbprint: to.Ptr("9154A390F0C387D679E0DD040701745CDFED67F3"), + // ExternalAccess: to.Ptr(armdomainservices.ExternalAccessEnabled), + // Ldaps: to.Ptr(armdomainservices.LdapsEnabled), + // PublicCertificate: to.Ptr("MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w..."), + // }, + // NotificationSettings: &armdomainservices.NotificationSettings{ + // AdditionalRecipients: []*string{ + // to.Ptr("jicha@microsoft.com"), + // to.Ptr("caalmont@microsoft.com")}, + // NotifyDcAdmins: to.Ptr(armdomainservices.NotifyDcAdminsEnabled), + // NotifyGlobalAdmins: to.Ptr(armdomainservices.NotifyGlobalAdminsEnabled), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ReplicaSets: []*armdomainservices.ReplicaSet{ + // { + // DomainControllerIPAddress: []*string{ + // to.Ptr("10.0.0.1"), + // to.Ptr("10.0.0.2")}, + // ExternalAccessIPAddress: to.Ptr("13.64.148.151"), + // Location: to.Ptr("West US"), + // ReplicaSetID: to.Ptr("4a619871-0150-41c4-aeb4-0b10deb7940a"), + // ServiceStatus: to.Ptr("Running"), + // SubnetID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS"), + // VnetSiteID: to.Ptr("99083198-a39c-469f-972d-59017e7f078c"), + // }}, + // SyncOwner: to.Ptr("4a619871-0150-41c4-aeb4-0b10deb7940a"), + // TenantID: to.Ptr("3f8cd22c-7b32-48aa-a01c-f533133b1def"), + // Version: to.Ptr[int32](2), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetDomainService.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 := armdomainservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewClient().Get(ctx, "TestResourceGroup", "TestDomainService.com", 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.DomainService = armdomainservices.DomainService{ + // Name: to.Ptr("TestDomainService.com"), + // Type: to.Ptr("Microsoft.AAD/DomainServices"), + // ID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestResourceGroup/providers/Microsoft.AAD/DomainServices/TestDomainService.com"), + // Properties: &armdomainservices.DomainServiceProperties{ + // DeploymentID: to.Ptr("4a619871-0150-41c4-aeb4-0b10deb7940a"), + // DomainName: to.Ptr("TestDomainService.com"), + // DomainSecuritySettings: &armdomainservices.DomainSecuritySettings{ + // NtlmV1: to.Ptr(armdomainservices.NtlmV1Enabled), + // SyncNtlmPasswords: to.Ptr(armdomainservices.SyncNtlmPasswordsEnabled), + // TLSV1: to.Ptr(armdomainservices.TLSV1Disabled), + // }, + // FilteredSync: to.Ptr(armdomainservices.FilteredSyncEnabled), + // LdapsSettings: &armdomainservices.LdapsSettings{ + // CertificateNotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-15T21:43:21Z"); return t}()), + // CertificateThumbprint: to.Ptr("9154A390F0C387D679E0DD040701745CDFED67F3"), + // ExternalAccess: to.Ptr(armdomainservices.ExternalAccessEnabled), + // Ldaps: to.Ptr(armdomainservices.LdapsEnabled), + // PublicCertificate: to.Ptr("MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w..."), + // }, + // NotificationSettings: &armdomainservices.NotificationSettings{ + // AdditionalRecipients: []*string{ + // to.Ptr("jicha@microsoft.com"), + // to.Ptr("caalmont@microsoft.com")}, + // NotifyDcAdmins: to.Ptr(armdomainservices.NotifyDcAdminsEnabled), + // NotifyGlobalAdmins: to.Ptr(armdomainservices.NotifyGlobalAdminsEnabled), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ReplicaSets: []*armdomainservices.ReplicaSet{ + // { + // DomainControllerIPAddress: []*string{ + // to.Ptr("10.0.0.1"), + // to.Ptr("10.0.0.2")}, + // ExternalAccessIPAddress: to.Ptr("13.64.148.151"), + // HealthAlerts: []*armdomainservices.HealthAlert{ + // { + // Name: to.Ptr("The managed domain is experiencing a network error"), + // ID: to.Ptr("AADDS104"), + // Issue: to.Ptr("Microsoft is unable to reach the domain controllers for this managed domain. This may happen if a network security group (NSG) configured on your virtual network blocks access to the managed domain. Another possible reason is if there is a user defined route that blocks incoming traffic from the internet."), + // LastDetected: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-18T17:46:39.2697888Z"); return t}()), + // Raised: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-18T01:55:40.7834289Z"); return t}()), + // ResolutionURI: to.Ptr("https://aka.ms/aadds-neterr"), + // Severity: to.Ptr("2"), + // }}, + // HealthLastEvaluated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2018-02-15T21:43:21Z"); return t}()), + // HealthMonitors: []*armdomainservices.HealthMonitor{ + // { + // Name: to.Ptr("Backup"), + // ID: to.Ptr("AADDS501"), + // Details: to.Ptr("Last backed up on Tue, 18 Sep 2018 03:37:04 GMT"), + // }, + // { + // Name: to.Ptr("Synchronization with Azure AD"), + // ID: to.Ptr("AADDS500"), + // Details: to.Ptr("Synchronized on Tue, 18 Sep 2018 16:47:57 GMT."), + // }}, + // Location: to.Ptr("West US"), + // ReplicaSetID: to.Ptr("4a619871-0150-41c4-aeb4-0b10deb7940a"), + // ServiceStatus: to.Ptr("Running"), + // SubnetID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS"), + // VnetSiteID: to.Ptr("99083198-a39c-469f-972d-59017e7f078c"), + // }}, + // SyncOwner: to.Ptr("4a619871-0150-41c4-aeb4-0b10deb7940a"), + // TenantID: to.Ptr("3f8cd22c-7b32-48aa-a01c-f533133b1def"), + // Version: to.Ptr[int32](2), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/DeleteDomainService.json +func ExampleClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdomainservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewClient().BeginDelete(ctx, "TestResourceGroup", "TestDomainService.com", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/UpdateDomainService.json +func ExampleClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdomainservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewClient().BeginUpdate(ctx, "TestResourceGroup", "TestDomainService.com", armdomainservices.DomainService{ + Properties: &armdomainservices.DomainServiceProperties{ + ConfigDiagnostics: &armdomainservices.ConfigDiagnostics{ + LastExecuted: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2021-05-05T12:00:23Z;"); return t }()), + ValidatorResults: []*armdomainservices.ConfigDiagnosticsValidatorResult{ + { + Issues: []*armdomainservices.ConfigDiagnosticsValidatorResultIssue{ + { + DescriptionParams: []*string{}, + ID: to.Ptr("AADDS-CFG-DIAG-I20"), + }}, + ReplicaSetSubnetDisplayName: to.Ptr("West US/aadds-subnet"), + Status: to.Ptr(armdomainservices.StatusWarning), + ValidatorID: to.Ptr("AADDS-CFG-DIAG-V06"), + }}, + }, + DomainSecuritySettings: &armdomainservices.DomainSecuritySettings{ + NtlmV1: to.Ptr(armdomainservices.NtlmV1Enabled), + SyncNtlmPasswords: to.Ptr(armdomainservices.SyncNtlmPasswordsEnabled), + TLSV1: to.Ptr(armdomainservices.TLSV1Disabled), + }, + FilteredSync: to.Ptr(armdomainservices.FilteredSyncEnabled), + LdapsSettings: &armdomainservices.LdapsSettings{ + ExternalAccess: to.Ptr(armdomainservices.ExternalAccessEnabled), + Ldaps: to.Ptr(armdomainservices.LdapsEnabled), + PfxCertificate: to.Ptr("MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w..."), + PfxCertificatePassword: to.Ptr(""), + }, + NotificationSettings: &armdomainservices.NotificationSettings{ + AdditionalRecipients: []*string{ + to.Ptr("jicha@microsoft.com"), + to.Ptr("caalmont@microsoft.com")}, + NotifyDcAdmins: to.Ptr(armdomainservices.NotifyDcAdminsEnabled), + NotifyGlobalAdmins: to.Ptr(armdomainservices.NotifyGlobalAdminsEnabled), + }, + ReplicaSets: []*armdomainservices.ReplicaSet{ + { + Location: to.Ptr("West US"), + SubnetID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS"), + }, + { + Location: to.Ptr("East US"), + SubnetID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetEUS/subnets/TestSubnetEUS"), + }}, + }, + }, 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.DomainService = armdomainservices.DomainService{ + // Name: to.Ptr("TestDomainService.com"), + // Type: to.Ptr("Microsoft.AAD/DomainServices"), + // ID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestResourceGroup/providers/Microsoft.AAD/DomainServices/TestDomainService.com"), + // Properties: &armdomainservices.DomainServiceProperties{ + // DeploymentID: to.Ptr("4a619871-0150-41c4-aeb4-0b10deb7940a"), + // DomainName: to.Ptr("TestDomainService.com"), + // DomainSecuritySettings: &armdomainservices.DomainSecuritySettings{ + // NtlmV1: to.Ptr(armdomainservices.NtlmV1Enabled), + // SyncNtlmPasswords: to.Ptr(armdomainservices.SyncNtlmPasswordsEnabled), + // TLSV1: to.Ptr(armdomainservices.TLSV1Disabled), + // }, + // FilteredSync: to.Ptr(armdomainservices.FilteredSyncEnabled), + // LdapsSettings: &armdomainservices.LdapsSettings{ + // CertificateNotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-15T21:43:21Z"); return t}()), + // CertificateThumbprint: to.Ptr("9154A390F0C387D679E0DD040701745CDFED67F3"), + // ExternalAccess: to.Ptr(armdomainservices.ExternalAccessEnabled), + // Ldaps: to.Ptr(armdomainservices.LdapsEnabled), + // PublicCertificate: to.Ptr("MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w..."), + // }, + // NotificationSettings: &armdomainservices.NotificationSettings{ + // AdditionalRecipients: []*string{ + // to.Ptr("jicha@microsoft.com"), + // to.Ptr("caalmont@microsoft.com")}, + // NotifyDcAdmins: to.Ptr(armdomainservices.NotifyDcAdminsEnabled), + // NotifyGlobalAdmins: to.Ptr(armdomainservices.NotifyGlobalAdminsEnabled), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ReplicaSets: []*armdomainservices.ReplicaSet{ + // { + // DomainControllerIPAddress: []*string{ + // to.Ptr("10.0.0.1"), + // to.Ptr("10.0.0.2")}, + // ExternalAccessIPAddress: to.Ptr("13.64.148.151"), + // Location: to.Ptr("West US"), + // ReplicaSetID: to.Ptr("4a619871-0150-41c4-aeb4-0b10deb7940a"), + // ServiceStatus: to.Ptr("Running"), + // SubnetID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS"), + // VnetSiteID: to.Ptr("99083198-a39c-469f-972d-59017e7f078c"), + // }, + // { + // DomainControllerIPAddress: []*string{ + // to.Ptr("10.0.0.3"), + // to.Ptr("10.0.0.4")}, + // ExternalAccessIPAddress: to.Ptr("13.64.148.152"), + // Location: to.Ptr("East US"), + // ReplicaSetID: to.Ptr("5057347d-cad1-4ec8-8db6-66cf7eedf4b8"), + // ServiceStatus: to.Ptr("Running"), + // SubnetID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetEUS/subnets/TestSubnetEUS"), + // }}, + // SyncOwner: to.Ptr("4a619871-0150-41c4-aeb4-0b10deb7940a"), + // TenantID: to.Ptr("3f8cd22c-7b32-48aa-a01c-f533133b1def"), + // Version: to.Ptr[int32](2), + // }, + // } +} diff --git a/sdk/resourcemanager/domainservices/armdomainservices/client_factory.go b/sdk/resourcemanager/domainservices/armdomainservices/client_factory.go new file mode 100644 index 000000000000..ed68faa1aed7 --- /dev/null +++ b/sdk/resourcemanager/domainservices/armdomainservices/client_factory.go @@ -0,0 +1,60 @@ +//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 armdomainservices + +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 the 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) NewDomainServiceOperationsClient() *DomainServiceOperationsClient { + subClient, _ := NewDomainServiceOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewClient() *Client { + subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOuContainerOperationsClient() *OuContainerOperationsClient { + subClient, _ := NewOuContainerOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOuContainerClient() *OuContainerClient { + subClient, _ := NewOuContainerClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_constants.go b/sdk/resourcemanager/domainservices/armdomainservices/constants.go similarity index 99% rename from sdk/resourcemanager/domainservices/armdomainservices/zz_generated_constants.go rename to sdk/resourcemanager/domainservices/armdomainservices/constants.go index 8e8fdcafd545..60126e7d5af5 100644 --- a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_constants.go +++ b/sdk/resourcemanager/domainservices/armdomainservices/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 armdomainservices const ( moduleName = "armdomainservices" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_domainserviceoperations_client.go b/sdk/resourcemanager/domainservices/armdomainservices/domainserviceoperations_client.go similarity index 78% rename from sdk/resourcemanager/domainservices/armdomainservices/zz_generated_domainserviceoperations_client.go rename to sdk/resourcemanager/domainservices/armdomainservices/domainserviceoperations_client.go index 1cbd9fba7031..bd8228e11378 100644 --- a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_domainserviceoperations_client.go +++ b/sdk/resourcemanager/domainservices/armdomainservices/domainserviceoperations_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 armdomainservices @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,37 +21,28 @@ import ( // DomainServiceOperationsClient contains the methods for the DomainServiceOperations group. // Don't use this type directly, use NewDomainServiceOperationsClient() instead. type DomainServiceOperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewDomainServiceOperationsClient creates a new instance of DomainServiceOperationsClient 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 NewDomainServiceOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*DomainServiceOperationsClient, 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+".DomainServiceOperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DomainServiceOperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists all the available Domain Services operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// options - DomainServiceOperationsClientListOptions contains the optional parameters for the DomainServiceOperationsClient.List -// method. +// - options - DomainServiceOperationsClientListOptions contains the optional parameters for the DomainServiceOperationsClient.NewListPager +// method. func (client *DomainServiceOperationsClient) NewListPager(options *DomainServiceOperationsClientListOptions) *runtime.Pager[DomainServiceOperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[DomainServiceOperationsClientListResponse]{ More: func(page DomainServiceOperationsClientListResponse) bool { @@ -69,7 +59,7 @@ func (client *DomainServiceOperationsClient) NewListPager(options *DomainService if err != nil { return DomainServiceOperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DomainServiceOperationsClientListResponse{}, err } @@ -84,7 +74,7 @@ func (client *DomainServiceOperationsClient) NewListPager(options *DomainService // listCreateRequest creates the List request. func (client *DomainServiceOperationsClient) listCreateRequest(ctx context.Context, options *DomainServiceOperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.AAD/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/domainservices/armdomainservices/domainserviceoperations_client_example_test.go b/sdk/resourcemanager/domainservices/armdomainservices/domainserviceoperations_client_example_test.go new file mode 100644 index 000000000000..f9d397d4b64a --- /dev/null +++ b/sdk/resourcemanager/domainservices/armdomainservices/domainserviceoperations_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 armdomainservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/domainservices/armdomainservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOperations.json +func ExampleDomainServiceOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdomainservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDomainServiceOperationsClient().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.OperationEntityListResult = armdomainservices.OperationEntityListResult{ + // Value: []*armdomainservices.OperationEntity{ + // { + // Name: to.Ptr("Microsoft.AAD/unregister/action"), + // Display: &armdomainservices.OperationDisplayInfo{ + // Description: to.Ptr("Unregisters Domain Services"), + // Operation: to.Ptr("Unregister Domain Service"), + // Provider: to.Ptr("Domain Services Resource Provider"), + // Resource: to.Ptr("Domain Service Type"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.AAD/register/action"), + // Display: &armdomainservices.OperationDisplayInfo{ + // Description: to.Ptr("Registers Domain Services"), + // Operation: to.Ptr("Register Domain Service"), + // Provider: to.Ptr("Domain Services Resource Provider"), + // Resource: to.Ptr("Domain Service Type"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.AAD/domainServices/read"), + // Display: &armdomainservices.OperationDisplayInfo{ + // Description: to.Ptr("Reads Domain Services"), + // Operation: to.Ptr("Read Domain Service"), + // Provider: to.Ptr("Domain Services Resource Provider"), + // Resource: to.Ptr("Domain Service Type"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.AAD/domainServices/write"), + // Display: &armdomainservices.OperationDisplayInfo{ + // Description: to.Ptr("Writes Domain Services"), + // Operation: to.Ptr("Write Domain Service"), + // Provider: to.Ptr("Domain Services Resource Provider"), + // Resource: to.Ptr("Domain Service Type"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.AAD/domainServices/delete"), + // Display: &armdomainservices.OperationDisplayInfo{ + // Description: to.Ptr("Deletes Domain Services"), + // Operation: to.Ptr("Delete Domain Service"), + // Provider: to.Ptr("Domain Services Resource Provider"), + // Resource: to.Ptr("Domain Service Type"), + // }, + // Origin: to.Ptr("user,system"), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/domainservices/armdomainservices/go.mod b/sdk/resourcemanager/domainservices/armdomainservices/go.mod index 00076e183366..fa049bf13ef7 100644 --- a/sdk/resourcemanager/domainservices/armdomainservices/go.mod +++ b/sdk/resourcemanager/domainservices/armdomainservices/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/domainservices/armd 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/domainservices/armdomainservices/go.sum b/sdk/resourcemanager/domainservices/armdomainservices/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/domainservices/armdomainservices/go.sum +++ b/sdk/resourcemanager/domainservices/armdomainservices/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/domainservices/armdomainservices/zz_generated_models.go b/sdk/resourcemanager/domainservices/armdomainservices/models.go similarity index 94% rename from sdk/resourcemanager/domainservices/armdomainservices/zz_generated_models.go rename to sdk/resourcemanager/domainservices/armdomainservices/models.go index 91fe0fc28efd..50663d6f8303 100644 --- a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_models.go +++ b/sdk/resourcemanager/domainservices/armdomainservices/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 armdomainservices @@ -33,37 +34,16 @@ type ClientGetOptions struct { // placeholder for future optional parameters } -// ClientListByResourceGroupOptions contains the optional parameters for the Client.ListByResourceGroup method. +// ClientListByResourceGroupOptions contains the optional parameters for the Client.NewListByResourceGroupPager method. type ClientListByResourceGroupOptions 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 } -// CloudError - An error response from the Domain Services. -type CloudError struct { - // An error response from the Domain Services. - Error *CloudErrorBody `json:"error,omitempty"` -} - -// CloudErrorBody - An error response from the Domain Services. -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"` -} - // ConfigDiagnostics - Configuration Diagnostics type ConfigDiagnostics struct { // Last domain configuration diagnostics DateTime @@ -169,7 +149,8 @@ type DomainServiceListResult struct { NextLink *string `json:"nextLink,omitempty" azure:"ro"` } -// DomainServiceOperationsClientListOptions contains the optional parameters for the DomainServiceOperationsClient.List method. +// DomainServiceOperationsClientListOptions contains the optional parameters for the DomainServiceOperationsClient.NewListPager +// method. type DomainServiceOperationsClientListOptions struct { // placeholder for future optional parameters } @@ -423,7 +404,7 @@ type OuContainerClientGetOptions struct { // placeholder for future optional parameters } -// OuContainerClientListOptions contains the optional parameters for the OuContainerClient.List method. +// OuContainerClientListOptions contains the optional parameters for the OuContainerClient.NewListPager method. type OuContainerClientListOptions struct { // placeholder for future optional parameters } @@ -437,7 +418,8 @@ type OuContainerListResult struct { NextLink *string `json:"nextLink,omitempty" azure:"ro"` } -// OuContainerOperationsClientListOptions contains the optional parameters for the OuContainerOperationsClient.List method. +// OuContainerOperationsClientListOptions contains the optional parameters for the OuContainerOperationsClient.NewListPager +// method. type OuContainerOperationsClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/domainservices/armdomainservices/models_serde.go b/sdk/resourcemanager/domainservices/armdomainservices/models_serde.go new file mode 100644 index 000000000000..5b9e790f7e71 --- /dev/null +++ b/sdk/resourcemanager/domainservices/armdomainservices/models_serde.go @@ -0,0 +1,1116 @@ +//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 armdomainservices + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ConfigDiagnostics. +func (c ConfigDiagnostics) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC1123(objectMap, "lastExecuted", c.LastExecuted) + populate(objectMap, "validatorResults", c.ValidatorResults) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigDiagnostics. +func (c *ConfigDiagnostics) UnmarshalJSON(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 "lastExecuted": + err = unpopulateTimeRFC1123(val, "LastExecuted", &c.LastExecuted) + delete(rawMsg, key) + case "validatorResults": + err = unpopulate(val, "ValidatorResults", &c.ValidatorResults) + 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 ConfigDiagnosticsValidatorResult. +func (c ConfigDiagnosticsValidatorResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "issues", c.Issues) + populate(objectMap, "replicaSetSubnetDisplayName", c.ReplicaSetSubnetDisplayName) + populate(objectMap, "status", c.Status) + populate(objectMap, "validatorId", c.ValidatorID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigDiagnosticsValidatorResult. +func (c *ConfigDiagnosticsValidatorResult) UnmarshalJSON(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 "issues": + err = unpopulate(val, "Issues", &c.Issues) + delete(rawMsg, key) + case "replicaSetSubnetDisplayName": + err = unpopulate(val, "ReplicaSetSubnetDisplayName", &c.ReplicaSetSubnetDisplayName) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &c.Status) + delete(rawMsg, key) + case "validatorId": + err = unpopulate(val, "ValidatorID", &c.ValidatorID) + 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 ConfigDiagnosticsValidatorResultIssue. +func (c ConfigDiagnosticsValidatorResultIssue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "descriptionParams", c.DescriptionParams) + populate(objectMap, "id", c.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigDiagnosticsValidatorResultIssue. +func (c *ConfigDiagnosticsValidatorResultIssue) UnmarshalJSON(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 "descriptionParams": + err = unpopulate(val, "DescriptionParams", &c.DescriptionParams) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + 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 ContainerAccount. +func (c ContainerAccount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountName", c.AccountName) + populate(objectMap, "password", c.Password) + populate(objectMap, "spn", c.Spn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerAccount. +func (c *ContainerAccount) UnmarshalJSON(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 "accountName": + err = unpopulate(val, "AccountName", &c.AccountName) + delete(rawMsg, key) + case "password": + err = unpopulate(val, "Password", &c.Password) + delete(rawMsg, key) + case "spn": + err = unpopulate(val, "Spn", &c.Spn) + 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 DomainSecuritySettings. +func (d DomainSecuritySettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kerberosArmoring", d.KerberosArmoring) + populate(objectMap, "kerberosRc4Encryption", d.KerberosRc4Encryption) + populate(objectMap, "ntlmV1", d.NtlmV1) + populate(objectMap, "syncKerberosPasswords", d.SyncKerberosPasswords) + populate(objectMap, "syncNtlmPasswords", d.SyncNtlmPasswords) + populate(objectMap, "syncOnPremPasswords", d.SyncOnPremPasswords) + populate(objectMap, "tlsV1", d.TLSV1) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DomainSecuritySettings. +func (d *DomainSecuritySettings) UnmarshalJSON(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 "kerberosArmoring": + err = unpopulate(val, "KerberosArmoring", &d.KerberosArmoring) + delete(rawMsg, key) + case "kerberosRc4Encryption": + err = unpopulate(val, "KerberosRc4Encryption", &d.KerberosRc4Encryption) + delete(rawMsg, key) + case "ntlmV1": + err = unpopulate(val, "NtlmV1", &d.NtlmV1) + delete(rawMsg, key) + case "syncKerberosPasswords": + err = unpopulate(val, "SyncKerberosPasswords", &d.SyncKerberosPasswords) + delete(rawMsg, key) + case "syncNtlmPasswords": + err = unpopulate(val, "SyncNtlmPasswords", &d.SyncNtlmPasswords) + delete(rawMsg, key) + case "syncOnPremPasswords": + err = unpopulate(val, "SyncOnPremPasswords", &d.SyncOnPremPasswords) + delete(rawMsg, key) + case "tlsV1": + err = unpopulate(val, "TLSV1", &d.TLSV1) + 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 DomainService. +func (d DomainService) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", d.Etag) + populate(objectMap, "id", d.ID) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DomainService. +func (d *DomainService) UnmarshalJSON(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 "etag": + err = unpopulate(val, "Etag", &d.Etag) + delete(rawMsg, 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 "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + 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 DomainServiceListResult. +func (d DomainServiceListResult) 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 DomainServiceListResult. +func (d *DomainServiceListResult) UnmarshalJSON(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 DomainServiceProperties. +func (d DomainServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "configDiagnostics", d.ConfigDiagnostics) + populate(objectMap, "deploymentId", d.DeploymentID) + populate(objectMap, "domainConfigurationType", d.DomainConfigurationType) + populate(objectMap, "domainName", d.DomainName) + populate(objectMap, "domainSecuritySettings", d.DomainSecuritySettings) + populate(objectMap, "filteredSync", d.FilteredSync) + populate(objectMap, "ldapsSettings", d.LdapsSettings) + populate(objectMap, "migrationProperties", d.MigrationProperties) + populate(objectMap, "notificationSettings", d.NotificationSettings) + populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "replicaSets", d.ReplicaSets) + populate(objectMap, "resourceForestSettings", d.ResourceForestSettings) + populate(objectMap, "sku", d.SKU) + populate(objectMap, "syncOwner", d.SyncOwner) + populate(objectMap, "tenantId", d.TenantID) + populate(objectMap, "version", d.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DomainServiceProperties. +func (d *DomainServiceProperties) UnmarshalJSON(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 "configDiagnostics": + err = unpopulate(val, "ConfigDiagnostics", &d.ConfigDiagnostics) + delete(rawMsg, key) + case "deploymentId": + err = unpopulate(val, "DeploymentID", &d.DeploymentID) + delete(rawMsg, key) + case "domainConfigurationType": + err = unpopulate(val, "DomainConfigurationType", &d.DomainConfigurationType) + delete(rawMsg, key) + case "domainName": + err = unpopulate(val, "DomainName", &d.DomainName) + delete(rawMsg, key) + case "domainSecuritySettings": + err = unpopulate(val, "DomainSecuritySettings", &d.DomainSecuritySettings) + delete(rawMsg, key) + case "filteredSync": + err = unpopulate(val, "FilteredSync", &d.FilteredSync) + delete(rawMsg, key) + case "ldapsSettings": + err = unpopulate(val, "LdapsSettings", &d.LdapsSettings) + delete(rawMsg, key) + case "migrationProperties": + err = unpopulate(val, "MigrationProperties", &d.MigrationProperties) + delete(rawMsg, key) + case "notificationSettings": + err = unpopulate(val, "NotificationSettings", &d.NotificationSettings) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + case "replicaSets": + err = unpopulate(val, "ReplicaSets", &d.ReplicaSets) + delete(rawMsg, key) + case "resourceForestSettings": + err = unpopulate(val, "ResourceForestSettings", &d.ResourceForestSettings) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &d.SKU) + delete(rawMsg, key) + case "syncOwner": + err = unpopulate(val, "SyncOwner", &d.SyncOwner) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &d.TenantID) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &d.Version) + 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 ForestTrust. +func (f ForestTrust) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "friendlyName", f.FriendlyName) + populate(objectMap, "remoteDnsIps", f.RemoteDNSIPs) + populate(objectMap, "trustDirection", f.TrustDirection) + populate(objectMap, "trustPassword", f.TrustPassword) + populate(objectMap, "trustedDomainFqdn", f.TrustedDomainFqdn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ForestTrust. +func (f *ForestTrust) UnmarshalJSON(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 "friendlyName": + err = unpopulate(val, "FriendlyName", &f.FriendlyName) + delete(rawMsg, key) + case "remoteDnsIps": + err = unpopulate(val, "RemoteDNSIPs", &f.RemoteDNSIPs) + delete(rawMsg, key) + case "trustDirection": + err = unpopulate(val, "TrustDirection", &f.TrustDirection) + delete(rawMsg, key) + case "trustPassword": + err = unpopulate(val, "TrustPassword", &f.TrustPassword) + delete(rawMsg, key) + case "trustedDomainFqdn": + err = unpopulate(val, "TrustedDomainFqdn", &f.TrustedDomainFqdn) + 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 HealthAlert. +func (h HealthAlert) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", h.ID) + populate(objectMap, "issue", h.Issue) + populateTimeRFC3339(objectMap, "lastDetected", h.LastDetected) + populate(objectMap, "name", h.Name) + populateTimeRFC3339(objectMap, "raised", h.Raised) + populate(objectMap, "resolutionUri", h.ResolutionURI) + populate(objectMap, "severity", h.Severity) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthAlert. +func (h *HealthAlert) UnmarshalJSON(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 "id": + err = unpopulate(val, "ID", &h.ID) + delete(rawMsg, key) + case "issue": + err = unpopulate(val, "Issue", &h.Issue) + delete(rawMsg, key) + case "lastDetected": + err = unpopulateTimeRFC3339(val, "LastDetected", &h.LastDetected) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &h.Name) + delete(rawMsg, key) + case "raised": + err = unpopulateTimeRFC3339(val, "Raised", &h.Raised) + delete(rawMsg, key) + case "resolutionUri": + err = unpopulate(val, "ResolutionURI", &h.ResolutionURI) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, "Severity", &h.Severity) + 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 HealthMonitor. +func (h HealthMonitor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "details", h.Details) + populate(objectMap, "id", h.ID) + populate(objectMap, "name", h.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthMonitor. +func (h *HealthMonitor) UnmarshalJSON(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 "details": + err = unpopulate(val, "Details", &h.Details) + 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) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LdapsSettings. +func (l LdapsSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "certificateNotAfter", l.CertificateNotAfter) + populate(objectMap, "certificateThumbprint", l.CertificateThumbprint) + populate(objectMap, "externalAccess", l.ExternalAccess) + populate(objectMap, "ldaps", l.Ldaps) + populate(objectMap, "pfxCertificate", l.PfxCertificate) + populate(objectMap, "pfxCertificatePassword", l.PfxCertificatePassword) + populate(objectMap, "publicCertificate", l.PublicCertificate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LdapsSettings. +func (l *LdapsSettings) UnmarshalJSON(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 "certificateNotAfter": + err = unpopulateTimeRFC3339(val, "CertificateNotAfter", &l.CertificateNotAfter) + delete(rawMsg, key) + case "certificateThumbprint": + err = unpopulate(val, "CertificateThumbprint", &l.CertificateThumbprint) + delete(rawMsg, key) + case "externalAccess": + err = unpopulate(val, "ExternalAccess", &l.ExternalAccess) + delete(rawMsg, key) + case "ldaps": + err = unpopulate(val, "Ldaps", &l.Ldaps) + delete(rawMsg, key) + case "pfxCertificate": + err = unpopulate(val, "PfxCertificate", &l.PfxCertificate) + delete(rawMsg, key) + case "pfxCertificatePassword": + err = unpopulate(val, "PfxCertificatePassword", &l.PfxCertificatePassword) + delete(rawMsg, key) + case "publicCertificate": + err = unpopulate(val, "PublicCertificate", &l.PublicCertificate) + 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 MigrationProgress. +func (m MigrationProgress) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "completionPercentage", m.CompletionPercentage) + populate(objectMap, "progressMessage", m.ProgressMessage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MigrationProgress. +func (m *MigrationProgress) UnmarshalJSON(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 "completionPercentage": + err = unpopulate(val, "CompletionPercentage", &m.CompletionPercentage) + delete(rawMsg, key) + case "progressMessage": + err = unpopulate(val, "ProgressMessage", &m.ProgressMessage) + 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 MigrationProperties. +func (m MigrationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "migrationProgress", m.MigrationProgress) + populate(objectMap, "oldSubnetId", m.OldSubnetID) + populate(objectMap, "oldVnetSiteId", m.OldVnetSiteID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MigrationProperties. +func (m *MigrationProperties) UnmarshalJSON(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 "migrationProgress": + err = unpopulate(val, "MigrationProgress", &m.MigrationProgress) + delete(rawMsg, key) + case "oldSubnetId": + err = unpopulate(val, "OldSubnetID", &m.OldSubnetID) + delete(rawMsg, key) + case "oldVnetSiteId": + err = unpopulate(val, "OldVnetSiteID", &m.OldVnetSiteID) + 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 NotificationSettings. +func (n NotificationSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalRecipients", n.AdditionalRecipients) + populate(objectMap, "notifyDcAdmins", n.NotifyDcAdmins) + populate(objectMap, "notifyGlobalAdmins", n.NotifyGlobalAdmins) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NotificationSettings. +func (n *NotificationSettings) UnmarshalJSON(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 "additionalRecipients": + err = unpopulate(val, "AdditionalRecipients", &n.AdditionalRecipients) + delete(rawMsg, key) + case "notifyDcAdmins": + err = unpopulate(val, "NotifyDcAdmins", &n.NotifyDcAdmins) + delete(rawMsg, key) + case "notifyGlobalAdmins": + err = unpopulate(val, "NotifyGlobalAdmins", &n.NotifyGlobalAdmins) + 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 OperationDisplayInfo. +func (o OperationDisplayInfo) 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 OperationDisplayInfo. +func (o *OperationDisplayInfo) UnmarshalJSON(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 OperationEntity. +func (o OperationEntity) 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 OperationEntity. +func (o *OperationEntity) UnmarshalJSON(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 OperationEntityListResult. +func (o OperationEntityListResult) 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 OperationEntityListResult. +func (o *OperationEntityListResult) UnmarshalJSON(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 OuContainer. +func (o OuContainer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", o.Etag) + populate(objectMap, "id", o.ID) + populate(objectMap, "location", o.Location) + populate(objectMap, "name", o.Name) + populate(objectMap, "properties", o.Properties) + 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 OuContainer. +func (o *OuContainer) UnmarshalJSON(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 "etag": + err = unpopulate(val, "Etag", &o.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &o.ID) + 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 "properties": + err = unpopulate(val, "Properties", &o.Properties) + 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 OuContainerListResult. +func (o OuContainerListResult) 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 OuContainerListResult. +func (o *OuContainerListResult) UnmarshalJSON(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 OuContainerProperties. +func (o OuContainerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accounts", o.Accounts) + populate(objectMap, "containerId", o.ContainerID) + populate(objectMap, "deploymentId", o.DeploymentID) + populate(objectMap, "distinguishedName", o.DistinguishedName) + populate(objectMap, "domainName", o.DomainName) + populate(objectMap, "provisioningState", o.ProvisioningState) + populate(objectMap, "serviceStatus", o.ServiceStatus) + populate(objectMap, "tenantId", o.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OuContainerProperties. +func (o *OuContainerProperties) UnmarshalJSON(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 "accounts": + err = unpopulate(val, "Accounts", &o.Accounts) + delete(rawMsg, key) + case "containerId": + err = unpopulate(val, "ContainerID", &o.ContainerID) + delete(rawMsg, key) + case "deploymentId": + err = unpopulate(val, "DeploymentID", &o.DeploymentID) + delete(rawMsg, key) + case "distinguishedName": + err = unpopulate(val, "DistinguishedName", &o.DistinguishedName) + delete(rawMsg, key) + case "domainName": + err = unpopulate(val, "DomainName", &o.DomainName) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &o.ProvisioningState) + delete(rawMsg, key) + case "serviceStatus": + err = unpopulate(val, "ServiceStatus", &o.ServiceStatus) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &o.TenantID) + 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 ReplicaSet. +func (r ReplicaSet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "domainControllerIpAddress", r.DomainControllerIPAddress) + populate(objectMap, "externalAccessIpAddress", r.ExternalAccessIPAddress) + populate(objectMap, "healthAlerts", r.HealthAlerts) + populateTimeRFC1123(objectMap, "healthLastEvaluated", r.HealthLastEvaluated) + populate(objectMap, "healthMonitors", r.HealthMonitors) + populate(objectMap, "location", r.Location) + populate(objectMap, "replicaSetId", r.ReplicaSetID) + populate(objectMap, "serviceStatus", r.ServiceStatus) + populate(objectMap, "subnetId", r.SubnetID) + populate(objectMap, "vnetSiteId", r.VnetSiteID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReplicaSet. +func (r *ReplicaSet) UnmarshalJSON(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 "domainControllerIpAddress": + err = unpopulate(val, "DomainControllerIPAddress", &r.DomainControllerIPAddress) + delete(rawMsg, key) + case "externalAccessIpAddress": + err = unpopulate(val, "ExternalAccessIPAddress", &r.ExternalAccessIPAddress) + delete(rawMsg, key) + case "healthAlerts": + err = unpopulate(val, "HealthAlerts", &r.HealthAlerts) + delete(rawMsg, key) + case "healthLastEvaluated": + err = unpopulateTimeRFC1123(val, "HealthLastEvaluated", &r.HealthLastEvaluated) + delete(rawMsg, key) + case "healthMonitors": + err = unpopulate(val, "HealthMonitors", &r.HealthMonitors) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "replicaSetId": + err = unpopulate(val, "ReplicaSetID", &r.ReplicaSetID) + delete(rawMsg, key) + case "serviceStatus": + err = unpopulate(val, "ServiceStatus", &r.ServiceStatus) + delete(rawMsg, key) + case "subnetId": + err = unpopulate(val, "SubnetID", &r.SubnetID) + delete(rawMsg, key) + case "vnetSiteId": + err = unpopulate(val, "VnetSiteID", &r.VnetSiteID) + 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, "etag", r.Etag) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + 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 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 "etag": + err = unpopulate(val, "Etag", &r.Etag) + delete(rawMsg, 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 "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 ResourceForestSettings. +func (r ResourceForestSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceForest", r.ResourceForest) + populate(objectMap, "settings", r.Settings) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceForestSettings. +func (r *ResourceForestSettings) UnmarshalJSON(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 "resourceForest": + err = unpopulate(val, "ResourceForest", &r.ResourceForest) + delete(rawMsg, key) + case "settings": + err = unpopulate(val, "Settings", &r.Settings) + 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/domainservices/armdomainservices/zz_generated_oucontainer_client.go b/sdk/resourcemanager/domainservices/armdomainservices/oucontainer_client.go similarity index 83% rename from sdk/resourcemanager/domainservices/armdomainservices/zz_generated_oucontainer_client.go rename to sdk/resourcemanager/domainservices/armdomainservices/oucontainer_client.go index 0379859ad8c4..8a617ebedf28 100644 --- a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_oucontainer_client.go +++ b/sdk/resourcemanager/domainservices/armdomainservices/oucontainer_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 armdomainservices @@ -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 ( // OuContainerClient contains the methods for the OuContainer group. // Don't use this type directly, use NewOuContainerClient() instead. type OuContainerClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewOuContainerClient creates a new instance of OuContainerClient with the specified values. -// subscriptionID - Gets subscription credentials which uniquely identify the 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 the 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 NewOuContainerClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OuContainerClient, 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+".OuContainerClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OuContainerClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - The Create OuContainer operation creates a new OuContainer under the specified Domain Service instance. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// domainServiceName - The name of the domain service. -// ouContainerName - The name of the OuContainer. -// containerAccount - Container Account Description. -// options - OuContainerClientBeginCreateOptions contains the optional parameters for the OuContainerClient.BeginCreate method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - domainServiceName - The name of the domain service. +// - ouContainerName - The name of the OuContainer. +// - containerAccount - Container Account Description. +// - options - OuContainerClientBeginCreateOptions contains the optional parameters for the OuContainerClient.BeginCreate method. func (client *OuContainerClient) BeginCreate(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string, containerAccount ContainerAccount, options *OuContainerClientBeginCreateOptions) (*runtime.Poller[OuContainerClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, domainServiceName, ouContainerName, containerAccount, options) if err != nil { return nil, err } - return runtime.NewPoller[OuContainerClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[OuContainerClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[OuContainerClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[OuContainerClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - The Create OuContainer operation creates a new OuContainer under the specified Domain Service instance. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *OuContainerClient) create(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string, containerAccount ContainerAccount, options *OuContainerClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, domainServiceName, ouContainerName, containerAccount, 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 *OuContainerClient) createCreateRequest(ctx context.Context, resour return nil, errors.New("parameter ouContainerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ouContainerName}", url.PathEscape(ouContainerName)) - 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 *OuContainerClient) createCreateRequest(ctx context.Context, resour // BeginDelete - The Delete OuContainer operation deletes specified OuContainer. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// domainServiceName - The name of the domain service. -// ouContainerName - The name of the OuContainer. -// options - OuContainerClientBeginDeleteOptions contains the optional parameters for the OuContainerClient.BeginDelete method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - domainServiceName - The name of the domain service. +// - ouContainerName - The name of the OuContainer. +// - options - OuContainerClientBeginDeleteOptions contains the optional parameters for the OuContainerClient.BeginDelete method. func (client *OuContainerClient) BeginDelete(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string, options *OuContainerClientBeginDeleteOptions) (*runtime.Poller[OuContainerClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, domainServiceName, ouContainerName, options) if err != nil { return nil, err } - return runtime.NewPoller[OuContainerClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[OuContainerClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[OuContainerClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[OuContainerClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - The Delete OuContainer operation deletes specified OuContainer. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *OuContainerClient) deleteOperation(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string, options *OuContainerClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, domainServiceName, ouContainerName, 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 *OuContainerClient) deleteCreateRequest(ctx context.Context, resour return nil, errors.New("parameter ouContainerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ouContainerName}", url.PathEscape(ouContainerName)) - 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 *OuContainerClient) deleteCreateRequest(ctx context.Context, resour // Get - Get OuContainer in DomainService instance. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// domainServiceName - The name of the domain service. -// ouContainerName - The name of the OuContainer. -// options - OuContainerClientGetOptions contains the optional parameters for the OuContainerClient.Get method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - domainServiceName - The name of the domain service. +// - ouContainerName - The name of the OuContainer. +// - options - OuContainerClientGetOptions contains the optional parameters for the OuContainerClient.Get method. func (client *OuContainerClient) Get(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string, options *OuContainerClientGetOptions) (OuContainerClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, domainServiceName, ouContainerName, options) if err != nil { return OuContainerClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OuContainerClientGetResponse{}, err } @@ -231,7 +226,7 @@ func (client *OuContainerClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter ouContainerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ouContainerName}", url.PathEscape(ouContainerName)) - 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 *OuContainerClient) getHandleResponse(resp *http.Response) (OuConta } // NewListPager - The List of OuContainers in DomainService instance. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// domainServiceName - The name of the domain service. -// options - OuContainerClientListOptions contains the optional parameters for the OuContainerClient.List method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - domainServiceName - The name of the domain service. +// - options - OuContainerClientListOptions contains the optional parameters for the OuContainerClient.NewListPager method. func (client *OuContainerClient) NewListPager(resourceGroupName string, domainServiceName string, options *OuContainerClientListOptions) *runtime.Pager[OuContainerClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OuContainerClientListResponse]{ More: func(page OuContainerClientListResponse) bool { @@ -273,7 +268,7 @@ func (client *OuContainerClient) NewListPager(resourceGroupName string, domainSe if err != nil { return OuContainerClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OuContainerClientListResponse{}, err } @@ -300,7 +295,7 @@ func (client *OuContainerClient) listCreateRequest(ctx context.Context, resource return nil, errors.New("parameter domainServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{domainServiceName}", url.PathEscape(domainServiceName)) - 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 *OuContainerClient) listHandleResponse(resp *http.Response) (OuCont // BeginUpdate - The Update OuContainer operation can be used to update the existing OuContainers. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// domainServiceName - The name of the domain service. -// ouContainerName - The name of the OuContainer. -// containerAccount - Container Account Description. -// options - OuContainerClientBeginUpdateOptions contains the optional parameters for the OuContainerClient.BeginUpdate method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - domainServiceName - The name of the domain service. +// - ouContainerName - The name of the OuContainer. +// - containerAccount - Container Account Description. +// - options - OuContainerClientBeginUpdateOptions contains the optional parameters for the OuContainerClient.BeginUpdate method. func (client *OuContainerClient) BeginUpdate(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string, containerAccount ContainerAccount, options *OuContainerClientBeginUpdateOptions) (*runtime.Poller[OuContainerClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, domainServiceName, ouContainerName, containerAccount, options) if err != nil { return nil, err } - return runtime.NewPoller[OuContainerClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[OuContainerClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[OuContainerClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[OuContainerClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - The Update OuContainer operation can be used to update the existing OuContainers. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 func (client *OuContainerClient) update(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string, containerAccount ContainerAccount, options *OuContainerClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, domainServiceName, ouContainerName, containerAccount, 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 *OuContainerClient) updateCreateRequest(ctx context.Context, resour return nil, errors.New("parameter ouContainerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ouContainerName}", url.PathEscape(ouContainerName)) - 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/domainservices/armdomainservices/oucontainer_client_example_test.go b/sdk/resourcemanager/domainservices/armdomainservices/oucontainer_client_example_test.go new file mode 100644 index 000000000000..63c7c58c0a60 --- /dev/null +++ b/sdk/resourcemanager/domainservices/armdomainservices/oucontainer_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 armdomainservices_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/domainservices/armdomainservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListOuContainers.json +func ExampleOuContainerClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdomainservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOuContainerClient().NewListPager("OuContainerResourceGroup", "OuContainer.com", 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.OuContainerListResult = armdomainservices.OuContainerListResult{ + // Value: []*armdomainservices.OuContainer{ + // { + // Name: to.Ptr("OuContainer.com/OuContainer1"), + // Type: to.Ptr("Microsoft.AAD/DomainServices/OuContainer"), + // ID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/ouContainerResourceGroup/providers/Microsoft.AAD/domainServices/ouContainer.com/ouContainer/ouContainer1"), + // Properties: &armdomainservices.OuContainerProperties{ + // Accounts: []*armdomainservices.ContainerAccount{ + // { + // AccountName: to.Ptr("AccountName1"), + // Spn: to.Ptr("Spn1"), + // }, + // { + // AccountName: to.Ptr("AccountName2"), + // Spn: to.Ptr("Spn2"), + // }}, + // ContainerID: to.Ptr("OuContainer1"), + // DeploymentID: to.Ptr("0FC50BDB-AC45-48E4-BC92-F0651EA0687B"), + // DomainName: to.Ptr("OuContainer.com"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceStatus: to.Ptr("Running"), + // TenantID: to.Ptr("3f8cd22c-7b32-48aa-a01c-f533133b1def"), + // }, + // }, + // { + // Name: to.Ptr("OuContainer.com/OuContainer2"), + // Type: to.Ptr("Microsoft.AAD/DomainServices/OuContainer"), + // ID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/ouContainerResourceGroup/providers/Microsoft.AAD/domainServices/ouContainer.com/ouContainer/ouContainer2"), + // Properties: &armdomainservices.OuContainerProperties{ + // Accounts: []*armdomainservices.ContainerAccount{ + // { + // AccountName: to.Ptr("AccountName3"), + // Spn: to.Ptr("Spn3"), + // }, + // { + // AccountName: to.Ptr("AccountName4"), + // Spn: to.Ptr("Spn4"), + // }}, + // ContainerID: to.Ptr("OuContainer2"), + // DeploymentID: to.Ptr("0FC50BDB-AC45-48E4-BC92-F0651EA0687B"), + // DomainName: to.Ptr("OuContainer.com"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceStatus: to.Ptr("Running"), + // TenantID: to.Ptr("3f8cd22c-7b32-48aa-a01c-f533133b1def"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOuContainer.json +func ExampleOuContainerClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdomainservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewOuContainerClient().Get(ctx, "OuContainerResourceGroup", "OuContainer.com", "OuContainer1", 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.OuContainer = armdomainservices.OuContainer{ + // Name: to.Ptr("OuContainer.com/OuContainer1"), + // Type: to.Ptr("Microsoft.AAD/DomainServices/OuContainer"), + // ID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/ouContainerResourceGroup/providers/Microsoft.AAD/domainServices/ouContainer.com/ouContainer/ouContainer1"), + // Properties: &armdomainservices.OuContainerProperties{ + // Accounts: []*armdomainservices.ContainerAccount{ + // { + // AccountName: to.Ptr("AccountName1"), + // Spn: to.Ptr("Spn1"), + // }, + // { + // AccountName: to.Ptr("AccountName2"), + // Spn: to.Ptr("Spn2"), + // }}, + // ContainerID: to.Ptr("OuContainer1"), + // DeploymentID: to.Ptr("0FC50BDB-AC45-48E4-BC92-F0651EA0687B"), + // DomainName: to.Ptr("OuContainer.com"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceStatus: to.Ptr("Running"), + // TenantID: to.Ptr("3f8cd22c-7b32-48aa-a01c-f533133b1def"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/CreateOuContainer.json +func ExampleOuContainerClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdomainservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewOuContainerClient().BeginCreate(ctx, "OuContainerResourceGroup", "OuContainer.com", "OuContainer1", armdomainservices.ContainerAccount{ + AccountName: to.Ptr("AccountName1"), + Password: to.Ptr(""), + Spn: to.Ptr("Spn1"), + }, 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.OuContainer = armdomainservices.OuContainer{ + // Name: to.Ptr("OuContainer.com/OuContainer1"), + // Type: to.Ptr("Microsoft.AAD/DomainServices/OuContainer"), + // ID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/ouContainerResourceGroup/providers/Microsoft.AAD/domainServices/ouContainer.com/ouContainer/ouContainer1"), + // Properties: &armdomainservices.OuContainerProperties{ + // Accounts: []*armdomainservices.ContainerAccount{ + // { + // AccountName: to.Ptr("AccountName1"), + // Spn: to.Ptr("Spn1"), + // }, + // { + // AccountName: to.Ptr("AccountName2"), + // Spn: to.Ptr("Spn2"), + // }}, + // ContainerID: to.Ptr("OuContainer1"), + // DeploymentID: to.Ptr("0FC50BDB-AC45-48E4-BC92-F0651EA0687B"), + // DomainName: to.Ptr("OuContainer.com"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceStatus: to.Ptr("Running"), + // TenantID: to.Ptr("3f8cd22c-7b32-48aa-a01c-f533133b1def"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/DeleteOuContainer.json +func ExampleOuContainerClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdomainservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewOuContainerClient().BeginDelete(ctx, "OuContainerResourceGroup", "OuContainer.com", "OuContainer1", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/UpdateOuContainer.json +func ExampleOuContainerClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdomainservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewOuContainerClient().BeginUpdate(ctx, "OuContainerResourceGroup", "OuContainer.com", "OuContainer1", armdomainservices.ContainerAccount{ + AccountName: to.Ptr("AccountName1"), + Password: to.Ptr(""), + Spn: to.Ptr("Spn1"), + }, 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.OuContainer = armdomainservices.OuContainer{ + // Name: to.Ptr("OuContainer.com/OuContainer1"), + // Type: to.Ptr("Microsoft.AAD/DomainServices/OuContainer"), + // ID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/ouContainerResourceGroup/providers/Microsoft.AAD/domainServices/ouContainer.com/ouContainer/ouContainer1"), + // Properties: &armdomainservices.OuContainerProperties{ + // Accounts: []*armdomainservices.ContainerAccount{ + // { + // AccountName: to.Ptr("AccountName1"), + // Spn: to.Ptr("Spn1"), + // }, + // { + // AccountName: to.Ptr("AccountName2"), + // Spn: to.Ptr("Spn2"), + // }}, + // ContainerID: to.Ptr("OuContainer1"), + // DeploymentID: to.Ptr("0FC50BDB-AC45-48E4-BC92-F0651EA0687B"), + // DomainName: to.Ptr("OuContainer.com"), + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceStatus: to.Ptr("Running"), + // TenantID: to.Ptr("3f8cd22c-7b32-48aa-a01c-f533133b1def"), + // }, + // } +} diff --git a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_oucontaineroperations_client.go b/sdk/resourcemanager/domainservices/armdomainservices/oucontaineroperations_client.go similarity index 78% rename from sdk/resourcemanager/domainservices/armdomainservices/zz_generated_oucontaineroperations_client.go rename to sdk/resourcemanager/domainservices/armdomainservices/oucontaineroperations_client.go index d5c8eff15063..5b1095e2f07a 100644 --- a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_oucontaineroperations_client.go +++ b/sdk/resourcemanager/domainservices/armdomainservices/oucontaineroperations_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 armdomainservices @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,37 +21,28 @@ import ( // OuContainerOperationsClient contains the methods for the OuContainerOperations group. // Don't use this type directly, use NewOuContainerOperationsClient() instead. type OuContainerOperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOuContainerOperationsClient creates a new instance of OuContainerOperationsClient 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 NewOuContainerOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OuContainerOperationsClient, 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+".OuContainerOperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OuContainerOperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists all the available OuContainer operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01 -// options - OuContainerOperationsClientListOptions contains the optional parameters for the OuContainerOperationsClient.List -// method. +// - options - OuContainerOperationsClientListOptions contains the optional parameters for the OuContainerOperationsClient.NewListPager +// method. func (client *OuContainerOperationsClient) NewListPager(options *OuContainerOperationsClientListOptions) *runtime.Pager[OuContainerOperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OuContainerOperationsClientListResponse]{ More: func(page OuContainerOperationsClientListResponse) bool { @@ -69,7 +59,7 @@ func (client *OuContainerOperationsClient) NewListPager(options *OuContainerOper if err != nil { return OuContainerOperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OuContainerOperationsClientListResponse{}, err } @@ -84,7 +74,7 @@ func (client *OuContainerOperationsClient) NewListPager(options *OuContainerOper // listCreateRequest creates the List request. func (client *OuContainerOperationsClient) listCreateRequest(ctx context.Context, options *OuContainerOperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Aad/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/domainservices/armdomainservices/oucontaineroperations_client_example_test.go b/sdk/resourcemanager/domainservices/armdomainservices/oucontaineroperations_client_example_test.go new file mode 100644 index 000000000000..29cf9e3f7c0f --- /dev/null +++ b/sdk/resourcemanager/domainservices/armdomainservices/oucontaineroperations_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 armdomainservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/domainservices/armdomainservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOperations.json +func ExampleOuContainerOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdomainservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOuContainerOperationsClient().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.OperationEntityListResult = armdomainservices.OperationEntityListResult{ + // Value: []*armdomainservices.OperationEntity{ + // { + // Name: to.Ptr("Microsoft.AAD/unregister/action"), + // Display: &armdomainservices.OperationDisplayInfo{ + // Description: to.Ptr("Unregisters Domain Services"), + // Operation: to.Ptr("Unregister Domain Service"), + // Provider: to.Ptr("Domain Services Resource Provider"), + // Resource: to.Ptr("Domain Service Type"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.AAD/register/action"), + // Display: &armdomainservices.OperationDisplayInfo{ + // Description: to.Ptr("Registers Domain Services"), + // Operation: to.Ptr("Register Domain Service"), + // Provider: to.Ptr("Domain Services Resource Provider"), + // Resource: to.Ptr("Domain Service Type"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.AAD/domainServices/read"), + // Display: &armdomainservices.OperationDisplayInfo{ + // Description: to.Ptr("Reads Domain Services"), + // Operation: to.Ptr("Read Domain Service"), + // Provider: to.Ptr("Domain Services Resource Provider"), + // Resource: to.Ptr("Domain Service Type"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.AAD/domainServices/write"), + // Display: &armdomainservices.OperationDisplayInfo{ + // Description: to.Ptr("Writes Domain Services"), + // Operation: to.Ptr("Write Domain Service"), + // Provider: to.Ptr("Domain Services Resource Provider"), + // Resource: to.Ptr("Domain Service Type"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.AAD/domainServices/delete"), + // Display: &armdomainservices.OperationDisplayInfo{ + // Description: to.Ptr("Deletes Domain Services"), + // Operation: to.Ptr("Delete Domain Service"), + // Provider: to.Ptr("Domain Services Resource Provider"), + // Resource: to.Ptr("Domain Service Type"), + // }, + // Origin: to.Ptr("user,system"), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_response_types.go b/sdk/resourcemanager/domainservices/armdomainservices/response_types.go similarity index 82% rename from sdk/resourcemanager/domainservices/armdomainservices/zz_generated_response_types.go rename to sdk/resourcemanager/domainservices/armdomainservices/response_types.go index a744e92f80b8..0ed4b07125af 100644 --- a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_response_types.go +++ b/sdk/resourcemanager/domainservices/armdomainservices/response_types.go @@ -5,15 +5,16 @@ // Licensed under the MIT License. See License.txt in the project root for 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 armdomainservices -// ClientCreateOrUpdateResponse contains the response from method Client.CreateOrUpdate. +// ClientCreateOrUpdateResponse contains the response from method Client.BeginCreateOrUpdate. type ClientCreateOrUpdateResponse struct { DomainService } -// ClientDeleteResponse contains the response from method Client.Delete. +// ClientDeleteResponse contains the response from method Client.BeginDelete. type ClientDeleteResponse struct { // placeholder for future response values } @@ -23,32 +24,32 @@ type ClientGetResponse struct { DomainService } -// ClientListByResourceGroupResponse contains the response from method Client.ListByResourceGroup. +// ClientListByResourceGroupResponse contains the response from method Client.NewListByResourceGroupPager. type ClientListByResourceGroupResponse struct { DomainServiceListResult } -// ClientListResponse contains the response from method Client.List. +// ClientListResponse contains the response from method Client.NewListPager. type ClientListResponse struct { DomainServiceListResult } -// ClientUpdateResponse contains the response from method Client.Update. +// ClientUpdateResponse contains the response from method Client.BeginUpdate. type ClientUpdateResponse struct { DomainService } -// DomainServiceOperationsClientListResponse contains the response from method DomainServiceOperationsClient.List. +// DomainServiceOperationsClientListResponse contains the response from method DomainServiceOperationsClient.NewListPager. type DomainServiceOperationsClientListResponse struct { OperationEntityListResult } -// OuContainerClientCreateResponse contains the response from method OuContainerClient.Create. +// OuContainerClientCreateResponse contains the response from method OuContainerClient.BeginCreate. type OuContainerClientCreateResponse struct { OuContainer } -// OuContainerClientDeleteResponse contains the response from method OuContainerClient.Delete. +// OuContainerClientDeleteResponse contains the response from method OuContainerClient.BeginDelete. type OuContainerClientDeleteResponse struct { // placeholder for future response values } @@ -58,17 +59,17 @@ type OuContainerClientGetResponse struct { OuContainer } -// OuContainerClientListResponse contains the response from method OuContainerClient.List. +// OuContainerClientListResponse contains the response from method OuContainerClient.NewListPager. type OuContainerClientListResponse struct { OuContainerListResult } -// OuContainerClientUpdateResponse contains the response from method OuContainerClient.Update. +// OuContainerClientUpdateResponse contains the response from method OuContainerClient.BeginUpdate. type OuContainerClientUpdateResponse struct { OuContainer } -// OuContainerOperationsClientListResponse contains the response from method OuContainerOperationsClient.List. +// OuContainerOperationsClientListResponse contains the response from method OuContainerOperationsClient.NewListPager. type OuContainerOperationsClientListResponse struct { OperationEntityListResult } diff --git a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_time_rfc1123.go b/sdk/resourcemanager/domainservices/armdomainservices/time_rfc1123.go similarity index 94% rename from sdk/resourcemanager/domainservices/armdomainservices/zz_generated_time_rfc1123.go rename to sdk/resourcemanager/domainservices/armdomainservices/time_rfc1123.go index c28918d35436..110f9512c4a5 100644 --- a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_time_rfc1123.go +++ b/sdk/resourcemanager/domainservices/armdomainservices/time_rfc1123.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 armdomainservices @@ -45,7 +46,7 @@ func (t *timeRFC1123) UnmarshalText(data []byte) error { return err } -func populateTimeRFC1123(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC1123(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_time_rfc3339.go b/sdk/resourcemanager/domainservices/armdomainservices/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/domainservices/armdomainservices/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/domainservices/armdomainservices/time_rfc3339.go index 93b85abf930c..4f3a6dda8f65 100644 --- a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/domainservices/armdomainservices/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 armdomainservices @@ -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/domainservices/armdomainservices/ze_generated_example_domainserviceoperations_client_test.go b/sdk/resourcemanager/domainservices/armdomainservices/ze_generated_example_domainserviceoperations_client_test.go deleted file mode 100644 index 8456c93d92dd..000000000000 --- a/sdk/resourcemanager/domainservices/armdomainservices/ze_generated_example_domainserviceoperations_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 armdomainservices_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/domainservices/armdomainservices" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOperations.json -func ExampleDomainServiceOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdomainservices.NewDomainServiceOperationsClient(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/domainservices/armdomainservices/ze_generated_example_domainservices_client_test.go b/sdk/resourcemanager/domainservices/armdomainservices/ze_generated_example_domainservices_client_test.go deleted file mode 100644 index da443cd60368..000000000000 --- a/sdk/resourcemanager/domainservices/armdomainservices/ze_generated_example_domainservices_client_test.go +++ /dev/null @@ -1,242 +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 armdomainservices_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/domainservices/armdomainservices" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListDomainServicesBySubscription.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 := armdomainservices.NewClient("1639790a-76a2-4ac4-98d9-8562f5dfcb4d", 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/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListDomainServicesByResourceGroup.json -func ExampleClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdomainservices.NewClient("1639790a-76a2-4ac4-98d9-8562f5dfcb4d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("TestResourceGroup", - 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/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/CreateDomainService.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 := armdomainservices.NewClient("1639790a-76a2-4ac4-98d9-8562f5dfcb4d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "TestResourceGroup", - "TestDomainService.com", - armdomainservices.DomainService{ - Properties: &armdomainservices.DomainServiceProperties{ - DomainName: to.Ptr("TestDomainService.com"), - DomainSecuritySettings: &armdomainservices.DomainSecuritySettings{ - NtlmV1: to.Ptr(armdomainservices.NtlmV1Enabled), - SyncNtlmPasswords: to.Ptr(armdomainservices.SyncNtlmPasswordsEnabled), - TLSV1: to.Ptr(armdomainservices.TLSV1Disabled), - }, - FilteredSync: to.Ptr(armdomainservices.FilteredSyncEnabled), - LdapsSettings: &armdomainservices.LdapsSettings{ - ExternalAccess: to.Ptr(armdomainservices.ExternalAccessEnabled), - Ldaps: to.Ptr(armdomainservices.LdapsEnabled), - PfxCertificate: to.Ptr("MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w..."), - PfxCertificatePassword: to.Ptr(""), - }, - NotificationSettings: &armdomainservices.NotificationSettings{ - AdditionalRecipients: []*string{ - to.Ptr("jicha@microsoft.com"), - to.Ptr("caalmont@microsoft.com")}, - NotifyDcAdmins: to.Ptr(armdomainservices.NotifyDcAdminsEnabled), - NotifyGlobalAdmins: to.Ptr(armdomainservices.NotifyGlobalAdminsEnabled), - }, - ReplicaSets: []*armdomainservices.ReplicaSet{ - { - Location: to.Ptr("West US"), - SubnetID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS"), - }}, - }, - }, - 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/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetDomainService.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 := armdomainservices.NewClient("1639790a-76a2-4ac4-98d9-8562f5dfcb4d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "TestResourceGroup", - "TestDomainService.com", - 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/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/DeleteDomainService.json -func ExampleClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdomainservices.NewClient("1639790a-76a2-4ac4-98d9-8562f5dfcb4d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "TestResourceGroup", - "TestDomainService.com", - 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/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/UpdateDomainService.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 := armdomainservices.NewClient("1639790a-76a2-4ac4-98d9-8562f5dfcb4d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "TestResourceGroup", - "TestDomainService.com", - armdomainservices.DomainService{ - Properties: &armdomainservices.DomainServiceProperties{ - ConfigDiagnostics: &armdomainservices.ConfigDiagnostics{ - LastExecuted: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2021-05-05T12:00:23Z;"); return t }()), - ValidatorResults: []*armdomainservices.ConfigDiagnosticsValidatorResult{ - { - Issues: []*armdomainservices.ConfigDiagnosticsValidatorResultIssue{ - { - DescriptionParams: []*string{}, - ID: to.Ptr("AADDS-CFG-DIAG-I20"), - }}, - ReplicaSetSubnetDisplayName: to.Ptr("West US/aadds-subnet"), - Status: to.Ptr(armdomainservices.StatusWarning), - ValidatorID: to.Ptr("AADDS-CFG-DIAG-V06"), - }}, - }, - DomainSecuritySettings: &armdomainservices.DomainSecuritySettings{ - NtlmV1: to.Ptr(armdomainservices.NtlmV1Enabled), - SyncNtlmPasswords: to.Ptr(armdomainservices.SyncNtlmPasswordsEnabled), - TLSV1: to.Ptr(armdomainservices.TLSV1Disabled), - }, - FilteredSync: to.Ptr(armdomainservices.FilteredSyncEnabled), - LdapsSettings: &armdomainservices.LdapsSettings{ - ExternalAccess: to.Ptr(armdomainservices.ExternalAccessEnabled), - Ldaps: to.Ptr(armdomainservices.LdapsEnabled), - PfxCertificate: to.Ptr("MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w..."), - PfxCertificatePassword: to.Ptr(""), - }, - NotificationSettings: &armdomainservices.NotificationSettings{ - AdditionalRecipients: []*string{ - to.Ptr("jicha@microsoft.com"), - to.Ptr("caalmont@microsoft.com")}, - NotifyDcAdmins: to.Ptr(armdomainservices.NotifyDcAdminsEnabled), - NotifyGlobalAdmins: to.Ptr(armdomainservices.NotifyGlobalAdminsEnabled), - }, - ReplicaSets: []*armdomainservices.ReplicaSet{ - { - Location: to.Ptr("West US"), - SubnetID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS"), - }, - { - Location: to.Ptr("East US"), - SubnetID: to.Ptr("/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetEUS/subnets/TestSubnetEUS"), - }}, - }, - }, - 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/domainservices/armdomainservices/ze_generated_example_oucontainer_client_test.go b/sdk/resourcemanager/domainservices/armdomainservices/ze_generated_example_oucontainer_client_test.go deleted file mode 100644 index 814c75e05d17..000000000000 --- a/sdk/resourcemanager/domainservices/armdomainservices/ze_generated_example_oucontainer_client_test.go +++ /dev/null @@ -1,156 +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 armdomainservices_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/domainservices/armdomainservices" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListOuContainers.json -func ExampleOuContainerClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdomainservices.NewOuContainerClient("1639790a-76a2-4ac4-98d9-8562f5dfcb4d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("OuContainerResourceGroup", - "OuContainer.com", - 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/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOuContainer.json -func ExampleOuContainerClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdomainservices.NewOuContainerClient("1639790a-76a2-4ac4-98d9-8562f5dfcb4d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "OuContainerResourceGroup", - "OuContainer.com", - "OuContainer1", - 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/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/CreateOuContainer.json -func ExampleOuContainerClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdomainservices.NewOuContainerClient("1639790a-76a2-4ac4-98d9-8562f5dfcb4d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "OuContainerResourceGroup", - "OuContainer.com", - "OuContainer1", - armdomainservices.ContainerAccount{ - AccountName: to.Ptr("AccountName1"), - Password: to.Ptr(""), - Spn: to.Ptr("Spn1"), - }, - 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/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/DeleteOuContainer.json -func ExampleOuContainerClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdomainservices.NewOuContainerClient("1639790a-76a2-4ac4-98d9-8562f5dfcb4d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "OuContainerResourceGroup", - "OuContainer.com", - "OuContainer1", - 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/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/UpdateOuContainer.json -func ExampleOuContainerClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdomainservices.NewOuContainerClient("1639790a-76a2-4ac4-98d9-8562f5dfcb4d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "OuContainerResourceGroup", - "OuContainer.com", - "OuContainer1", - armdomainservices.ContainerAccount{ - AccountName: to.Ptr("AccountName1"), - Password: to.Ptr(""), - Spn: to.Ptr("Spn1"), - }, - 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/domainservices/armdomainservices/ze_generated_example_oucontaineroperations_client_test.go b/sdk/resourcemanager/domainservices/armdomainservices/ze_generated_example_oucontaineroperations_client_test.go deleted file mode 100644 index 9d83662c2ee7..000000000000 --- a/sdk/resourcemanager/domainservices/armdomainservices/ze_generated_example_oucontaineroperations_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 armdomainservices_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/domainservices/armdomainservices" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOperations.json -func ExampleOuContainerOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armdomainservices.NewOuContainerOperationsClient(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/domainservices/armdomainservices/zz_generated_models_serde.go b/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_models_serde.go deleted file mode 100644 index 0e25cd5bff7f..000000000000 --- a/sdk/resourcemanager/domainservices/armdomainservices/zz_generated_models_serde.go +++ /dev/null @@ -1,400 +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 armdomainservices - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type ConfigDiagnostics. -func (c ConfigDiagnostics) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC1123(objectMap, "lastExecuted", c.LastExecuted) - populate(objectMap, "validatorResults", c.ValidatorResults) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigDiagnostics. -func (c *ConfigDiagnostics) UnmarshalJSON(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 "lastExecuted": - err = unpopulateTimeRFC1123(val, "LastExecuted", &c.LastExecuted) - delete(rawMsg, key) - case "validatorResults": - err = unpopulate(val, "ValidatorResults", &c.ValidatorResults) - 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 ConfigDiagnosticsValidatorResult. -func (c ConfigDiagnosticsValidatorResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "issues", c.Issues) - populate(objectMap, "replicaSetSubnetDisplayName", c.ReplicaSetSubnetDisplayName) - populate(objectMap, "status", c.Status) - populate(objectMap, "validatorId", c.ValidatorID) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ConfigDiagnosticsValidatorResultIssue. -func (c ConfigDiagnosticsValidatorResultIssue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "descriptionParams", c.DescriptionParams) - populate(objectMap, "id", c.ID) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ContainerAccount. -func (c ContainerAccount) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "accountName", c.AccountName) - populate(objectMap, "password", c.Password) - populate(objectMap, "spn", c.Spn) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type DomainService. -func (d DomainService) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "etag", d.Etag) - populate(objectMap, "id", d.ID) - populate(objectMap, "location", d.Location) - populate(objectMap, "name", d.Name) - populate(objectMap, "properties", d.Properties) - populate(objectMap, "systemData", d.SystemData) - populate(objectMap, "tags", d.Tags) - populate(objectMap, "type", d.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type DomainServiceProperties. -func (d DomainServiceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "configDiagnostics", d.ConfigDiagnostics) - populate(objectMap, "deploymentId", d.DeploymentID) - populate(objectMap, "domainConfigurationType", d.DomainConfigurationType) - populate(objectMap, "domainName", d.DomainName) - populate(objectMap, "domainSecuritySettings", d.DomainSecuritySettings) - populate(objectMap, "filteredSync", d.FilteredSync) - populate(objectMap, "ldapsSettings", d.LdapsSettings) - populate(objectMap, "migrationProperties", d.MigrationProperties) - populate(objectMap, "notificationSettings", d.NotificationSettings) - populate(objectMap, "provisioningState", d.ProvisioningState) - populate(objectMap, "replicaSets", d.ReplicaSets) - populate(objectMap, "resourceForestSettings", d.ResourceForestSettings) - populate(objectMap, "sku", d.SKU) - populate(objectMap, "syncOwner", d.SyncOwner) - populate(objectMap, "tenantId", d.TenantID) - populate(objectMap, "version", d.Version) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type HealthAlert. -func (h HealthAlert) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", h.ID) - populate(objectMap, "issue", h.Issue) - populateTimeRFC3339(objectMap, "lastDetected", h.LastDetected) - populate(objectMap, "name", h.Name) - populateTimeRFC3339(objectMap, "raised", h.Raised) - populate(objectMap, "resolutionUri", h.ResolutionURI) - populate(objectMap, "severity", h.Severity) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type HealthAlert. -func (h *HealthAlert) UnmarshalJSON(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 "id": - err = unpopulate(val, "ID", &h.ID) - delete(rawMsg, key) - case "issue": - err = unpopulate(val, "Issue", &h.Issue) - delete(rawMsg, key) - case "lastDetected": - err = unpopulateTimeRFC3339(val, "LastDetected", &h.LastDetected) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &h.Name) - delete(rawMsg, key) - case "raised": - err = unpopulateTimeRFC3339(val, "Raised", &h.Raised) - delete(rawMsg, key) - case "resolutionUri": - err = unpopulate(val, "ResolutionURI", &h.ResolutionURI) - delete(rawMsg, key) - case "severity": - err = unpopulate(val, "Severity", &h.Severity) - 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 LdapsSettings. -func (l LdapsSettings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "certificateNotAfter", l.CertificateNotAfter) - populate(objectMap, "certificateThumbprint", l.CertificateThumbprint) - populate(objectMap, "externalAccess", l.ExternalAccess) - populate(objectMap, "ldaps", l.Ldaps) - populate(objectMap, "pfxCertificate", l.PfxCertificate) - populate(objectMap, "pfxCertificatePassword", l.PfxCertificatePassword) - populate(objectMap, "publicCertificate", l.PublicCertificate) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type LdapsSettings. -func (l *LdapsSettings) UnmarshalJSON(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 "certificateNotAfter": - err = unpopulateTimeRFC3339(val, "CertificateNotAfter", &l.CertificateNotAfter) - delete(rawMsg, key) - case "certificateThumbprint": - err = unpopulate(val, "CertificateThumbprint", &l.CertificateThumbprint) - delete(rawMsg, key) - case "externalAccess": - err = unpopulate(val, "ExternalAccess", &l.ExternalAccess) - delete(rawMsg, key) - case "ldaps": - err = unpopulate(val, "Ldaps", &l.Ldaps) - delete(rawMsg, key) - case "pfxCertificate": - err = unpopulate(val, "PfxCertificate", &l.PfxCertificate) - delete(rawMsg, key) - case "pfxCertificatePassword": - err = unpopulate(val, "PfxCertificatePassword", &l.PfxCertificatePassword) - delete(rawMsg, key) - case "publicCertificate": - err = unpopulate(val, "PublicCertificate", &l.PublicCertificate) - 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 NotificationSettings. -func (n NotificationSettings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "additionalRecipients", n.AdditionalRecipients) - populate(objectMap, "notifyDcAdmins", n.NotifyDcAdmins) - populate(objectMap, "notifyGlobalAdmins", n.NotifyGlobalAdmins) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type OuContainer. -func (o OuContainer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "etag", o.Etag) - populate(objectMap, "id", o.ID) - populate(objectMap, "location", o.Location) - populate(objectMap, "name", o.Name) - populate(objectMap, "properties", o.Properties) - 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 OuContainerProperties. -func (o OuContainerProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "accounts", o.Accounts) - populate(objectMap, "containerId", o.ContainerID) - populate(objectMap, "deploymentId", o.DeploymentID) - populate(objectMap, "distinguishedName", o.DistinguishedName) - populate(objectMap, "domainName", o.DomainName) - populate(objectMap, "provisioningState", o.ProvisioningState) - populate(objectMap, "serviceStatus", o.ServiceStatus) - populate(objectMap, "tenantId", o.TenantID) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ReplicaSet. -func (r ReplicaSet) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "domainControllerIpAddress", r.DomainControllerIPAddress) - populate(objectMap, "externalAccessIpAddress", r.ExternalAccessIPAddress) - populate(objectMap, "healthAlerts", r.HealthAlerts) - populateTimeRFC1123(objectMap, "healthLastEvaluated", r.HealthLastEvaluated) - populate(objectMap, "healthMonitors", r.HealthMonitors) - populate(objectMap, "location", r.Location) - populate(objectMap, "replicaSetId", r.ReplicaSetID) - populate(objectMap, "serviceStatus", r.ServiceStatus) - populate(objectMap, "subnetId", r.SubnetID) - populate(objectMap, "vnetSiteId", r.VnetSiteID) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ReplicaSet. -func (r *ReplicaSet) UnmarshalJSON(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 "domainControllerIpAddress": - err = unpopulate(val, "DomainControllerIPAddress", &r.DomainControllerIPAddress) - delete(rawMsg, key) - case "externalAccessIpAddress": - err = unpopulate(val, "ExternalAccessIPAddress", &r.ExternalAccessIPAddress) - delete(rawMsg, key) - case "healthAlerts": - err = unpopulate(val, "HealthAlerts", &r.HealthAlerts) - delete(rawMsg, key) - case "healthLastEvaluated": - err = unpopulateTimeRFC1123(val, "HealthLastEvaluated", &r.HealthLastEvaluated) - delete(rawMsg, key) - case "healthMonitors": - err = unpopulate(val, "HealthMonitors", &r.HealthMonitors) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &r.Location) - delete(rawMsg, key) - case "replicaSetId": - err = unpopulate(val, "ReplicaSetID", &r.ReplicaSetID) - delete(rawMsg, key) - case "serviceStatus": - err = unpopulate(val, "ServiceStatus", &r.ServiceStatus) - delete(rawMsg, key) - case "subnetId": - err = unpopulate(val, "SubnetID", &r.SubnetID) - delete(rawMsg, key) - case "vnetSiteId": - err = unpopulate(val, "VnetSiteID", &r.VnetSiteID) - 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]interface{}) - populate(objectMap, "etag", r.Etag) - populate(objectMap, "id", r.ID) - populate(objectMap, "location", r.Location) - populate(objectMap, "name", r.Name) - 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 ResourceForestSettings. -func (r ResourceForestSettings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "resourceForest", r.ResourceForest) - populate(objectMap, "settings", r.Settings) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -} diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/CHANGELOG.md b/sdk/resourcemanager/dynatrace/armdynatrace/CHANGELOG.md index 6179e8801d95..69f403945ad7 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/CHANGELOG.md +++ b/sdk/resourcemanager/dynatrace/armdynatrace/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-09-20) ### Other Changes diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/README.md b/sdk/resourcemanager/dynatrace/armdynatrace/README.md index 663cd4f81af0..6ef368f4af62 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/README.md +++ b/sdk/resourcemanager/dynatrace/armdynatrace/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 Dynatrace 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 Dynatrace 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 := armdynatrace.NewTagRulesClient(, cred, nil) +clientFactory, err := armdynatrace.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 := armdynatrace.NewTagRulesClient(, cred, &options) +clientFactory, err := armdynatrace.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.NewMonitorsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/autorest.md b/sdk/resourcemanager/dynatrace/armdynatrace/autorest.md index 5906e3a4ef29..7fb91c2cffec 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/autorest.md +++ b/sdk/resourcemanager/dynatrace/armdynatrace/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/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/dynatrace/armdynatrace/client_factory.go b/sdk/resourcemanager/dynatrace/armdynatrace/client_factory.go new file mode 100644 index 000000000000..d1c3c8c1fce9 --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/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 armdynatrace + +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) NewMonitorsClient() *MonitorsClient { + subClient, _ := NewMonitorsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewTagRulesClient() *TagRulesClient { + subClient, _ := NewTagRulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSingleSignOnClient() *SingleSignOnClient { + subClient, _ := NewSingleSignOnClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/constants.go b/sdk/resourcemanager/dynatrace/armdynatrace/constants.go index 54685c6142ef..ae21ed7c0d17 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/constants.go +++ b/sdk/resourcemanager/dynatrace/armdynatrace/constants.go @@ -11,7 +11,7 @@ package armdynatrace const ( moduleName = "armdynatrace" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/go.mod b/sdk/resourcemanager/dynatrace/armdynatrace/go.mod index 6219fee474ee..172e03a7baff 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/go.mod +++ b/sdk/resourcemanager/dynatrace/armdynatrace/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dynatrace/armdynatr 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/dynatrace/armdynatrace/go.sum b/sdk/resourcemanager/dynatrace/armdynatrace/go.sum index 8828b17b1853..8ba445a8c4da 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/go.sum +++ b/sdk/resourcemanager/dynatrace/armdynatrace/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/dynatrace/armdynatrace/models.go b/sdk/resourcemanager/dynatrace/armdynatrace/models.go index bab5e7ad45da..2e23587ed7fe 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/models.go +++ b/sdk/resourcemanager/dynatrace/armdynatrace/models.go @@ -345,34 +345,35 @@ type MonitorsClientGetVMHostPayloadOptions struct { // placeholder for future optional parameters } -// MonitorsClientListAppServicesOptions contains the optional parameters for the MonitorsClient.ListAppServices method. +// MonitorsClientListAppServicesOptions contains the optional parameters for the MonitorsClient.NewListAppServicesPager method. type MonitorsClientListAppServicesOptions struct { // placeholder for future optional parameters } -// MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.ListByResourceGroup method. +// MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.NewListByResourceGroupPager +// method. type MonitorsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// MonitorsClientListBySubscriptionIDOptions contains the optional parameters for the MonitorsClient.ListBySubscriptionID +// MonitorsClientListBySubscriptionIDOptions contains the optional parameters for the MonitorsClient.NewListBySubscriptionIDPager // method. type MonitorsClientListBySubscriptionIDOptions struct { // placeholder for future optional parameters } -// MonitorsClientListHostsOptions contains the optional parameters for the MonitorsClient.ListHosts method. +// MonitorsClientListHostsOptions contains the optional parameters for the MonitorsClient.NewListHostsPager method. type MonitorsClientListHostsOptions struct { // placeholder for future optional parameters } -// MonitorsClientListLinkableEnvironmentsOptions contains the optional parameters for the MonitorsClient.ListLinkableEnvironments +// MonitorsClientListLinkableEnvironmentsOptions contains the optional parameters for the MonitorsClient.NewListLinkableEnvironmentsPager // method. type MonitorsClientListLinkableEnvironmentsOptions struct { // placeholder for future optional parameters } -// MonitorsClientListMonitoredResourcesOptions contains the optional parameters for the MonitorsClient.ListMonitoredResources +// MonitorsClientListMonitoredResourcesOptions contains the optional parameters for the MonitorsClient.NewListMonitoredResourcesPager // method. type MonitorsClientListMonitoredResourcesOptions struct { // placeholder for future optional parameters @@ -432,7 +433,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 } @@ -488,7 +489,7 @@ type SingleSignOnClientGetOptions struct { // placeholder for future optional parameters } -// SingleSignOnClientListOptions contains the optional parameters for the SingleSignOnClient.List method. +// SingleSignOnClientListOptions contains the optional parameters for the SingleSignOnClient.NewListPager method. type SingleSignOnClientListOptions struct { // placeholder for future optional parameters } @@ -612,7 +613,7 @@ type TagRulesClientGetOptions struct { // placeholder for future optional parameters } -// TagRulesClientListOptions contains the optional parameters for the TagRulesClient.List method. +// TagRulesClientListOptions contains the optional parameters for the TagRulesClient.NewListPager method. type TagRulesClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/models_serde.go b/sdk/resourcemanager/dynatrace/armdynatrace/models_serde.go index 5a3cfbf780b8..f88b589f6108 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/models_serde.go +++ b/sdk/resourcemanager/dynatrace/armdynatrace/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type AccountInfo. func (a AccountInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "accountId", a.AccountID) populate(objectMap, "regionId", a.RegionID) return json.Marshal(objectMap) @@ -49,7 +49,7 @@ func (a *AccountInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AccountInfoSecure. func (a AccountInfoSecure) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "apiKey", a.APIKey) populate(objectMap, "accountId", a.AccountID) populate(objectMap, "regionId", a.RegionID) @@ -84,7 +84,7 @@ func (a *AccountInfoSecure) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AppServiceInfo. func (a AppServiceInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "autoUpdateSetting", a.AutoUpdateSetting) populate(objectMap, "availabilityState", a.AvailabilityState) populate(objectMap, "hostGroup", a.HostGroup) @@ -143,7 +143,7 @@ func (a *AppServiceInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AppServiceListResponse. func (a AppServiceListResponse) 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) @@ -174,7 +174,7 @@ func (a *AppServiceListResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EnvironmentInfo. func (e EnvironmentInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "environmentId", e.EnvironmentID) populate(objectMap, "ingestionKey", e.IngestionKey) populate(objectMap, "landingURL", e.LandingURL) @@ -213,7 +213,7 @@ func (e *EnvironmentInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EnvironmentProperties. func (e EnvironmentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "accountInfo", e.AccountInfo) populate(objectMap, "environmentInfo", e.EnvironmentInfo) populate(objectMap, "singleSignOnProperties", e.SingleSignOnProperties) @@ -252,7 +252,7 @@ func (e *EnvironmentProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FilteringTag. func (f FilteringTag) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "action", f.Action) populate(objectMap, "name", f.Name) populate(objectMap, "value", f.Value) @@ -287,7 +287,7 @@ func (f *FilteringTag) 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) @@ -326,7 +326,7 @@ func (i *IdentityProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LinkableEnvironmentListResponse. func (l LinkableEnvironmentListResponse) 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) @@ -357,7 +357,7 @@ func (l *LinkableEnvironmentListResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LinkableEnvironmentRequest. func (l LinkableEnvironmentRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "region", l.Region) populate(objectMap, "tenantId", l.TenantID) populate(objectMap, "userPrincipal", l.UserPrincipal) @@ -392,7 +392,7 @@ func (l *LinkableEnvironmentRequest) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LinkableEnvironmentResponse. func (l LinkableEnvironmentResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "environmentId", l.EnvironmentID) populate(objectMap, "environmentName", l.EnvironmentName) populate(objectMap, "planData", l.PlanData) @@ -427,7 +427,7 @@ func (l *LinkableEnvironmentResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LogRules. func (l LogRules) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "filteringTags", l.FilteringTags) populate(objectMap, "sendAadLogs", l.SendAADLogs) populate(objectMap, "sendActivityLogs", l.SendActivityLogs) @@ -466,7 +466,7 @@ func (l *LogRules) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MetricRules. func (m MetricRules) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "filteringTags", m.FilteringTags) return json.Marshal(objectMap) } @@ -493,7 +493,7 @@ func (m *MetricRules) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitorProperties. func (m MonitorProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "dynatraceEnvironmentProperties", m.DynatraceEnvironmentProperties) populate(objectMap, "liftrResourceCategory", m.LiftrResourceCategory) populate(objectMap, "liftrResourcePreference", m.LiftrResourcePreference) @@ -548,7 +548,7 @@ func (m *MonitorProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitorResource. func (m MonitorResource) 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) @@ -603,7 +603,7 @@ func (m *MonitorResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitorResourceListResult. func (m MonitorResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", m.NextLink) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) @@ -634,7 +634,7 @@ func (m *MonitorResourceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitorResourceUpdate. func (m MonitorResourceUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "dynatraceEnvironmentProperties", m.DynatraceEnvironmentProperties) populate(objectMap, "marketplaceSubscriptionStatus", m.MarketplaceSubscriptionStatus) populate(objectMap, "monitoringStatus", m.MonitoringStatus) @@ -681,7 +681,7 @@ func (m *MonitorResourceUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitoredResource. func (m MonitoredResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", m.ID) populate(objectMap, "reasonForLogsStatus", m.ReasonForLogsStatus) populate(objectMap, "reasonForMetricsStatus", m.ReasonForMetricsStatus) @@ -724,7 +724,7 @@ func (m *MonitoredResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitoredResourceListResponse. func (m MonitoredResourceListResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", m.NextLink) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) @@ -755,7 +755,7 @@ func (m *MonitoredResourceListResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitoringTagRulesProperties. func (m MonitoringTagRulesProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "logRules", m.LogRules) populate(objectMap, "metricRules", m.MetricRules) populate(objectMap, "provisioningState", m.ProvisioningState) @@ -790,7 +790,7 @@ func (m *MonitoringTagRulesProperties) 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) @@ -833,7 +833,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) @@ -872,7 +872,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) @@ -903,7 +903,7 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PlanData. func (p PlanData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "billingCycle", p.BillingCycle) populateTimeRFC3339(objectMap, "effectiveDate", p.EffectiveDate) populate(objectMap, "planDetails", p.PlanDetails) @@ -942,7 +942,7 @@ func (p *PlanData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SSODetailsRequest. func (s SSODetailsRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "userPrincipal", s.UserPrincipal) return json.Marshal(objectMap) } @@ -969,7 +969,7 @@ func (s *SSODetailsRequest) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SSODetailsResponse. func (s SSODetailsResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "aadDomains", s.AADDomains) populate(objectMap, "adminUsers", s.AdminUsers) populate(objectMap, "isSsoEnabled", s.IsSsoEnabled) @@ -1012,7 +1012,7 @@ func (s *SSODetailsResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SingleSignOnProperties. func (s SingleSignOnProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "aadDomains", s.AADDomains) populate(objectMap, "enterpriseAppId", s.EnterpriseAppID) populate(objectMap, "provisioningState", s.ProvisioningState) @@ -1055,7 +1055,7 @@ func (s *SingleSignOnProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SingleSignOnResource. func (s SingleSignOnResource) 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) @@ -1098,7 +1098,7 @@ func (s *SingleSignOnResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SingleSignOnResourceListResult. func (s SingleSignOnResourceListResult) 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) @@ -1129,7 +1129,7 @@ func (s *SingleSignOnResourceListResult) 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) @@ -1176,7 +1176,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TagRule. func (t TagRule) 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) @@ -1219,7 +1219,7 @@ func (t *TagRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TagRuleListResult. func (t TagRuleListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", t.NextLink) populate(objectMap, "value", t.Value) return json.Marshal(objectMap) @@ -1250,7 +1250,7 @@ func (t *TagRuleListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TagRuleUpdate. func (t TagRuleUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "logRules", t.LogRules) populate(objectMap, "metricRules", t.MetricRules) return json.Marshal(objectMap) @@ -1281,7 +1281,7 @@ func (t *TagRuleUpdate) 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) @@ -1312,7 +1312,7 @@ func (u *UserAssignedIdentity) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UserInfo. func (u UserInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "country", u.Country) populate(objectMap, "emailAddress", u.EmailAddress) populate(objectMap, "firstName", u.FirstName) @@ -1355,7 +1355,7 @@ func (u *UserInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VMExtensionPayload. func (v VMExtensionPayload) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "environmentId", v.EnvironmentID) populate(objectMap, "ingestionKey", v.IngestionKey) return json.Marshal(objectMap) @@ -1386,7 +1386,7 @@ func (v *VMExtensionPayload) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VMHostsListResponse. func (v VMHostsListResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", v.NextLink) populate(objectMap, "value", v.Value) return json.Marshal(objectMap) @@ -1417,7 +1417,7 @@ func (v *VMHostsListResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VMInfo. func (v VMInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "autoUpdateSetting", v.AutoUpdateSetting) populate(objectMap, "availabilityState", v.AvailabilityState) populate(objectMap, "hostGroup", v.HostGroup) @@ -1474,7 +1474,7 @@ func (v *VMInfo) 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) { @@ -1484,7 +1484,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/dynatrace/armdynatrace/monitors_client.go b/sdk/resourcemanager/dynatrace/armdynatrace/monitors_client.go index 493c6fd45e3b..bff9d22149da 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/monitors_client.go +++ b/sdk/resourcemanager/dynatrace/armdynatrace/monitors_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 ( // MonitorsClient contains the methods for the Monitors group. // Don't use this type directly, use NewMonitorsClient() instead. type MonitorsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewMonitorsClient creates a new instance of MonitorsClient 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 NewMonitorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MonitorsClient, 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+".MonitorsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &MonitorsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create a MonitorResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// resource - Resource create parameters. -// options - MonitorsClientBeginCreateOrUpdateOptions contains the optional parameters for the MonitorsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - resource - Resource create parameters. +// - options - MonitorsClientBeginCreateOrUpdateOptions contains the optional parameters for the MonitorsClient.BeginCreateOrUpdate +// method. func (client *MonitorsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, resource MonitorResource, options *MonitorsClientBeginCreateOrUpdateOptions) (*runtime.Poller[MonitorsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, monitorName, resource, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[MonitorsClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MonitorsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[MonitorsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[MonitorsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create a MonitorResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 func (client *MonitorsClient) createOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, resource MonitorResource, options *MonitorsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, monitorName, resource, 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 *MonitorsClient) createOrUpdateCreateRequest(ctx context.Context, r return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - 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 *MonitorsClient) createOrUpdateCreateRequest(ctx context.Context, r // BeginDelete - Delete a MonitorResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// options - MonitorsClientBeginDeleteOptions contains the optional parameters for the MonitorsClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - options - MonitorsClientBeginDeleteOptions contains the optional parameters for the MonitorsClient.BeginDelete method. func (client *MonitorsClient) BeginDelete(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginDeleteOptions) (*runtime.Poller[MonitorsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[MonitorsClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MonitorsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[MonitorsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[MonitorsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete a MonitorResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 func (client *MonitorsClient) deleteOperation(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, monitorName, 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 *MonitorsClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - 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 *MonitorsClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Get a MonitorResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// options - MonitorsClientGetOptions contains the optional parameters for the MonitorsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - options - MonitorsClientGetOptions contains the optional parameters for the MonitorsClient.Get method. func (client *MonitorsClient) Get(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetOptions) (MonitorsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return MonitorsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientGetResponse{}, err } @@ -221,7 +215,7 @@ func (client *MonitorsClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - 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,17 +237,18 @@ func (client *MonitorsClient) getHandleResponse(resp *http.Response) (MonitorsCl // GetAccountCredentials - Gets the user account credentials for a Monitor // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// options - MonitorsClientGetAccountCredentialsOptions contains the optional parameters for the MonitorsClient.GetAccountCredentials -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - options - MonitorsClientGetAccountCredentialsOptions contains the optional parameters for the MonitorsClient.GetAccountCredentials +// method. func (client *MonitorsClient) GetAccountCredentials(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetAccountCredentialsOptions) (MonitorsClientGetAccountCredentialsResponse, error) { req, err := client.getAccountCredentialsCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return MonitorsClientGetAccountCredentialsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientGetAccountCredentialsResponse{}, err } @@ -278,7 +273,7 @@ func (client *MonitorsClient) getAccountCredentialsCreateRequest(ctx context.Con return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - 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 } @@ -300,16 +295,17 @@ func (client *MonitorsClient) getAccountCredentialsHandleResponse(resp *http.Res // GetSSODetails - Gets the SSO configuration details from the partner. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// options - MonitorsClientGetSSODetailsOptions contains the optional parameters for the MonitorsClient.GetSSODetails method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - options - MonitorsClientGetSSODetailsOptions contains the optional parameters for the MonitorsClient.GetSSODetails method. func (client *MonitorsClient) GetSSODetails(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetSSODetailsOptions) (MonitorsClientGetSSODetailsResponse, error) { req, err := client.getSSODetailsCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return MonitorsClientGetSSODetailsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientGetSSODetailsResponse{}, err } @@ -334,7 +330,7 @@ func (client *MonitorsClient) getSSODetailsCreateRequest(ctx context.Context, re return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - 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 } @@ -360,17 +356,18 @@ func (client *MonitorsClient) getSSODetailsHandleResponse(resp *http.Response) ( // GetVMHostPayload - Returns the payload that needs to be passed in the request body for installing Dynatrace agent on a // VM. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// options - MonitorsClientGetVMHostPayloadOptions contains the optional parameters for the MonitorsClient.GetVMHostPayload -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - options - MonitorsClientGetVMHostPayloadOptions contains the optional parameters for the MonitorsClient.GetVMHostPayload +// method. func (client *MonitorsClient) GetVMHostPayload(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetVMHostPayloadOptions) (MonitorsClientGetVMHostPayloadResponse, error) { req, err := client.getVMHostPayloadCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return MonitorsClientGetVMHostPayloadResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientGetVMHostPayloadResponse{}, err } @@ -395,7 +392,7 @@ func (client *MonitorsClient) getVMHostPayloadCreateRequest(ctx context.Context, return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - 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 } @@ -416,11 +413,12 @@ func (client *MonitorsClient) getVMHostPayloadHandleResponse(resp *http.Response } // NewListAppServicesPager - Gets list of App Services with Dynatrace PaaS OneAgent enabled +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// options - MonitorsClientListAppServicesOptions contains the optional parameters for the MonitorsClient.ListAppServices -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - options - MonitorsClientListAppServicesOptions contains the optional parameters for the MonitorsClient.NewListAppServicesPager +// method. func (client *MonitorsClient) NewListAppServicesPager(resourceGroupName string, monitorName string, options *MonitorsClientListAppServicesOptions) *runtime.Pager[MonitorsClientListAppServicesResponse] { return runtime.NewPager(runtime.PagingHandler[MonitorsClientListAppServicesResponse]{ More: func(page MonitorsClientListAppServicesResponse) bool { @@ -437,7 +435,7 @@ func (client *MonitorsClient) NewListAppServicesPager(resourceGroupName string, if err != nil { return MonitorsClientListAppServicesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientListAppServicesResponse{}, err } @@ -464,7 +462,7 @@ func (client *MonitorsClient) listAppServicesCreateRequest(ctx context.Context, return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - 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 } @@ -485,10 +483,11 @@ func (client *MonitorsClient) listAppServicesHandleResponse(resp *http.Response) } // NewListByResourceGroupPager - List MonitorResource resources by resource group +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.NewListByResourceGroupPager +// method. func (client *MonitorsClient) NewListByResourceGroupPager(resourceGroupName string, options *MonitorsClientListByResourceGroupOptions) *runtime.Pager[MonitorsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[MonitorsClientListByResourceGroupResponse]{ More: func(page MonitorsClientListByResourceGroupResponse) bool { @@ -505,7 +504,7 @@ func (client *MonitorsClient) NewListByResourceGroupPager(resourceGroupName stri if err != nil { return MonitorsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientListByResourceGroupResponse{}, err } @@ -528,7 +527,7 @@ func (client *MonitorsClient) listByResourceGroupCreateRequest(ctx context.Conte 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 } @@ -549,9 +548,10 @@ func (client *MonitorsClient) listByResourceGroupHandleResponse(resp *http.Respo } // NewListBySubscriptionIDPager - List all MonitorResource by subscriptionId +// // Generated from API version 2021-09-01 -// options - MonitorsClientListBySubscriptionIDOptions contains the optional parameters for the MonitorsClient.ListBySubscriptionID -// method. +// - options - MonitorsClientListBySubscriptionIDOptions contains the optional parameters for the MonitorsClient.NewListBySubscriptionIDPager +// method. func (client *MonitorsClient) NewListBySubscriptionIDPager(options *MonitorsClientListBySubscriptionIDOptions) *runtime.Pager[MonitorsClientListBySubscriptionIDResponse] { return runtime.NewPager(runtime.PagingHandler[MonitorsClientListBySubscriptionIDResponse]{ More: func(page MonitorsClientListBySubscriptionIDResponse) bool { @@ -568,7 +568,7 @@ func (client *MonitorsClient) NewListBySubscriptionIDPager(options *MonitorsClie if err != nil { return MonitorsClientListBySubscriptionIDResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientListBySubscriptionIDResponse{}, err } @@ -587,7 +587,7 @@ func (client *MonitorsClient) listBySubscriptionIDCreateRequest(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 } @@ -608,10 +608,11 @@ func (client *MonitorsClient) listBySubscriptionIDHandleResponse(resp *http.Resp } // NewListHostsPager - List the compute resources currently being monitored by the Dynatrace resource. +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// options - MonitorsClientListHostsOptions contains the optional parameters for the MonitorsClient.ListHosts method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - options - MonitorsClientListHostsOptions contains the optional parameters for the MonitorsClient.NewListHostsPager method. func (client *MonitorsClient) NewListHostsPager(resourceGroupName string, monitorName string, options *MonitorsClientListHostsOptions) *runtime.Pager[MonitorsClientListHostsResponse] { return runtime.NewPager(runtime.PagingHandler[MonitorsClientListHostsResponse]{ More: func(page MonitorsClientListHostsResponse) bool { @@ -628,7 +629,7 @@ func (client *MonitorsClient) NewListHostsPager(resourceGroupName string, monito if err != nil { return MonitorsClientListHostsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientListHostsResponse{}, err } @@ -655,7 +656,7 @@ func (client *MonitorsClient) listHostsCreateRequest(ctx context.Context, resour return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - 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 } @@ -676,12 +677,13 @@ func (client *MonitorsClient) listHostsHandleResponse(resp *http.Response) (Moni } // NewListLinkableEnvironmentsPager - Gets all the Dynatrace environments that a user can link a azure resource to +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// request - The details of the linkable environment request. -// options - MonitorsClientListLinkableEnvironmentsOptions contains the optional parameters for the MonitorsClient.ListLinkableEnvironments -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - request - The details of the linkable environment request. +// - options - MonitorsClientListLinkableEnvironmentsOptions contains the optional parameters for the MonitorsClient.NewListLinkableEnvironmentsPager +// method. func (client *MonitorsClient) NewListLinkableEnvironmentsPager(resourceGroupName string, monitorName string, request LinkableEnvironmentRequest, options *MonitorsClientListLinkableEnvironmentsOptions) *runtime.Pager[MonitorsClientListLinkableEnvironmentsResponse] { return runtime.NewPager(runtime.PagingHandler[MonitorsClientListLinkableEnvironmentsResponse]{ More: func(page MonitorsClientListLinkableEnvironmentsResponse) bool { @@ -698,7 +700,7 @@ func (client *MonitorsClient) NewListLinkableEnvironmentsPager(resourceGroupName if err != nil { return MonitorsClientListLinkableEnvironmentsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientListLinkableEnvironmentsResponse{}, err } @@ -725,7 +727,7 @@ func (client *MonitorsClient) listLinkableEnvironmentsCreateRequest(ctx context. return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - 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 } @@ -746,11 +748,12 @@ func (client *MonitorsClient) listLinkableEnvironmentsHandleResponse(resp *http. } // NewListMonitoredResourcesPager - List the resources currently being monitored by the Dynatrace monitor resource. +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// options - MonitorsClientListMonitoredResourcesOptions contains the optional parameters for the MonitorsClient.ListMonitoredResources -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - options - MonitorsClientListMonitoredResourcesOptions contains the optional parameters for the MonitorsClient.NewListMonitoredResourcesPager +// method. func (client *MonitorsClient) NewListMonitoredResourcesPager(resourceGroupName string, monitorName string, options *MonitorsClientListMonitoredResourcesOptions) *runtime.Pager[MonitorsClientListMonitoredResourcesResponse] { return runtime.NewPager(runtime.PagingHandler[MonitorsClientListMonitoredResourcesResponse]{ More: func(page MonitorsClientListMonitoredResourcesResponse) bool { @@ -767,7 +770,7 @@ func (client *MonitorsClient) NewListMonitoredResourcesPager(resourceGroupName s if err != nil { return MonitorsClientListMonitoredResourcesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientListMonitoredResourcesResponse{}, err } @@ -794,7 +797,7 @@ func (client *MonitorsClient) listMonitoredResourcesCreateRequest(ctx context.Co return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - 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 } @@ -816,17 +819,18 @@ func (client *MonitorsClient) listMonitoredResourcesHandleResponse(resp *http.Re // Update - Update a MonitorResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// resource - The resource properties to be updated. -// options - MonitorsClientUpdateOptions contains the optional parameters for the MonitorsClient.Update method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - resource - The resource properties to be updated. +// - options - MonitorsClientUpdateOptions contains the optional parameters for the MonitorsClient.Update method. func (client *MonitorsClient) Update(ctx context.Context, resourceGroupName string, monitorName string, resource MonitorResourceUpdate, options *MonitorsClientUpdateOptions) (MonitorsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, monitorName, resource, options) if err != nil { return MonitorsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientUpdateResponse{}, err } @@ -851,7 +855,7 @@ func (client *MonitorsClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - 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/dynatrace/armdynatrace/monitors_client_example_test.go b/sdk/resourcemanager/dynatrace/armdynatrace/monitors_client_example_test.go index 648aed9cdd89..8f1b67ede005 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/monitors_client_example_test.go +++ b/sdk/resourcemanager/dynatrace/armdynatrace/monitors_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 armdynatrace_test @@ -19,180 +20,279 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dynatrace/armdynatrace" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_GetAccountCredentials_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_GetAccountCredentials_MaximumSet_Gen.json func ExampleMonitorsClient_GetAccountCredentials_monitorsGetAccountCredentialsMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GetAccountCredentials(ctx, "myResourceGroup", "myMonitor", nil) + res, err := clientFactory.NewMonitorsClient().GetAccountCredentials(ctx, "myResourceGroup", "myMonitor", 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.AccountInfoSecure = armdynatrace.AccountInfoSecure{ + // AccountID: to.Ptr("1234567890"), + // RegionID: to.Ptr("wus2"), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_GetAccountCredentials_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_GetAccountCredentials_MinimumSet_Gen.json func ExampleMonitorsClient_GetAccountCredentials_monitorsGetAccountCredentialsMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GetAccountCredentials(ctx, "myResourceGroup", "myMonitor", nil) + res, err := clientFactory.NewMonitorsClient().GetAccountCredentials(ctx, "myResourceGroup", "myMonitor", 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.AccountInfoSecure = armdynatrace.AccountInfoSecure{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListMonitoredResources_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListMonitoredResources_MaximumSet_Gen.json func ExampleMonitorsClient_NewListMonitoredResourcesPager_monitorsListMonitoredResourcesMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListMonitoredResourcesPager("myResourceGroup", "myMonitor", nil) + pager := clientFactory.NewMonitorsClient().NewListMonitoredResourcesPager("myResourceGroup", "myMonitor", 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.MonitoredResourceListResponse = armdynatrace.MonitoredResourceListResponse{ + // Value: []*armdynatrace.MonitoredResource{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor/listMonitoredResources"), + // ReasonForLogsStatus: to.Ptr("CapturedByRules"), + // ReasonForMetricsStatus: to.Ptr("CapturedByRules"), + // SendingLogs: to.Ptr(armdynatrace.SendingLogsStatusEnabled), + // SendingMetrics: to.Ptr(armdynatrace.SendingMetricsStatusEnabled), + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListMonitoredResources_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListMonitoredResources_MinimumSet_Gen.json func ExampleMonitorsClient_NewListMonitoredResourcesPager_monitorsListMonitoredResourcesMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListMonitoredResourcesPager("myResourceGroup", "myMonitor", nil) + pager := clientFactory.NewMonitorsClient().NewListMonitoredResourcesPager("myResourceGroup", "myMonitor", 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.MonitoredResourceListResponse = armdynatrace.MonitoredResourceListResponse{ + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_GetVMHostPayload_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_GetVMHostPayload_MaximumSet_Gen.json func ExampleMonitorsClient_GetVMHostPayload_monitorsGetVmHostPayloadMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GetVMHostPayload(ctx, "myResourceGroup", "myMonitor", nil) + res, err := clientFactory.NewMonitorsClient().GetVMHostPayload(ctx, "myResourceGroup", "myMonitor", 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.VMExtensionPayload = armdynatrace.VMExtensionPayload{ + // EnvironmentID: to.Ptr("abc123lsjlsfjlfjgd"), + // IngestionKey: to.Ptr("abcd.efg"), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_GetVMHostPayload_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_GetVMHostPayload_MinimumSet_Gen.json func ExampleMonitorsClient_GetVMHostPayload_monitorsGetVmHostPayloadMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GetVMHostPayload(ctx, "myResourceGroup", "myMonitor", nil) + res, err := clientFactory.NewMonitorsClient().GetVMHostPayload(ctx, "myResourceGroup", "myMonitor", 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.VMExtensionPayload = armdynatrace.VMExtensionPayload{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_Get_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_Get_MaximumSet_Gen.json func ExampleMonitorsClient_Get_monitorsGetMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myResourceGroup", "myMonitor", nil) + res, err := clientFactory.NewMonitorsClient().Get(ctx, "myResourceGroup", "myMonitor", 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.MonitorResource = armdynatrace.MonitorResource{ + // Name: to.Ptr("myMonitor"), + // Type: to.Ptr("Dynatrace.Observability/monitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor"), + // Location: to.Ptr("West US 2"), + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // Identity: &armdynatrace.IdentityProperties{ + // Type: to.Ptr(armdynatrace.ManagedIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("4534676867978"), + // TenantID: to.Ptr("23456789001"), + // }, + // Properties: &armdynatrace.MonitorProperties{ + // DynatraceEnvironmentProperties: &armdynatrace.EnvironmentProperties{ + // AccountInfo: &armdynatrace.AccountInfo{ + // AccountID: to.Ptr("1234567890"), + // RegionID: to.Ptr("wus2"), + // }, + // EnvironmentInfo: &armdynatrace.EnvironmentInfo{ + // EnvironmentID: to.Ptr("a23xcv456"), + // IngestionKey: to.Ptr("1234567890"), + // LandingURL: to.Ptr("https://a23xcv456.dynatrace.com"), + // LogsIngestionEndpoint: to.Ptr("https://dynatrace.com"), + // }, + // SingleSignOnProperties: &armdynatrace.SingleSignOnProperties{ + // AADDomains: []*string{ + // to.Ptr("mpliftrdt20210811outlook.onmicrosoft.com")}, + // EnterpriseAppID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // SingleSignOnState: to.Ptr(armdynatrace.SingleSignOnStatesEnable), + // SingleSignOnURL: to.Ptr("https://www.dynatrace.io/IAmSomeHash"), + // }, + // UserID: to.Ptr("alice123"), + // }, + // LiftrResourceCategory: to.Ptr(armdynatrace.LiftrResourceCategoriesUnknown), + // LiftrResourcePreference: to.Ptr[int32](28), + // MarketplaceSubscriptionStatus: to.Ptr(armdynatrace.MarketplaceSubscriptionStatusActive), + // MonitoringStatus: to.Ptr(armdynatrace.MonitoringStatusEnabled), + // PlanData: &armdynatrace.PlanData{ + // BillingCycle: to.Ptr("Monthly"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-30T15:14:33+02:00"); return t}()), + // PlanDetails: to.Ptr("dynatraceapitestplan"), + // UsageType: to.Ptr("Committed"), + // }, + // ProvisioningState: to.Ptr(armdynatrace.ProvisioningStateSucceeded), + // UserInfo: &armdynatrace.UserInfo{ + // Country: to.Ptr("westus2"), + // EmailAddress: to.Ptr("alice@microsoft.com"), + // FirstName: to.Ptr("Alice"), + // LastName: to.Ptr("Bobab"), + // PhoneNumber: to.Ptr("123456"), + // }, + // }, + // SystemData: &armdynatrace.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // CreatedBy: to.Ptr("alice@microsoft.com"), + // CreatedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // LastModifiedBy: to.Ptr("alice@microsoft.com"), + // LastModifiedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_Get_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_Get_MinimumSet_Gen.json func ExampleMonitorsClient_Get_monitorsGetMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myResourceGroup", "myMonitor", nil) + res, err := clientFactory.NewMonitorsClient().Get(ctx, "myResourceGroup", "myMonitor", 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.MonitorResource = armdynatrace.MonitorResource{ + // Location: to.Ptr("West US 2"), + // Properties: &armdynatrace.MonitorProperties{ + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_CreateOrUpdate_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_CreateOrUpdate_MaximumSet_Gen.json func ExampleMonitorsClient_BeginCreateOrUpdate_monitorsCreateOrUpdateMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "myResourceGroup", "myMonitor", armdynatrace.MonitorResource{ + poller, err := clientFactory.NewMonitorsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myMonitor", armdynatrace.MonitorResource{ Location: to.Ptr("West US 2"), Tags: map[string]*string{ "Environment": to.Ptr("Dev"), @@ -232,22 +332,84 @@ func ExampleMonitorsClient_BeginCreateOrUpdate_monitorsCreateOrUpdateMaximumSetG 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.MonitorResource = armdynatrace.MonitorResource{ + // Name: to.Ptr("myMonitor"), + // Type: to.Ptr("Dynatrace.Observability/monitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor"), + // Location: to.Ptr("West US 2"), + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // Identity: &armdynatrace.IdentityProperties{ + // Type: to.Ptr(armdynatrace.ManagedIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("4534676867978"), + // TenantID: to.Ptr("23456789001"), + // }, + // Properties: &armdynatrace.MonitorProperties{ + // DynatraceEnvironmentProperties: &armdynatrace.EnvironmentProperties{ + // AccountInfo: &armdynatrace.AccountInfo{ + // AccountID: to.Ptr("1234567890"), + // RegionID: to.Ptr("wus2"), + // }, + // EnvironmentInfo: &armdynatrace.EnvironmentInfo{ + // EnvironmentID: to.Ptr("a23xcv456"), + // IngestionKey: to.Ptr("1234567890"), + // LogsIngestionEndpoint: to.Ptr("https://dynatrace.com"), + // }, + // SingleSignOnProperties: &armdynatrace.SingleSignOnProperties{ + // AADDomains: []*string{ + // to.Ptr("mpliftrdt20210811outlook.onmicrosoft.com")}, + // EnterpriseAppID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // SingleSignOnState: to.Ptr(armdynatrace.SingleSignOnStatesEnable), + // SingleSignOnURL: to.Ptr("https://www.dynatrace.io/IAmSomeHash"), + // }, + // UserID: to.Ptr("alice123"), + // }, + // LiftrResourceCategory: to.Ptr(armdynatrace.LiftrResourceCategoriesUnknown), + // LiftrResourcePreference: to.Ptr[int32](28), + // MarketplaceSubscriptionStatus: to.Ptr(armdynatrace.MarketplaceSubscriptionStatusActive), + // MonitoringStatus: to.Ptr(armdynatrace.MonitoringStatusEnabled), + // PlanData: &armdynatrace.PlanData{ + // BillingCycle: to.Ptr("Monthly"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-30T15:14:33+02:00"); return t}()), + // PlanDetails: to.Ptr("dynatraceapitestplan"), + // UsageType: to.Ptr("Committed"), + // }, + // ProvisioningState: to.Ptr(armdynatrace.ProvisioningStateSucceeded), + // UserInfo: &armdynatrace.UserInfo{ + // Country: to.Ptr("westus2"), + // EmailAddress: to.Ptr("alice@microsoft.com"), + // FirstName: to.Ptr("Alice"), + // LastName: to.Ptr("Bobab"), + // PhoneNumber: to.Ptr("123456"), + // }, + // }, + // SystemData: &armdynatrace.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // CreatedBy: to.Ptr("alice@microsoft.com"), + // CreatedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // LastModifiedBy: to.Ptr("alice@microsoft.com"), + // LastModifiedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_CreateOrUpdate_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_CreateOrUpdate_MinimumSet_Gen.json func ExampleMonitorsClient_BeginCreateOrUpdate_monitorsCreateOrUpdateMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "myResourceGroup", "myMonitor", armdynatrace.MonitorResource{ + poller, err := clientFactory.NewMonitorsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myMonitor", armdynatrace.MonitorResource{ Location: to.Ptr("West US 2"), Properties: &armdynatrace.MonitorProperties{}, }, nil) @@ -258,22 +420,28 @@ func ExampleMonitorsClient_BeginCreateOrUpdate_monitorsCreateOrUpdateMinimumSetG 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.MonitorResource = armdynatrace.MonitorResource{ + // Location: to.Ptr("West US 2"), + // Properties: &armdynatrace.MonitorProperties{ + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_Update_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_Update_MaximumSet_Gen.json func ExampleMonitorsClient_Update_monitorsUpdateMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "myResourceGroup", "myMonitor", armdynatrace.MonitorResourceUpdate{ + res, err := clientFactory.NewMonitorsClient().Update(ctx, "myResourceGroup", "myMonitor", armdynatrace.MonitorResourceUpdate{ DynatraceEnvironmentProperties: &armdynatrace.EnvironmentProperties{ AccountInfo: &armdynatrace.AccountInfo{}, EnvironmentInfo: &armdynatrace.EnvironmentInfo{}, @@ -301,41 +469,110 @@ func ExampleMonitorsClient_Update_monitorsUpdateMaximumSetGen() { 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.MonitorResource = armdynatrace.MonitorResource{ + // Name: to.Ptr("myMonitor"), + // Type: to.Ptr("Dynatrace.Observability/monitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor"), + // Location: to.Ptr("West US 2"), + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // Identity: &armdynatrace.IdentityProperties{ + // Type: to.Ptr(armdynatrace.ManagedIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("4534676867978"), + // TenantID: to.Ptr("23456789001"), + // }, + // Properties: &armdynatrace.MonitorProperties{ + // DynatraceEnvironmentProperties: &armdynatrace.EnvironmentProperties{ + // AccountInfo: &armdynatrace.AccountInfo{ + // AccountID: to.Ptr("1234567890"), + // RegionID: to.Ptr("wus2"), + // }, + // EnvironmentInfo: &armdynatrace.EnvironmentInfo{ + // EnvironmentID: to.Ptr("a23xcv456"), + // IngestionKey: to.Ptr("1234567890"), + // LandingURL: to.Ptr("https://a23xcv456.dynatrace.com"), + // LogsIngestionEndpoint: to.Ptr("https://dynatrace.com"), + // }, + // SingleSignOnProperties: &armdynatrace.SingleSignOnProperties{ + // AADDomains: []*string{ + // to.Ptr("mpliftrdt20210811outlook.onmicrosoft.com")}, + // EnterpriseAppID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // SingleSignOnState: to.Ptr(armdynatrace.SingleSignOnStatesEnable), + // SingleSignOnURL: to.Ptr("https://www.dynatrace.io/IAmSomeHash"), + // }, + // UserID: to.Ptr("alice123"), + // }, + // LiftrResourceCategory: to.Ptr(armdynatrace.LiftrResourceCategoriesUnknown), + // LiftrResourcePreference: to.Ptr[int32](28), + // MarketplaceSubscriptionStatus: to.Ptr(armdynatrace.MarketplaceSubscriptionStatusActive), + // MonitoringStatus: to.Ptr(armdynatrace.MonitoringStatusEnabled), + // PlanData: &armdynatrace.PlanData{ + // BillingCycle: to.Ptr("Monthly"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-30T15:14:33+02:00"); return t}()), + // PlanDetails: to.Ptr("dynatraceapitestplan"), + // UsageType: to.Ptr("Committed"), + // }, + // ProvisioningState: to.Ptr(armdynatrace.ProvisioningStateSucceeded), + // UserInfo: &armdynatrace.UserInfo{ + // Country: to.Ptr("westus2"), + // EmailAddress: to.Ptr("alice@microsoft.com"), + // FirstName: to.Ptr("Alice"), + // LastName: to.Ptr("Bobab"), + // PhoneNumber: to.Ptr("123456"), + // }, + // }, + // SystemData: &armdynatrace.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // CreatedBy: to.Ptr("alice@microsoft.com"), + // CreatedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // LastModifiedBy: to.Ptr("alice@microsoft.com"), + // LastModifiedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_Update_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_Update_MinimumSet_Gen.json func ExampleMonitorsClient_Update_monitorsUpdateMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "myResourceGroup", "myMonitor", armdynatrace.MonitorResourceUpdate{}, nil) + res, err := clientFactory.NewMonitorsClient().Update(ctx, "myResourceGroup", "myMonitor", armdynatrace.MonitorResourceUpdate{}, 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.MonitorResource = armdynatrace.MonitorResource{ + // Location: to.Ptr("West US 2"), + // Properties: &armdynatrace.MonitorProperties{ + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_Delete_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_Delete_MaximumSet_Gen.json func ExampleMonitorsClient_BeginDelete_monitorsDeleteMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "myResourceGroup", "myMonitor", nil) + poller, err := clientFactory.NewMonitorsClient().BeginDelete(ctx, "myResourceGroup", "myMonitor", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -345,18 +582,18 @@ func ExampleMonitorsClient_BeginDelete_monitorsDeleteMaximumSetGen() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_Delete_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_Delete_MinimumSet_Gen.json func ExampleMonitorsClient_BeginDelete_monitorsDeleteMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "myResourceGroup", "myMonitor", nil) + poller, err := clientFactory.NewMonitorsClient().BeginDelete(ctx, "myResourceGroup", "myMonitor", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -366,287 +603,503 @@ func ExampleMonitorsClient_BeginDelete_monitorsDeleteMinimumSetGen() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListBySubscriptionId_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListBySubscriptionId_MaximumSet_Gen.json func ExampleMonitorsClient_NewListBySubscriptionIDPager_monitorsListBySubscriptionIdMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySubscriptionIDPager(nil) + pager := clientFactory.NewMonitorsClient().NewListBySubscriptionIDPager(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.MonitorResourceListResult = armdynatrace.MonitorResourceListResult{ + // Value: []*armdynatrace.MonitorResource{ + // { + // Name: to.Ptr("myMonitor"), + // Type: to.Ptr("Dynatrace.Observability/monitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor"), + // Location: to.Ptr("West US 2"), + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // Identity: &armdynatrace.IdentityProperties{ + // Type: to.Ptr(armdynatrace.ManagedIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("4534676867978"), + // TenantID: to.Ptr("23456789001"), + // }, + // Properties: &armdynatrace.MonitorProperties{ + // DynatraceEnvironmentProperties: &armdynatrace.EnvironmentProperties{ + // AccountInfo: &armdynatrace.AccountInfo{ + // AccountID: to.Ptr("1234567890"), + // RegionID: to.Ptr("wus2"), + // }, + // EnvironmentInfo: &armdynatrace.EnvironmentInfo{ + // EnvironmentID: to.Ptr("a23xcv456"), + // IngestionKey: to.Ptr("1234567890"), + // LandingURL: to.Ptr("https://a23xcv456.dynatrace.com"), + // LogsIngestionEndpoint: to.Ptr("https://dynatrace.com"), + // }, + // SingleSignOnProperties: &armdynatrace.SingleSignOnProperties{ + // AADDomains: []*string{ + // to.Ptr("mpliftrdt20210811outlook.onmicrosoft.com")}, + // EnterpriseAppID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // SingleSignOnState: to.Ptr(armdynatrace.SingleSignOnStatesEnable), + // SingleSignOnURL: to.Ptr("https://www.dynatrace.io/IAmSomeHash"), + // }, + // UserID: to.Ptr("alice123"), + // }, + // LiftrResourceCategory: to.Ptr(armdynatrace.LiftrResourceCategoriesUnknown), + // LiftrResourcePreference: to.Ptr[int32](28), + // MarketplaceSubscriptionStatus: to.Ptr(armdynatrace.MarketplaceSubscriptionStatusActive), + // MonitoringStatus: to.Ptr(armdynatrace.MonitoringStatusEnabled), + // PlanData: &armdynatrace.PlanData{ + // BillingCycle: to.Ptr("Monthly"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-30T15:14:33+02:00"); return t}()), + // PlanDetails: to.Ptr("dynatraceapitestplan"), + // UsageType: to.Ptr("Committed"), + // }, + // ProvisioningState: to.Ptr(armdynatrace.ProvisioningStateSucceeded), + // UserInfo: &armdynatrace.UserInfo{ + // Country: to.Ptr("westus2"), + // EmailAddress: to.Ptr("alice@microsoft.com"), + // FirstName: to.Ptr("Alice"), + // LastName: to.Ptr("Bobab"), + // PhoneNumber: to.Ptr("123456"), + // }, + // }, + // SystemData: &armdynatrace.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // CreatedBy: to.Ptr("alice@microsoft.com"), + // CreatedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // LastModifiedBy: to.Ptr("alice@microsoft.com"), + // LastModifiedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListBySubscriptionId_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListBySubscriptionId_MinimumSet_Gen.json func ExampleMonitorsClient_NewListBySubscriptionIDPager_monitorsListBySubscriptionIdMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySubscriptionIDPager(nil) + pager := clientFactory.NewMonitorsClient().NewListBySubscriptionIDPager(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.MonitorResourceListResult = armdynatrace.MonitorResourceListResult{ + // Value: []*armdynatrace.MonitorResource{ + // { + // Location: to.Ptr("West US 2"), + // Properties: &armdynatrace.MonitorProperties{ + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListByResourceGroup_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListByResourceGroup_MaximumSet_Gen.json func ExampleMonitorsClient_NewListByResourceGroupPager_monitorsListByResourceGroupMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("myResourceGroup", nil) + pager := clientFactory.NewMonitorsClient().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.MonitorResourceListResult = armdynatrace.MonitorResourceListResult{ + // Value: []*armdynatrace.MonitorResource{ + // { + // Name: to.Ptr("myMonitor"), + // Type: to.Ptr("Dynatrace.Observability/monitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor"), + // Location: to.Ptr("West US 2"), + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // Identity: &armdynatrace.IdentityProperties{ + // Type: to.Ptr(armdynatrace.ManagedIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("4534676867978"), + // TenantID: to.Ptr("23456789001"), + // }, + // Properties: &armdynatrace.MonitorProperties{ + // DynatraceEnvironmentProperties: &armdynatrace.EnvironmentProperties{ + // AccountInfo: &armdynatrace.AccountInfo{ + // AccountID: to.Ptr("1234567890"), + // RegionID: to.Ptr("wus2"), + // }, + // EnvironmentInfo: &armdynatrace.EnvironmentInfo{ + // EnvironmentID: to.Ptr("a23xcv456"), + // IngestionKey: to.Ptr("1234567890"), + // LandingURL: to.Ptr("https://a23xcv456.dynatrace.com"), + // LogsIngestionEndpoint: to.Ptr("https://dynatrace.com"), + // }, + // SingleSignOnProperties: &armdynatrace.SingleSignOnProperties{ + // AADDomains: []*string{ + // to.Ptr("mpliftrdt20210811outlook.onmicrosoft.com")}, + // EnterpriseAppID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // SingleSignOnState: to.Ptr(armdynatrace.SingleSignOnStatesEnable), + // SingleSignOnURL: to.Ptr("https://www.dynatrace.io/IAmSomeHash"), + // }, + // UserID: to.Ptr("alice123"), + // }, + // LiftrResourceCategory: to.Ptr(armdynatrace.LiftrResourceCategoriesUnknown), + // LiftrResourcePreference: to.Ptr[int32](28), + // MarketplaceSubscriptionStatus: to.Ptr(armdynatrace.MarketplaceSubscriptionStatusActive), + // MonitoringStatus: to.Ptr(armdynatrace.MonitoringStatusEnabled), + // PlanData: &armdynatrace.PlanData{ + // BillingCycle: to.Ptr("Monthly"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-30T15:14:33+02:00"); return t}()), + // PlanDetails: to.Ptr("dynatraceapitestplan"), + // UsageType: to.Ptr("Committed"), + // }, + // ProvisioningState: to.Ptr(armdynatrace.ProvisioningStateSucceeded), + // UserInfo: &armdynatrace.UserInfo{ + // Country: to.Ptr("westus2"), + // EmailAddress: to.Ptr("alice@microsoft.com"), + // FirstName: to.Ptr("Alice"), + // LastName: to.Ptr("Bobab"), + // PhoneNumber: to.Ptr("123456"), + // }, + // }, + // SystemData: &armdynatrace.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // CreatedBy: to.Ptr("alice@microsoft.com"), + // CreatedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // LastModifiedBy: to.Ptr("alice@microsoft.com"), + // LastModifiedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListByResourceGroup_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListByResourceGroup_MinimumSet_Gen.json func ExampleMonitorsClient_NewListByResourceGroupPager_monitorsListByResourceGroupMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("myResourceGroup", nil) + pager := clientFactory.NewMonitorsClient().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.MonitorResourceListResult = armdynatrace.MonitorResourceListResult{ + // Value: []*armdynatrace.MonitorResource{ + // { + // Location: to.Ptr("West US 2"), + // Properties: &armdynatrace.MonitorProperties{ + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListHosts_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListHosts_MaximumSet_Gen.json func ExampleMonitorsClient_NewListHostsPager_monitorsListHostsMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListHostsPager("myResourceGroup", "myMonitor", nil) + pager := clientFactory.NewMonitorsClient().NewListHostsPager("myResourceGroup", "myMonitor", 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.VMHostsListResponse = armdynatrace.VMHostsListResponse{ + // Value: []*armdynatrace.VMInfo{ + // { + // AutoUpdateSetting: to.Ptr(armdynatrace.AutoUpdateSettingENABLED), + // AvailabilityState: to.Ptr(armdynatrace.AvailabilityStateCRASHED), + // HostGroup: to.Ptr("myGroup"), + // HostName: to.Ptr("myName"), + // LogModule: to.Ptr(armdynatrace.LogModuleENABLED), + // MonitoringType: to.Ptr(armdynatrace.MonitoringTypeCLOUDINFRASTRUCTURE), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/virtual1"), + // UpdateStatus: to.Ptr(armdynatrace.UpdateStatusINCOMPATIBLE), + // Version: to.Ptr("1.2.0"), + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListHosts_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListHosts_MinimumSet_Gen.json func ExampleMonitorsClient_NewListHostsPager_monitorsListHostsMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListHostsPager("myResourceGroup", "myMonitor", nil) + pager := clientFactory.NewMonitorsClient().NewListHostsPager("myResourceGroup", "myMonitor", 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.VMHostsListResponse = armdynatrace.VMHostsListResponse{ + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListAppServices_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListAppServices_MaximumSet_Gen.json func ExampleMonitorsClient_NewListAppServicesPager_monitorsListAppServicesMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListAppServicesPager("myResourceGroup", "myMonitor", nil) + pager := clientFactory.NewMonitorsClient().NewListAppServicesPager("myResourceGroup", "myMonitor", 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.AppServiceListResponse = armdynatrace.AppServiceListResponse{ + // Value: []*armdynatrace.AppServiceInfo{ + // { + // AutoUpdateSetting: to.Ptr(armdynatrace.AutoUpdateSettingENABLED), + // AvailabilityState: to.Ptr(armdynatrace.AvailabilityStateCRASHED), + // HostGroup: to.Ptr("myGroup"), + // HostName: to.Ptr("myName"), + // LogModule: to.Ptr(armdynatrace.LogModuleENABLED), + // MonitoringType: to.Ptr(armdynatrace.MonitoringTypeCLOUDINFRASTRUCTURE), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/virtual1"), + // UpdateStatus: to.Ptr(armdynatrace.UpdateStatusINCOMPATIBLE), + // Version: to.Ptr("1.2.0"), + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListAppServices_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListAppServices_MinimumSet_Gen.json func ExampleMonitorsClient_NewListAppServicesPager_monitorsListAppServicesMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListAppServicesPager("myResourceGroup", "myMonitor", nil) + pager := clientFactory.NewMonitorsClient().NewListAppServicesPager("myResourceGroup", "myMonitor", 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.AppServiceListResponse = armdynatrace.AppServiceListResponse{ + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_GetSSODetails_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_GetSSODetails_MaximumSet_Gen.json func ExampleMonitorsClient_GetSSODetails_monitorsGetSsoDetailsMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GetSSODetails(ctx, "myResourceGroup", "myMonitor", &armdynatrace.MonitorsClientGetSSODetailsOptions{Request: &armdynatrace.SSODetailsRequest{ + res, err := clientFactory.NewMonitorsClient().GetSSODetails(ctx, "myResourceGroup", "myMonitor", &armdynatrace.MonitorsClientGetSSODetailsOptions{Request: &armdynatrace.SSODetailsRequest{ UserPrincipal: to.Ptr("alice@microsoft.com"), }, }) 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.SSODetailsResponse = armdynatrace.SSODetailsResponse{ + // AADDomains: []*string{ + // to.Ptr("mpliftrdt20210811outlook.onmicrosoft.com")}, + // AdminUsers: []*string{ + // to.Ptr("alice@microsoft.com")}, + // IsSsoEnabled: to.Ptr(armdynatrace.SSOStatusEnabled), + // MetadataURL: to.Ptr("https://someuri"), + // SingleSignOnURL: to.Ptr("https://www.dynatrace.io/IAmSomeHash"), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_GetSSODetails_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_GetSSODetails_MinimumSet_Gen.json func ExampleMonitorsClient_GetSSODetails_monitorsGetSsoDetailsMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GetSSODetails(ctx, "myResourceGroup", "myMonitor", &armdynatrace.MonitorsClientGetSSODetailsOptions{Request: &armdynatrace.SSODetailsRequest{}}) + res, err := clientFactory.NewMonitorsClient().GetSSODetails(ctx, "myResourceGroup", "myMonitor", &armdynatrace.MonitorsClientGetSSODetailsOptions{Request: &armdynatrace.SSODetailsRequest{}}) 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.SSODetailsResponse = armdynatrace.SSODetailsResponse{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListLinkableEnvironments_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListLinkableEnvironments_MaximumSet_Gen.json func ExampleMonitorsClient_NewListLinkableEnvironmentsPager_monitorsListLinkableEnvironmentsMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListLinkableEnvironmentsPager("myResourceGroup", "myMonitor", armdynatrace.LinkableEnvironmentRequest{ + pager := clientFactory.NewMonitorsClient().NewListLinkableEnvironmentsPager("myResourceGroup", "myMonitor", armdynatrace.LinkableEnvironmentRequest{ Region: to.Ptr("East US"), TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), UserPrincipal: to.Ptr("alice@microsoft.com"), }, 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.LinkableEnvironmentListResponse = armdynatrace.LinkableEnvironmentListResponse{ + // Value: []*armdynatrace.LinkableEnvironmentResponse{ + // { + // EnvironmentID: to.Ptr("abc.123"), + // EnvironmentName: to.Ptr("myEnv"), + // PlanData: &armdynatrace.PlanData{ + // BillingCycle: to.Ptr("Monthly"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-30T15:14:33+02:00"); return t}()), + // PlanDetails: to.Ptr("dynatraceapitestplan"), + // UsageType: to.Ptr("Committed"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListLinkableEnvironments_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Monitors_ListLinkableEnvironments_MinimumSet_Gen.json func ExampleMonitorsClient_NewListLinkableEnvironmentsPager_monitorsListLinkableEnvironmentsMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListLinkableEnvironmentsPager("myResourceGroup", "myMonitor", armdynatrace.LinkableEnvironmentRequest{}, nil) + pager := clientFactory.NewMonitorsClient().NewListLinkableEnvironmentsPager("myResourceGroup", "myMonitor", armdynatrace.LinkableEnvironmentRequest{}, 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.LinkableEnvironmentListResponse = armdynatrace.LinkableEnvironmentListResponse{ + // } } } diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/operations_client.go b/sdk/resourcemanager/dynatrace/armdynatrace/operations_client.go index 2ef6742e964c..bc50df35ca9c 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/operations_client.go +++ b/sdk/resourcemanager/dynatrace/armdynatrace/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 the operations for Dynatrace.Observability +// // Generated from API version 2021-09-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/Dynatrace.Observability/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/dynatrace/armdynatrace/operations_client_example_test.go b/sdk/resourcemanager/dynatrace/armdynatrace/operations_client_example_test.go index 9453788c33e7..b9f92907218f 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/operations_client_example_test.go +++ b/sdk/resourcemanager/dynatrace/armdynatrace/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 armdynatrace_test @@ -16,50 +17,69 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dynatrace/armdynatrace" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Operations_List_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Operations_List_MaximumSet_Gen.json func ExampleOperationsClient_NewListPager_operationsListMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewOperationsClient(cred, nil) + clientFactory, err := armdynatrace.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 = armdynatrace.OperationListResult{ + // Value: []*armdynatrace.Operation{ + // { + // Name: to.Ptr("Dynatrace.Observability/monitors/write"), + // ActionType: to.Ptr(armdynatrace.ActionTypeInternal), + // Display: &armdynatrace.OperationDisplay{ + // Description: to.Ptr("Write monitors resource"), + // Operation: to.Ptr("write"), + // Provider: to.Ptr("Dynatrace.Observability"), + // Resource: to.Ptr("monitors"), + // }, + // IsDataAction: to.Ptr(true), + // Origin: to.Ptr(armdynatrace.OriginUser), + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Operations_List_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/Operations_List_MinimumSet_Gen.json func ExampleOperationsClient_NewListPager_operationsListMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewOperationsClient(cred, nil) + clientFactory, err := armdynatrace.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 = armdynatrace.OperationListResult{ + // } } } diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/response_types.go b/sdk/resourcemanager/dynatrace/armdynatrace/response_types.go index dd886be0ecfd..f8d27e7038ce 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/response_types.go +++ b/sdk/resourcemanager/dynatrace/armdynatrace/response_types.go @@ -9,12 +9,12 @@ package armdynatrace -// MonitorsClientCreateOrUpdateResponse contains the response from method MonitorsClient.CreateOrUpdate. +// MonitorsClientCreateOrUpdateResponse contains the response from method MonitorsClient.BeginCreateOrUpdate. type MonitorsClientCreateOrUpdateResponse struct { MonitorResource } -// MonitorsClientDeleteResponse contains the response from method MonitorsClient.Delete. +// MonitorsClientDeleteResponse contains the response from method MonitorsClient.BeginDelete. type MonitorsClientDeleteResponse struct { // placeholder for future response values } @@ -39,32 +39,32 @@ type MonitorsClientGetVMHostPayloadResponse struct { VMExtensionPayload } -// MonitorsClientListAppServicesResponse contains the response from method MonitorsClient.ListAppServices. +// MonitorsClientListAppServicesResponse contains the response from method MonitorsClient.NewListAppServicesPager. type MonitorsClientListAppServicesResponse struct { AppServiceListResponse } -// MonitorsClientListByResourceGroupResponse contains the response from method MonitorsClient.ListByResourceGroup. +// MonitorsClientListByResourceGroupResponse contains the response from method MonitorsClient.NewListByResourceGroupPager. type MonitorsClientListByResourceGroupResponse struct { MonitorResourceListResult } -// MonitorsClientListBySubscriptionIDResponse contains the response from method MonitorsClient.ListBySubscriptionID. +// MonitorsClientListBySubscriptionIDResponse contains the response from method MonitorsClient.NewListBySubscriptionIDPager. type MonitorsClientListBySubscriptionIDResponse struct { MonitorResourceListResult } -// MonitorsClientListHostsResponse contains the response from method MonitorsClient.ListHosts. +// MonitorsClientListHostsResponse contains the response from method MonitorsClient.NewListHostsPager. type MonitorsClientListHostsResponse struct { VMHostsListResponse } -// MonitorsClientListLinkableEnvironmentsResponse contains the response from method MonitorsClient.ListLinkableEnvironments. +// MonitorsClientListLinkableEnvironmentsResponse contains the response from method MonitorsClient.NewListLinkableEnvironmentsPager. type MonitorsClientListLinkableEnvironmentsResponse struct { LinkableEnvironmentListResponse } -// MonitorsClientListMonitoredResourcesResponse contains the response from method MonitorsClient.ListMonitoredResources. +// MonitorsClientListMonitoredResourcesResponse contains the response from method MonitorsClient.NewListMonitoredResourcesPager. type MonitorsClientListMonitoredResourcesResponse struct { MonitoredResourceListResponse } @@ -74,12 +74,12 @@ type MonitorsClientUpdateResponse struct { MonitorResource } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult } -// SingleSignOnClientCreateOrUpdateResponse contains the response from method SingleSignOnClient.CreateOrUpdate. +// SingleSignOnClientCreateOrUpdateResponse contains the response from method SingleSignOnClient.BeginCreateOrUpdate. type SingleSignOnClientCreateOrUpdateResponse struct { SingleSignOnResource } @@ -89,17 +89,17 @@ type SingleSignOnClientGetResponse struct { SingleSignOnResource } -// SingleSignOnClientListResponse contains the response from method SingleSignOnClient.List. +// SingleSignOnClientListResponse contains the response from method SingleSignOnClient.NewListPager. type SingleSignOnClientListResponse struct { SingleSignOnResourceListResult } -// TagRulesClientCreateOrUpdateResponse contains the response from method TagRulesClient.CreateOrUpdate. +// TagRulesClientCreateOrUpdateResponse contains the response from method TagRulesClient.BeginCreateOrUpdate. type TagRulesClientCreateOrUpdateResponse struct { TagRule } -// TagRulesClientDeleteResponse contains the response from method TagRulesClient.Delete. +// TagRulesClientDeleteResponse contains the response from method TagRulesClient.BeginDelete. type TagRulesClientDeleteResponse struct { // placeholder for future response values } @@ -109,7 +109,7 @@ type TagRulesClientGetResponse struct { TagRule } -// TagRulesClientListResponse contains the response from method TagRulesClient.List. +// TagRulesClientListResponse contains the response from method TagRulesClient.NewListPager. type TagRulesClientListResponse struct { TagRuleListResult } diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/singlesignon_client.go b/sdk/resourcemanager/dynatrace/armdynatrace/singlesignon_client.go index 5b3f36765718..44c1389e0419 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/singlesignon_client.go +++ b/sdk/resourcemanager/dynatrace/armdynatrace/singlesignon_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 ( // SingleSignOnClient contains the methods for the SingleSignOn group. // Don't use this type directly, use NewSingleSignOnClient() instead. type SingleSignOnClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSingleSignOnClient creates a new instance of SingleSignOnClient 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 NewSingleSignOnClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SingleSignOnClient, 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+".SingleSignOnClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SingleSignOnClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create a DynatraceSingleSignOnResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// configurationName - Single Sign On Configuration Name -// resource - Resource create parameters. -// options - SingleSignOnClientBeginCreateOrUpdateOptions contains the optional parameters for the SingleSignOnClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - configurationName - Single Sign On Configuration Name +// - resource - Resource create parameters. +// - options - SingleSignOnClientBeginCreateOrUpdateOptions contains the optional parameters for the SingleSignOnClient.BeginCreateOrUpdate +// method. func (client *SingleSignOnClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, configurationName string, resource SingleSignOnResource, options *SingleSignOnClientBeginCreateOrUpdateOptions) (*runtime.Poller[SingleSignOnClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, monitorName, configurationName, resource, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SingleSignOnClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SingleSignOnClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[SingleSignOnClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SingleSignOnClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create a DynatraceSingleSignOnResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 func (client *SingleSignOnClient) createOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, configurationName string, resource SingleSignOnResource, options *SingleSignOnClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, monitorName, configurationName, resource, 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 *SingleSignOnClient) createOrUpdateCreateRequest(ctx context.Contex 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 } @@ -128,17 +119,18 @@ func (client *SingleSignOnClient) createOrUpdateCreateRequest(ctx context.Contex // Get - Get a DynatraceSingleSignOnResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// configurationName - Single Sign On Configuration Name -// options - SingleSignOnClientGetOptions contains the optional parameters for the SingleSignOnClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - configurationName - Single Sign On Configuration Name +// - options - SingleSignOnClientGetOptions contains the optional parameters for the SingleSignOnClient.Get method. func (client *SingleSignOnClient) Get(ctx context.Context, resourceGroupName string, monitorName string, configurationName string, options *SingleSignOnClientGetOptions) (SingleSignOnClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, monitorName, configurationName, options) if err != nil { return SingleSignOnClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SingleSignOnClientGetResponse{}, err } @@ -167,7 +159,7 @@ func (client *SingleSignOnClient) getCreateRequest(ctx context.Context, resource 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 } @@ -188,10 +180,11 @@ func (client *SingleSignOnClient) getHandleResponse(resp *http.Response) (Single } // NewListPager - List all DynatraceSingleSignOnResource by monitorName +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// options - SingleSignOnClientListOptions contains the optional parameters for the SingleSignOnClient.List method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - options - SingleSignOnClientListOptions contains the optional parameters for the SingleSignOnClient.NewListPager method. func (client *SingleSignOnClient) NewListPager(resourceGroupName string, monitorName string, options *SingleSignOnClientListOptions) *runtime.Pager[SingleSignOnClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SingleSignOnClientListResponse]{ More: func(page SingleSignOnClientListResponse) bool { @@ -208,7 +201,7 @@ func (client *SingleSignOnClient) NewListPager(resourceGroupName string, monitor if err != nil { return SingleSignOnClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SingleSignOnClientListResponse{}, err } @@ -235,7 +228,7 @@ func (client *SingleSignOnClient) listCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - 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/dynatrace/armdynatrace/singlesignon_client_example_test.go b/sdk/resourcemanager/dynatrace/armdynatrace/singlesignon_client_example_test.go index 5de8f1c6a3e3..858606ad4812 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/singlesignon_client_example_test.go +++ b/sdk/resourcemanager/dynatrace/armdynatrace/singlesignon_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 armdynatrace_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dynatrace/armdynatrace" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/SingleSignOn_CreateOrUpdate_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/SingleSignOn_CreateOrUpdate_MaximumSet_Gen.json func ExampleSingleSignOnClient_BeginCreateOrUpdate_singleSignOnCreateOrUpdateMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewSingleSignOnClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "myResourceGroup", "myMonitor", "default", armdynatrace.SingleSignOnResource{ + poller, err := clientFactory.NewSingleSignOnClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myMonitor", "default", armdynatrace.SingleSignOnResource{ Properties: &armdynatrace.SingleSignOnProperties{ AADDomains: []*string{ to.Ptr("mpliftrdt20210811outlook.onmicrosoft.com")}, @@ -45,22 +46,44 @@ func ExampleSingleSignOnClient_BeginCreateOrUpdate_singleSignOnCreateOrUpdateMax 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.SingleSignOnResource = armdynatrace.SingleSignOnResource{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Dynatrace.Observability/monitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Dynatrace.Observability/monitors/myMonitor/singleSignOnConfigurations/default"), + // Properties: &armdynatrace.SingleSignOnProperties{ + // AADDomains: []*string{ + // to.Ptr("mpliftrdt20210811outlook.onmicrosoft.com")}, + // EnterpriseAppID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ProvisioningState: to.Ptr(armdynatrace.ProvisioningStateSucceeded), + // SingleSignOnState: to.Ptr(armdynatrace.SingleSignOnStatesEnable), + // SingleSignOnURL: to.Ptr("https://www.dynatrace.io/IAmSomeHash"), + // }, + // SystemData: &armdynatrace.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // CreatedBy: to.Ptr("alice@microsoft.com"), + // CreatedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // LastModifiedBy: to.Ptr("alice@microsoft.com"), + // LastModifiedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/SingleSignOn_CreateOrUpdate_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/SingleSignOn_CreateOrUpdate_MinimumSet_Gen.json func ExampleSingleSignOnClient_BeginCreateOrUpdate_singleSignOnCreateOrUpdateMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewSingleSignOnClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "myResourceGroup", "myMonitor", "default", armdynatrace.SingleSignOnResource{ + poller, err := clientFactory.NewSingleSignOnClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myMonitor", "default", armdynatrace.SingleSignOnResource{ Properties: &armdynatrace.SingleSignOnProperties{ AADDomains: []*string{ to.Ptr("mpliftrdt20210811outlook.onmicrosoft.com")}, @@ -74,92 +97,166 @@ func ExampleSingleSignOnClient_BeginCreateOrUpdate_singleSignOnCreateOrUpdateMin 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.SingleSignOnResource = armdynatrace.SingleSignOnResource{ + // Properties: &armdynatrace.SingleSignOnProperties{ + // AADDomains: []*string{ + // to.Ptr("mpliftrdt20210811outlook.onmicrosoft.com")}, + // SingleSignOnURL: to.Ptr("https://www.dynatrace.io/IAmSomeHash"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/SingleSignOn_Get_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/SingleSignOn_Get_MaximumSet_Gen.json func ExampleSingleSignOnClient_Get_singleSignOnGetMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewSingleSignOnClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myResourceGroup", "myMonitor", "default", nil) + res, err := clientFactory.NewSingleSignOnClient().Get(ctx, "myResourceGroup", "myMonitor", "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.SingleSignOnResource = armdynatrace.SingleSignOnResource{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Dynatrace.Observability/monitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Dynatrace.Observability/monitors/myMonitor/singleSignOnConfigurations/default"), + // Properties: &armdynatrace.SingleSignOnProperties{ + // AADDomains: []*string{ + // to.Ptr("mpliftrdt20210811outlook.onmicrosoft.com")}, + // EnterpriseAppID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ProvisioningState: to.Ptr(armdynatrace.ProvisioningStateSucceeded), + // SingleSignOnState: to.Ptr(armdynatrace.SingleSignOnStatesEnable), + // SingleSignOnURL: to.Ptr("https://www.dynatrace.io/IAmSomeHash"), + // }, + // SystemData: &armdynatrace.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // CreatedBy: to.Ptr("alice@microsoft.com"), + // CreatedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // LastModifiedBy: to.Ptr("alice@microsoft.com"), + // LastModifiedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/SingleSignOn_Get_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/SingleSignOn_Get_MinimumSet_Gen.json func ExampleSingleSignOnClient_Get_singleSignOnGetMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewSingleSignOnClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myResourceGroup", "myMonitor", "default", nil) + res, err := clientFactory.NewSingleSignOnClient().Get(ctx, "myResourceGroup", "myMonitor", "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.SingleSignOnResource = armdynatrace.SingleSignOnResource{ + // Properties: &armdynatrace.SingleSignOnProperties{ + // AADDomains: []*string{ + // to.Ptr("mpliftrdt20210811outlook.onmicrosoft.com")}, + // SingleSignOnURL: to.Ptr("https://www.dynatrace.io/IAmSomeHash"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/SingleSignOn_List_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/SingleSignOn_List_MaximumSet_Gen.json func ExampleSingleSignOnClient_NewListPager_singleSignOnListMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewSingleSignOnClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("myResourceGroup", "myMonitor", nil) + pager := clientFactory.NewSingleSignOnClient().NewListPager("myResourceGroup", "myMonitor", 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.SingleSignOnResourceListResult = armdynatrace.SingleSignOnResourceListResult{ + // Value: []*armdynatrace.SingleSignOnResource{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Dynatrace.Observability/monitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Dynatrace.Observability/monitors/myMonitor/singleSignOnConfigurations/default"), + // Properties: &armdynatrace.SingleSignOnProperties{ + // AADDomains: []*string{ + // to.Ptr("mpliftrdt20210811outlook.onmicrosoft.com")}, + // EnterpriseAppID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ProvisioningState: to.Ptr(armdynatrace.ProvisioningStateSucceeded), + // SingleSignOnState: to.Ptr(armdynatrace.SingleSignOnStatesEnable), + // SingleSignOnURL: to.Ptr("https://www.dynatrace.io/IAmSomeHash"), + // }, + // SystemData: &armdynatrace.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // CreatedBy: to.Ptr("alice@microsoft.com"), + // CreatedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // LastModifiedBy: to.Ptr("alice@microsoft.com"), + // LastModifiedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/SingleSignOn_List_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/SingleSignOn_List_MinimumSet_Gen.json func ExampleSingleSignOnClient_NewListPager_singleSignOnListMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewSingleSignOnClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("myResourceGroup", "myMonitor", nil) + pager := clientFactory.NewSingleSignOnClient().NewListPager("myResourceGroup", "myMonitor", 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.SingleSignOnResourceListResult = armdynatrace.SingleSignOnResourceListResult{ + // Value: []*armdynatrace.SingleSignOnResource{ + // { + // Properties: &armdynatrace.SingleSignOnProperties{ + // AADDomains: []*string{ + // to.Ptr("mpliftrdt20210811outlook.onmicrosoft.com")}, + // SingleSignOnURL: to.Ptr("https://www.dynatrace.io/IAmSomeHash"), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/tagrules_client.go b/sdk/resourcemanager/dynatrace/armdynatrace/tagrules_client.go index 7656dc5b6656..412633743421 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/tagrules_client.go +++ b/sdk/resourcemanager/dynatrace/armdynatrace/tagrules_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 ( // TagRulesClient contains the methods for the TagRules group. // Don't use this type directly, use NewTagRulesClient() instead. type TagRulesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTagRulesClient creates a new instance of TagRulesClient 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 NewTagRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TagRulesClient, 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+".TagRulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TagRulesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create a TagRule // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// ruleSetName - Monitor resource name -// resource - Resource create parameters. -// options - TagRulesClientBeginCreateOrUpdateOptions contains the optional parameters for the TagRulesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - ruleSetName - Monitor resource name +// - resource - Resource create parameters. +// - options - TagRulesClientBeginCreateOrUpdateOptions contains the optional parameters for the TagRulesClient.BeginCreateOrUpdate +// method. func (client *TagRulesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, resource TagRule, options *TagRulesClientBeginCreateOrUpdateOptions) (*runtime.Poller[TagRulesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, monitorName, ruleSetName, resource, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[TagRulesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TagRulesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[TagRulesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[TagRulesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create a TagRule // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 func (client *TagRulesClient) createOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, resource TagRule, options *TagRulesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, resource, 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 *TagRulesClient) createOrUpdateCreateRequest(ctx context.Context, r return nil, errors.New("parameter ruleSetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ruleSetName}", url.PathEscape(ruleSetName)) - 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 *TagRulesClient) createOrUpdateCreateRequest(ctx context.Context, r // BeginDelete - Delete a TagRule // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// ruleSetName - Monitor resource name -// options - TagRulesClientBeginDeleteOptions contains the optional parameters for the TagRulesClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - ruleSetName - Monitor resource name +// - options - TagRulesClientBeginDeleteOptions contains the optional parameters for the TagRulesClient.BeginDelete method. func (client *TagRulesClient) BeginDelete(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientBeginDeleteOptions) (*runtime.Poller[TagRulesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, monitorName, ruleSetName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[TagRulesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TagRulesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[TagRulesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[TagRulesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete a TagRule // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 func (client *TagRulesClient) deleteOperation(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, 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 *TagRulesClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter ruleSetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ruleSetName}", url.PathEscape(ruleSetName)) - 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 *TagRulesClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Get a TagRule // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// ruleSetName - Monitor resource name -// options - TagRulesClientGetOptions contains the optional parameters for the TagRulesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - ruleSetName - Monitor resource name +// - options - TagRulesClientGetOptions contains the optional parameters for the TagRulesClient.Get method. func (client *TagRulesClient) Get(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientGetOptions) (TagRulesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, options) if err != nil { return TagRulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TagRulesClientGetResponse{}, err } @@ -236,7 +230,7 @@ func (client *TagRulesClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter ruleSetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ruleSetName}", url.PathEscape(ruleSetName)) - 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,10 +251,11 @@ func (client *TagRulesClient) getHandleResponse(resp *http.Response) (TagRulesCl } // NewListPager - List all TagRule by monitorName +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// options - TagRulesClientListOptions contains the optional parameters for the TagRulesClient.List method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - options - TagRulesClientListOptions contains the optional parameters for the TagRulesClient.NewListPager method. func (client *TagRulesClient) NewListPager(resourceGroupName string, monitorName string, options *TagRulesClientListOptions) *runtime.Pager[TagRulesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TagRulesClientListResponse]{ More: func(page TagRulesClientListResponse) bool { @@ -277,7 +272,7 @@ func (client *TagRulesClient) NewListPager(resourceGroupName string, monitorName if err != nil { return TagRulesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TagRulesClientListResponse{}, err } @@ -304,7 +299,7 @@ func (client *TagRulesClient) listCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - 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 } @@ -326,18 +321,19 @@ func (client *TagRulesClient) listHandleResponse(resp *http.Response) (TagRulesC // Update - Update a TagRule // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// monitorName - Monitor resource name -// ruleSetName - Monitor resource name -// resource - The resource properties to be updated. -// options - TagRulesClientUpdateOptions contains the optional parameters for the TagRulesClient.Update method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - ruleSetName - Monitor resource name +// - resource - The resource properties to be updated. +// - options - TagRulesClientUpdateOptions contains the optional parameters for the TagRulesClient.Update method. func (client *TagRulesClient) Update(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, resource TagRuleUpdate, options *TagRulesClientUpdateOptions) (TagRulesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, resource, options) if err != nil { return TagRulesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TagRulesClientUpdateResponse{}, err } @@ -366,7 +362,7 @@ func (client *TagRulesClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter ruleSetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ruleSetName}", url.PathEscape(ruleSetName)) - 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/dynatrace/armdynatrace/tagrules_client_example_test.go b/sdk/resourcemanager/dynatrace/armdynatrace/tagrules_client_example_test.go index a356acbf523f..a62178e2eada 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/tagrules_client_example_test.go +++ b/sdk/resourcemanager/dynatrace/armdynatrace/tagrules_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 armdynatrace_test @@ -17,56 +18,102 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dynatrace/armdynatrace" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_Get_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_Get_MaximumSet_Gen.json func ExampleTagRulesClient_Get_tagRulesGetMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewTagRulesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myResourceGroup", "myMonitor", "default", nil) + res, err := clientFactory.NewTagRulesClient().Get(ctx, "myResourceGroup", "myMonitor", "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.TagRule = armdynatrace.TagRule{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Dynatrace.Observability/monitors/tagRules"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Dynatrace.Observability/monitors/myMonitor/tagRules/default"), + // Properties: &armdynatrace.MonitoringTagRulesProperties{ + // LogRules: &armdynatrace.LogRules{ + // FilteringTags: []*armdynatrace.FilteringTag{ + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armdynatrace.TagActionInclude), + // Value: to.Ptr("Prod"), + // }, + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armdynatrace.TagActionExclude), + // Value: to.Ptr("Dev"), + // }}, + // SendAADLogs: to.Ptr(armdynatrace.SendAADLogsStatusEnabled), + // SendActivityLogs: to.Ptr(armdynatrace.SendActivityLogsStatusEnabled), + // SendSubscriptionLogs: to.Ptr(armdynatrace.SendSubscriptionLogsStatusEnabled), + // }, + // MetricRules: &armdynatrace.MetricRules{ + // FilteringTags: []*armdynatrace.FilteringTag{ + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armdynatrace.TagActionInclude), + // Value: to.Ptr("Prod"), + // }}, + // }, + // ProvisioningState: to.Ptr(armdynatrace.ProvisioningStateSucceeded), + // }, + // SystemData: &armdynatrace.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // CreatedBy: to.Ptr("alice@microsoft.com"), + // CreatedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // LastModifiedBy: to.Ptr("alice@microsoft.com"), + // LastModifiedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_Get_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_Get_MinimumSet_Gen.json func ExampleTagRulesClient_Get_tagRulesGetMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewTagRulesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myResourceGroup", "myMonitor", "default", nil) + res, err := clientFactory.NewTagRulesClient().Get(ctx, "myResourceGroup", "myMonitor", "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.TagRule = armdynatrace.TagRule{ + // Properties: &armdynatrace.MonitoringTagRulesProperties{ + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_CreateOrUpdate_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_CreateOrUpdate_MaximumSet_Gen.json func ExampleTagRulesClient_BeginCreateOrUpdate_tagRulesCreateOrUpdateMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewTagRulesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "myResourceGroup", "myMonitor", "default", armdynatrace.TagRule{ + poller, err := clientFactory.NewTagRulesClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myMonitor", "default", armdynatrace.TagRule{ Properties: &armdynatrace.MonitoringTagRulesProperties{ LogRules: &armdynatrace.LogRules{ FilteringTags: []*armdynatrace.FilteringTag{ @@ -102,22 +149,63 @@ func ExampleTagRulesClient_BeginCreateOrUpdate_tagRulesCreateOrUpdateMaximumSetG 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.TagRule = armdynatrace.TagRule{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Dynatrace.Observability/monitors/tagRules"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Dynatrace.Observability/monitors/myMonitor/tagRules/default"), + // Properties: &armdynatrace.MonitoringTagRulesProperties{ + // LogRules: &armdynatrace.LogRules{ + // FilteringTags: []*armdynatrace.FilteringTag{ + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armdynatrace.TagActionInclude), + // Value: to.Ptr("Prod"), + // }, + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armdynatrace.TagActionExclude), + // Value: to.Ptr("Dev"), + // }}, + // SendAADLogs: to.Ptr(armdynatrace.SendAADLogsStatusEnabled), + // SendActivityLogs: to.Ptr(armdynatrace.SendActivityLogsStatusEnabled), + // SendSubscriptionLogs: to.Ptr(armdynatrace.SendSubscriptionLogsStatusEnabled), + // }, + // MetricRules: &armdynatrace.MetricRules{ + // FilteringTags: []*armdynatrace.FilteringTag{ + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armdynatrace.TagActionInclude), + // Value: to.Ptr("Prod"), + // }}, + // }, + // ProvisioningState: to.Ptr(armdynatrace.ProvisioningStateSucceeded), + // }, + // SystemData: &armdynatrace.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // CreatedBy: to.Ptr("alice@microsoft.com"), + // CreatedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // LastModifiedBy: to.Ptr("alice@microsoft.com"), + // LastModifiedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_CreateOrUpdate_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_CreateOrUpdate_MinimumSet_Gen.json func ExampleTagRulesClient_BeginCreateOrUpdate_tagRulesCreateOrUpdateMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewTagRulesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "myResourceGroup", "myMonitor", "default", armdynatrace.TagRule{ + poller, err := clientFactory.NewTagRulesClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myMonitor", "default", armdynatrace.TagRule{ Properties: &armdynatrace.MonitoringTagRulesProperties{}, }, nil) if err != nil { @@ -127,22 +215,27 @@ func ExampleTagRulesClient_BeginCreateOrUpdate_tagRulesCreateOrUpdateMinimumSetG 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.TagRule = armdynatrace.TagRule{ + // Properties: &armdynatrace.MonitoringTagRulesProperties{ + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_Update_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_Update_MaximumSet_Gen.json func ExampleTagRulesClient_Update_tagRulesUpdateMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewTagRulesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "myResourceGroup", "myMonitor", "default", armdynatrace.TagRuleUpdate{ + res, err := clientFactory.NewTagRulesClient().Update(ctx, "myResourceGroup", "myMonitor", "default", armdynatrace.TagRuleUpdate{ LogRules: &armdynatrace.LogRules{ FilteringTags: []*armdynatrace.FilteringTag{ { @@ -171,41 +264,87 @@ func ExampleTagRulesClient_Update_tagRulesUpdateMaximumSetGen() { 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.TagRule = armdynatrace.TagRule{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Dynatrace.Observability/monitors/tagRules"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Dynatrace.Observability/monitors/myMonitor/tagRules/default"), + // Properties: &armdynatrace.MonitoringTagRulesProperties{ + // LogRules: &armdynatrace.LogRules{ + // FilteringTags: []*armdynatrace.FilteringTag{ + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armdynatrace.TagActionInclude), + // Value: to.Ptr("Prod"), + // }, + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armdynatrace.TagActionExclude), + // Value: to.Ptr("Dev"), + // }}, + // SendAADLogs: to.Ptr(armdynatrace.SendAADLogsStatusEnabled), + // SendActivityLogs: to.Ptr(armdynatrace.SendActivityLogsStatusEnabled), + // SendSubscriptionLogs: to.Ptr(armdynatrace.SendSubscriptionLogsStatusEnabled), + // }, + // MetricRules: &armdynatrace.MetricRules{ + // FilteringTags: []*armdynatrace.FilteringTag{ + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armdynatrace.TagActionInclude), + // Value: to.Ptr("Prod"), + // }}, + // }, + // ProvisioningState: to.Ptr(armdynatrace.ProvisioningStateSucceeded), + // }, + // SystemData: &armdynatrace.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // CreatedBy: to.Ptr("alice@microsoft.com"), + // CreatedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // LastModifiedBy: to.Ptr("alice@microsoft.com"), + // LastModifiedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_Update_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_Update_MinimumSet_Gen.json func ExampleTagRulesClient_Update_tagRulesUpdateMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewTagRulesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "myResourceGroup", "myMonitor", "default", armdynatrace.TagRuleUpdate{}, nil) + res, err := clientFactory.NewTagRulesClient().Update(ctx, "myResourceGroup", "myMonitor", "default", armdynatrace.TagRuleUpdate{}, 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.TagRule = armdynatrace.TagRule{ + // Properties: &armdynatrace.MonitoringTagRulesProperties{ + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_Delete_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_Delete_MaximumSet_Gen.json func ExampleTagRulesClient_BeginDelete_tagRulesDeleteMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewTagRulesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "myResourceGroup", "myMonitor", "default", nil) + poller, err := clientFactory.NewTagRulesClient().BeginDelete(ctx, "myResourceGroup", "myMonitor", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -215,18 +354,18 @@ func ExampleTagRulesClient_BeginDelete_tagRulesDeleteMaximumSetGen() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_Delete_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_Delete_MinimumSet_Gen.json func ExampleTagRulesClient_BeginDelete_tagRulesDeleteMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewTagRulesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "myResourceGroup", "myMonitor", "default", nil) + poller, err := clientFactory.NewTagRulesClient().BeginDelete(ctx, "myResourceGroup", "myMonitor", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -236,50 +375,102 @@ func ExampleTagRulesClient_BeginDelete_tagRulesDeleteMinimumSetGen() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_List_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_List_MaximumSet_Gen.json func ExampleTagRulesClient_NewListPager_tagRulesListMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewTagRulesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("myResourceGroup", "myMonitor", nil) + pager := clientFactory.NewTagRulesClient().NewListPager("myResourceGroup", "myMonitor", 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.TagRuleListResult = armdynatrace.TagRuleListResult{ + // Value: []*armdynatrace.TagRule{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Dynatrace.Observability/monitors/tagRules"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Dynatrace.Observability/monitors/myMonitor/tagRules/default"), + // Properties: &armdynatrace.MonitoringTagRulesProperties{ + // LogRules: &armdynatrace.LogRules{ + // FilteringTags: []*armdynatrace.FilteringTag{ + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armdynatrace.TagActionInclude), + // Value: to.Ptr("Prod"), + // }, + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armdynatrace.TagActionExclude), + // Value: to.Ptr("Dev"), + // }}, + // SendAADLogs: to.Ptr(armdynatrace.SendAADLogsStatusEnabled), + // SendActivityLogs: to.Ptr(armdynatrace.SendActivityLogsStatusEnabled), + // SendSubscriptionLogs: to.Ptr(armdynatrace.SendSubscriptionLogsStatusEnabled), + // }, + // MetricRules: &armdynatrace.MetricRules{ + // FilteringTags: []*armdynatrace.FilteringTag{ + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armdynatrace.TagActionInclude), + // Value: to.Ptr("Prod"), + // }}, + // }, + // ProvisioningState: to.Ptr(armdynatrace.ProvisioningStateSucceeded), + // }, + // SystemData: &armdynatrace.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // CreatedBy: to.Ptr("alice@microsoft.com"), + // CreatedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T04:25:21.040Z"); return t}()), + // LastModifiedBy: to.Ptr("alice@microsoft.com"), + // LastModifiedByType: to.Ptr(armdynatrace.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_List_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3751f321654db00858e70649291af5c81e94611e/specification/dynatrace/resource-manager/Dynatrace.Observability/stable/2021-09-01/examples/TagRules_List_MinimumSet_Gen.json func ExampleTagRulesClient_NewListPager_tagRulesListMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armdynatrace.NewTagRulesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armdynatrace.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("myResourceGroup", "myMonitor", nil) + pager := clientFactory.NewTagRulesClient().NewListPager("myResourceGroup", "myMonitor", 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.TagRuleListResult = armdynatrace.TagRuleListResult{ + // Value: []*armdynatrace.TagRule{ + // { + // Properties: &armdynatrace.MonitoringTagRulesProperties{ + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/time_rfc3339.go b/sdk/resourcemanager/dynatrace/armdynatrace/time_rfc3339.go index 228a96d7c14f..80f1b5ff683a 100644 --- a/sdk/resourcemanager/dynatrace/armdynatrace/time_rfc3339.go +++ b/sdk/resourcemanager/dynatrace/armdynatrace/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/edgeorder/armedgeorder/CHANGELOG.md b/sdk/resourcemanager/edgeorder/armedgeorder/CHANGELOG.md index 8ed24bf0247e..a23a040d26b8 100644 --- a/sdk/resourcemanager/edgeorder/armedgeorder/CHANGELOG.md +++ b/sdk/resourcemanager/edgeorder/armedgeorder/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-28) +### 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/edgeorder/armedgeorder` 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/edgeorder/armedgeorder/README.md b/sdk/resourcemanager/edgeorder/armedgeorder/README.md index 9ad40506c165..e2a27b1cf95c 100644 --- a/sdk/resourcemanager/edgeorder/armedgeorder/README.md +++ b/sdk/resourcemanager/edgeorder/armedgeorder/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 Edge Order 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 Edge Order 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 := armedgeorder.NewManagementClient(, cred, nil) +clientFactory, err := armedgeorder.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 := armedgeorder.NewManagementClient(, cred, &options) +clientFactory, err := armedgeorder.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.NewManagementClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/edgeorder/armedgeorder/autorest.md b/sdk/resourcemanager/edgeorder/armedgeorder/autorest.md index 316ec0823a61..e2d0fcf3b245 100644 --- a/sdk/resourcemanager/edgeorder/armedgeorder/autorest.md +++ b/sdk/resourcemanager/edgeorder/armedgeorder/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/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/edgeorder/armedgeorder/client_factory.go b/sdk/resourcemanager/edgeorder/armedgeorder/client_factory.go new file mode 100644 index 000000000000..f009acbef31e --- /dev/null +++ b/sdk/resourcemanager/edgeorder/armedgeorder/client_factory.go @@ -0,0 +1,44 @@ +//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 armedgeorder + +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) NewManagementClient() *ManagementClient { + subClient, _ := NewManagementClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_constants.go b/sdk/resourcemanager/edgeorder/armedgeorder/constants.go similarity index 99% rename from sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_constants.go rename to sdk/resourcemanager/edgeorder/armedgeorder/constants.go index 1733249b4d37..996f757a320d 100644 --- a/sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_constants.go +++ b/sdk/resourcemanager/edgeorder/armedgeorder/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 armedgeorder const ( moduleName = "armedgeorder" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // ActionStatusEnum - Describes whether the order item is deletable or not. diff --git a/sdk/resourcemanager/edgeorder/armedgeorder/go.mod b/sdk/resourcemanager/edgeorder/armedgeorder/go.mod index eac604f28f4d..bb50ccd75ef3 100644 --- a/sdk/resourcemanager/edgeorder/armedgeorder/go.mod +++ b/sdk/resourcemanager/edgeorder/armedgeorder/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgeorder/armedgeor 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/edgeorder/armedgeorder/go.sum b/sdk/resourcemanager/edgeorder/armedgeorder/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/edgeorder/armedgeorder/go.sum +++ b/sdk/resourcemanager/edgeorder/armedgeorder/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/edgeorder/armedgeorder/zz_generated_management_client.go b/sdk/resourcemanager/edgeorder/armedgeorder/management_client.go similarity index 86% rename from sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_management_client.go rename to sdk/resourcemanager/edgeorder/armedgeorder/management_client.go index 42c34796cc04..8b551728ef39 100644 --- a/sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_management_client.go +++ b/sdk/resourcemanager/edgeorder/armedgeorder/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 armedgeorder @@ -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 ( // ManagementClient contains the methods for the EdgeOrderManagementClient 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 } // CancelOrderItem - Cancel order item. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// orderItemName - The name of the order item -// resourceGroupName - The name of the resource group. The name is case insensitive. -// cancellationReason - Reason for cancellation. -// options - ManagementClientCancelOrderItemOptions contains the optional parameters for the ManagementClient.CancelOrderItem -// method. +// - orderItemName - The name of the order item +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - cancellationReason - Reason for cancellation. +// - options - ManagementClientCancelOrderItemOptions contains the optional parameters for the ManagementClient.CancelOrderItem +// method. func (client *ManagementClient) CancelOrderItem(ctx context.Context, orderItemName string, resourceGroupName string, cancellationReason CancellationReason, options *ManagementClientCancelOrderItemOptions) (ManagementClientCancelOrderItemResponse, error) { req, err := client.cancelOrderItemCreateRequest(ctx, orderItemName, resourceGroupName, cancellationReason, options) if err != nil { return ManagementClientCancelOrderItemResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientCancelOrderItemResponse{}, err } @@ -92,7 +83,7 @@ func (client *ManagementClient) cancelOrderItemCreateRequest(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.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 } @@ -105,34 +96,36 @@ func (client *ManagementClient) cancelOrderItemCreateRequest(ctx context.Context // BeginCreateAddress - Creates a new address with the specified parameters. Existing address can be updated with this API // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// addressName - The name of the address Resource within the specified resource group. address names must be between 3 and -// 24 characters in length and use any alphanumeric and underscore only -// resourceGroupName - The name of the resource group. The name is case insensitive. -// addressResource - Address details from request body. -// options - ManagementClientBeginCreateAddressOptions contains the optional parameters for the ManagementClient.BeginCreateAddress -// method. +// - addressName - The name of the address Resource within the specified resource group. address names must be between 3 and +// 24 characters in length and use any alphanumeric and underscore only +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - addressResource - Address details from request body. +// - options - ManagementClientBeginCreateAddressOptions contains the optional parameters for the ManagementClient.BeginCreateAddress +// method. func (client *ManagementClient) BeginCreateAddress(ctx context.Context, addressName string, resourceGroupName string, addressResource AddressResource, options *ManagementClientBeginCreateAddressOptions) (*runtime.Poller[ManagementClientCreateAddressResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createAddress(ctx, addressName, resourceGroupName, addressResource, options) if err != nil { return nil, err } - return runtime.NewPoller[ManagementClientCreateAddressResponse](resp, client.pl, nil) + return runtime.NewPoller[ManagementClientCreateAddressResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ManagementClientCreateAddressResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ManagementClientCreateAddressResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateAddress - Creates a new address with the specified parameters. Existing address can be updated with this API // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 func (client *ManagementClient) createAddress(ctx context.Context, addressName string, resourceGroupName string, addressResource AddressResource, options *ManagementClientBeginCreateAddressOptions) (*http.Response, error) { req, err := client.createAddressCreateRequest(ctx, addressName, resourceGroupName, addressResource, 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 } @@ -157,7 +150,7 @@ func (client *ManagementClient) createAddressCreateRequest(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 } @@ -171,34 +164,36 @@ func (client *ManagementClient) createAddressCreateRequest(ctx context.Context, // BeginCreateOrderItem - Creates an order item. Existing order item cannot be updated with this api and should instead be // updated with the Update order item API. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// orderItemName - The name of the order item -// resourceGroupName - The name of the resource group. The name is case insensitive. -// orderItemResource - Order item details from request body. -// options - ManagementClientBeginCreateOrderItemOptions contains the optional parameters for the ManagementClient.BeginCreateOrderItem -// method. +// - orderItemName - The name of the order item +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - orderItemResource - Order item details from request body. +// - options - ManagementClientBeginCreateOrderItemOptions contains the optional parameters for the ManagementClient.BeginCreateOrderItem +// method. func (client *ManagementClient) BeginCreateOrderItem(ctx context.Context, orderItemName string, resourceGroupName string, orderItemResource OrderItemResource, options *ManagementClientBeginCreateOrderItemOptions) (*runtime.Poller[ManagementClientCreateOrderItemResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrderItem(ctx, orderItemName, resourceGroupName, orderItemResource, options) if err != nil { return nil, err } - return runtime.NewPoller[ManagementClientCreateOrderItemResponse](resp, client.pl, nil) + return runtime.NewPoller[ManagementClientCreateOrderItemResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ManagementClientCreateOrderItemResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ManagementClientCreateOrderItemResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrderItem - Creates an order item. Existing order item cannot be updated with this api and should instead be updated // with the Update order item API. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 func (client *ManagementClient) createOrderItem(ctx context.Context, orderItemName string, resourceGroupName string, orderItemResource OrderItemResource, options *ManagementClientBeginCreateOrderItemOptions) (*http.Response, error) { req, err := client.createOrderItemCreateRequest(ctx, orderItemName, resourceGroupName, orderItemResource, 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 } @@ -223,7 +218,7 @@ func (client *ManagementClient) createOrderItemCreateRequest(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 } @@ -236,33 +231,35 @@ func (client *ManagementClient) createOrderItemCreateRequest(ctx context.Context // BeginDeleteAddressByName - Deletes an address. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// addressName - The name of the address Resource within the specified resource group. address names must be between 3 and -// 24 characters in length and use any alphanumeric and underscore only -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - ManagementClientBeginDeleteAddressByNameOptions contains the optional parameters for the ManagementClient.BeginDeleteAddressByName -// method. +// - addressName - The name of the address Resource within the specified resource group. address names must be between 3 and +// 24 characters in length and use any alphanumeric and underscore only +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ManagementClientBeginDeleteAddressByNameOptions contains the optional parameters for the ManagementClient.BeginDeleteAddressByName +// method. func (client *ManagementClient) BeginDeleteAddressByName(ctx context.Context, addressName string, resourceGroupName string, options *ManagementClientBeginDeleteAddressByNameOptions) (*runtime.Poller[ManagementClientDeleteAddressByNameResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteAddressByName(ctx, addressName, resourceGroupName, options) if err != nil { return nil, err } - return runtime.NewPoller[ManagementClientDeleteAddressByNameResponse](resp, client.pl, nil) + return runtime.NewPoller[ManagementClientDeleteAddressByNameResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ManagementClientDeleteAddressByNameResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ManagementClientDeleteAddressByNameResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // DeleteAddressByName - Deletes an address. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 func (client *ManagementClient) deleteAddressByName(ctx context.Context, addressName string, resourceGroupName string, options *ManagementClientBeginDeleteAddressByNameOptions) (*http.Response, error) { req, err := client.deleteAddressByNameCreateRequest(ctx, addressName, 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 } @@ -287,7 +284,7 @@ func (client *ManagementClient) deleteAddressByNameCreateRequest(ctx context.Con 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 } @@ -300,32 +297,34 @@ func (client *ManagementClient) deleteAddressByNameCreateRequest(ctx context.Con // BeginDeleteOrderItemByName - Deletes an order item. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// orderItemName - The name of the order item -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - ManagementClientBeginDeleteOrderItemByNameOptions contains the optional parameters for the ManagementClient.BeginDeleteOrderItemByName -// method. +// - orderItemName - The name of the order item +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ManagementClientBeginDeleteOrderItemByNameOptions contains the optional parameters for the ManagementClient.BeginDeleteOrderItemByName +// method. func (client *ManagementClient) BeginDeleteOrderItemByName(ctx context.Context, orderItemName string, resourceGroupName string, options *ManagementClientBeginDeleteOrderItemByNameOptions) (*runtime.Poller[ManagementClientDeleteOrderItemByNameResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOrderItemByName(ctx, orderItemName, resourceGroupName, options) if err != nil { return nil, err } - return runtime.NewPoller[ManagementClientDeleteOrderItemByNameResponse](resp, client.pl, nil) + return runtime.NewPoller[ManagementClientDeleteOrderItemByNameResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ManagementClientDeleteOrderItemByNameResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ManagementClientDeleteOrderItemByNameResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // DeleteOrderItemByName - Deletes an order item. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 func (client *ManagementClient) deleteOrderItemByName(ctx context.Context, orderItemName string, resourceGroupName string, options *ManagementClientBeginDeleteOrderItemByNameOptions) (*http.Response, error) { req, err := client.deleteOrderItemByNameCreateRequest(ctx, orderItemName, 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 } @@ -350,7 +349,7 @@ func (client *ManagementClient) deleteOrderItemByNameCreateRequest(ctx context.C 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 } @@ -363,18 +362,19 @@ func (client *ManagementClient) deleteOrderItemByNameCreateRequest(ctx context.C // GetAddressByName - Gets information about the specified address. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// addressName - The name of the address Resource within the specified resource group. address names must be between 3 and -// 24 characters in length and use any alphanumeric and underscore only -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - ManagementClientGetAddressByNameOptions contains the optional parameters for the ManagementClient.GetAddressByName -// method. +// - addressName - The name of the address Resource within the specified resource group. address names must be between 3 and +// 24 characters in length and use any alphanumeric and underscore only +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ManagementClientGetAddressByNameOptions contains the optional parameters for the ManagementClient.GetAddressByName +// method. func (client *ManagementClient) GetAddressByName(ctx context.Context, addressName string, resourceGroupName string, options *ManagementClientGetAddressByNameOptions) (ManagementClientGetAddressByNameResponse, error) { req, err := client.getAddressByNameCreateRequest(ctx, addressName, resourceGroupName, options) if err != nil { return ManagementClientGetAddressByNameResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientGetAddressByNameResponse{}, err } @@ -399,7 +399,7 @@ func (client *ManagementClient) getAddressByNameCreateRequest(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 } @@ -421,18 +421,19 @@ func (client *ManagementClient) getAddressByNameHandleResponse(resp *http.Respon // GetOrderByName - Gets an order. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// orderName - The name of the order -// resourceGroupName - The name of the resource group. The name is case insensitive. -// location - The name of Azure region. -// options - ManagementClientGetOrderByNameOptions contains the optional parameters for the ManagementClient.GetOrderByName -// method. +// - orderName - The name of the order +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - location - The name of Azure region. +// - options - ManagementClientGetOrderByNameOptions contains the optional parameters for the ManagementClient.GetOrderByName +// method. func (client *ManagementClient) GetOrderByName(ctx context.Context, orderName string, resourceGroupName string, location string, options *ManagementClientGetOrderByNameOptions) (ManagementClientGetOrderByNameResponse, error) { req, err := client.getOrderByNameCreateRequest(ctx, orderName, resourceGroupName, location, options) if err != nil { return ManagementClientGetOrderByNameResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientGetOrderByNameResponse{}, err } @@ -461,7 +462,7 @@ func (client *ManagementClient) getOrderByNameCreateRequest(ctx context.Context, return nil, errors.New("parameter location cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) - 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 } @@ -483,17 +484,18 @@ func (client *ManagementClient) getOrderByNameHandleResponse(resp *http.Response // GetOrderItemByName - Gets an order item. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// orderItemName - The name of the order item -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - ManagementClientGetOrderItemByNameOptions contains the optional parameters for the ManagementClient.GetOrderItemByName -// method. +// - orderItemName - The name of the order item +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ManagementClientGetOrderItemByNameOptions contains the optional parameters for the ManagementClient.GetOrderItemByName +// method. func (client *ManagementClient) GetOrderItemByName(ctx context.Context, orderItemName string, resourceGroupName string, options *ManagementClientGetOrderItemByNameOptions) (ManagementClientGetOrderItemByNameResponse, error) { req, err := client.getOrderItemByNameCreateRequest(ctx, orderItemName, resourceGroupName, options) if err != nil { return ManagementClientGetOrderItemByNameResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientGetOrderItemByNameResponse{}, err } @@ -518,7 +520,7 @@ func (client *ManagementClient) getOrderItemByNameCreateRequest(ctx context.Cont 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 } @@ -542,11 +544,11 @@ func (client *ManagementClient) getOrderItemByNameHandleResponse(resp *http.Resp } // NewListAddressesAtResourceGroupLevelPager - Lists all the addresses available under the given resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - ManagementClientListAddressesAtResourceGroupLevelOptions contains the optional parameters for the ManagementClient.ListAddressesAtResourceGroupLevel -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ManagementClientListAddressesAtResourceGroupLevelOptions contains the optional parameters for the ManagementClient.NewListAddressesAtResourceGroupLevelPager +// method. func (client *ManagementClient) NewListAddressesAtResourceGroupLevelPager(resourceGroupName string, options *ManagementClientListAddressesAtResourceGroupLevelOptions) *runtime.Pager[ManagementClientListAddressesAtResourceGroupLevelResponse] { return runtime.NewPager(runtime.PagingHandler[ManagementClientListAddressesAtResourceGroupLevelResponse]{ More: func(page ManagementClientListAddressesAtResourceGroupLevelResponse) bool { @@ -563,7 +565,7 @@ func (client *ManagementClient) NewListAddressesAtResourceGroupLevelPager(resour if err != nil { return ManagementClientListAddressesAtResourceGroupLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientListAddressesAtResourceGroupLevelResponse{}, err } @@ -586,7 +588,7 @@ func (client *ManagementClient) listAddressesAtResourceGroupLevelCreateRequest(c 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 } @@ -613,10 +615,10 @@ func (client *ManagementClient) listAddressesAtResourceGroupLevelHandleResponse( } // NewListAddressesAtSubscriptionLevelPager - Lists all the addresses available under the subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// options - ManagementClientListAddressesAtSubscriptionLevelOptions contains the optional parameters for the ManagementClient.ListAddressesAtSubscriptionLevel -// method. +// - options - ManagementClientListAddressesAtSubscriptionLevelOptions contains the optional parameters for the ManagementClient.NewListAddressesAtSubscriptionLevelPager +// method. func (client *ManagementClient) NewListAddressesAtSubscriptionLevelPager(options *ManagementClientListAddressesAtSubscriptionLevelOptions) *runtime.Pager[ManagementClientListAddressesAtSubscriptionLevelResponse] { return runtime.NewPager(runtime.PagingHandler[ManagementClientListAddressesAtSubscriptionLevelResponse]{ More: func(page ManagementClientListAddressesAtSubscriptionLevelResponse) bool { @@ -633,7 +635,7 @@ func (client *ManagementClient) NewListAddressesAtSubscriptionLevelPager(options if err != nil { return ManagementClientListAddressesAtSubscriptionLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientListAddressesAtSubscriptionLevelResponse{}, err } @@ -652,7 +654,7 @@ func (client *ManagementClient) listAddressesAtSubscriptionLevelCreateRequest(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 } @@ -680,11 +682,11 @@ func (client *ManagementClient) listAddressesAtSubscriptionLevelHandleResponse(r // NewListConfigurationsPager - This method provides the list of configurations for the given product family, product line // and product under subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// configurationsRequest - Filters for showing the configurations. -// options - ManagementClientListConfigurationsOptions contains the optional parameters for the ManagementClient.ListConfigurations -// method. +// - configurationsRequest - Filters for showing the configurations. +// - options - ManagementClientListConfigurationsOptions contains the optional parameters for the ManagementClient.NewListConfigurationsPager +// method. func (client *ManagementClient) NewListConfigurationsPager(configurationsRequest ConfigurationsRequest, options *ManagementClientListConfigurationsOptions) *runtime.Pager[ManagementClientListConfigurationsResponse] { return runtime.NewPager(runtime.PagingHandler[ManagementClientListConfigurationsResponse]{ More: func(page ManagementClientListConfigurationsResponse) bool { @@ -701,7 +703,7 @@ func (client *ManagementClient) NewListConfigurationsPager(configurationsRequest if err != nil { return ManagementClientListConfigurationsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientListConfigurationsResponse{}, err } @@ -720,7 +722,7 @@ func (client *ManagementClient) listConfigurationsCreateRequest(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 } @@ -744,10 +746,10 @@ func (client *ManagementClient) listConfigurationsHandleResponse(resp *http.Resp } // NewListOperationsPager - This method gets all the operations that are exposed for customer. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// options - ManagementClientListOperationsOptions contains the optional parameters for the ManagementClient.ListOperations -// method. +// - options - ManagementClientListOperationsOptions contains the optional parameters for the ManagementClient.NewListOperationsPager +// method. func (client *ManagementClient) NewListOperationsPager(options *ManagementClientListOperationsOptions) *runtime.Pager[ManagementClientListOperationsResponse] { return runtime.NewPager(runtime.PagingHandler[ManagementClientListOperationsResponse]{ More: func(page ManagementClientListOperationsResponse) bool { @@ -764,7 +766,7 @@ func (client *ManagementClient) NewListOperationsPager(options *ManagementClient if err != nil { return ManagementClientListOperationsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientListOperationsResponse{}, err } @@ -779,7 +781,7 @@ func (client *ManagementClient) NewListOperationsPager(options *ManagementClient // listOperationsCreateRequest creates the ListOperations request. func (client *ManagementClient) listOperationsCreateRequest(ctx context.Context, options *ManagementClientListOperationsOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.EdgeOrder/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 } @@ -800,11 +802,11 @@ func (client *ManagementClient) listOperationsHandleResponse(resp *http.Response } // NewListOrderAtResourceGroupLevelPager - Lists order at resource group level. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - ManagementClientListOrderAtResourceGroupLevelOptions contains the optional parameters for the ManagementClient.ListOrderAtResourceGroupLevel -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ManagementClientListOrderAtResourceGroupLevelOptions contains the optional parameters for the ManagementClient.NewListOrderAtResourceGroupLevelPager +// method. func (client *ManagementClient) NewListOrderAtResourceGroupLevelPager(resourceGroupName string, options *ManagementClientListOrderAtResourceGroupLevelOptions) *runtime.Pager[ManagementClientListOrderAtResourceGroupLevelResponse] { return runtime.NewPager(runtime.PagingHandler[ManagementClientListOrderAtResourceGroupLevelResponse]{ More: func(page ManagementClientListOrderAtResourceGroupLevelResponse) bool { @@ -821,7 +823,7 @@ func (client *ManagementClient) NewListOrderAtResourceGroupLevelPager(resourceGr if err != nil { return ManagementClientListOrderAtResourceGroupLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientListOrderAtResourceGroupLevelResponse{}, err } @@ -844,7 +846,7 @@ func (client *ManagementClient) listOrderAtResourceGroupLevelCreateRequest(ctx c 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 } @@ -868,10 +870,10 @@ func (client *ManagementClient) listOrderAtResourceGroupLevelHandleResponse(resp } // NewListOrderAtSubscriptionLevelPager - Lists order at subscription level. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// options - ManagementClientListOrderAtSubscriptionLevelOptions contains the optional parameters for the ManagementClient.ListOrderAtSubscriptionLevel -// method. +// - options - ManagementClientListOrderAtSubscriptionLevelOptions contains the optional parameters for the ManagementClient.NewListOrderAtSubscriptionLevelPager +// method. func (client *ManagementClient) NewListOrderAtSubscriptionLevelPager(options *ManagementClientListOrderAtSubscriptionLevelOptions) *runtime.Pager[ManagementClientListOrderAtSubscriptionLevelResponse] { return runtime.NewPager(runtime.PagingHandler[ManagementClientListOrderAtSubscriptionLevelResponse]{ More: func(page ManagementClientListOrderAtSubscriptionLevelResponse) bool { @@ -888,7 +890,7 @@ func (client *ManagementClient) NewListOrderAtSubscriptionLevelPager(options *Ma if err != nil { return ManagementClientListOrderAtSubscriptionLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientListOrderAtSubscriptionLevelResponse{}, err } @@ -907,7 +909,7 @@ func (client *ManagementClient) listOrderAtSubscriptionLevelCreateRequest(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 } @@ -931,11 +933,11 @@ func (client *ManagementClient) listOrderAtSubscriptionLevelHandleResponse(resp } // NewListOrderItemsAtResourceGroupLevelPager - Lists order item at resource group level. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - ManagementClientListOrderItemsAtResourceGroupLevelOptions contains the optional parameters for the ManagementClient.ListOrderItemsAtResourceGroupLevel -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ManagementClientListOrderItemsAtResourceGroupLevelOptions contains the optional parameters for the ManagementClient.NewListOrderItemsAtResourceGroupLevelPager +// method. func (client *ManagementClient) NewListOrderItemsAtResourceGroupLevelPager(resourceGroupName string, options *ManagementClientListOrderItemsAtResourceGroupLevelOptions) *runtime.Pager[ManagementClientListOrderItemsAtResourceGroupLevelResponse] { return runtime.NewPager(runtime.PagingHandler[ManagementClientListOrderItemsAtResourceGroupLevelResponse]{ More: func(page ManagementClientListOrderItemsAtResourceGroupLevelResponse) bool { @@ -952,7 +954,7 @@ func (client *ManagementClient) NewListOrderItemsAtResourceGroupLevelPager(resou if err != nil { return ManagementClientListOrderItemsAtResourceGroupLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientListOrderItemsAtResourceGroupLevelResponse{}, err } @@ -975,7 +977,7 @@ func (client *ManagementClient) listOrderItemsAtResourceGroupLevelCreateRequest( 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 } @@ -1005,10 +1007,10 @@ func (client *ManagementClient) listOrderItemsAtResourceGroupLevelHandleResponse } // NewListOrderItemsAtSubscriptionLevelPager - Lists order item at subscription level. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// options - ManagementClientListOrderItemsAtSubscriptionLevelOptions contains the optional parameters for the ManagementClient.ListOrderItemsAtSubscriptionLevel -// method. +// - options - ManagementClientListOrderItemsAtSubscriptionLevelOptions contains the optional parameters for the ManagementClient.NewListOrderItemsAtSubscriptionLevelPager +// method. func (client *ManagementClient) NewListOrderItemsAtSubscriptionLevelPager(options *ManagementClientListOrderItemsAtSubscriptionLevelOptions) *runtime.Pager[ManagementClientListOrderItemsAtSubscriptionLevelResponse] { return runtime.NewPager(runtime.PagingHandler[ManagementClientListOrderItemsAtSubscriptionLevelResponse]{ More: func(page ManagementClientListOrderItemsAtSubscriptionLevelResponse) bool { @@ -1025,7 +1027,7 @@ func (client *ManagementClient) NewListOrderItemsAtSubscriptionLevelPager(option if err != nil { return ManagementClientListOrderItemsAtSubscriptionLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientListOrderItemsAtSubscriptionLevelResponse{}, err } @@ -1044,7 +1046,7 @@ func (client *ManagementClient) listOrderItemsAtSubscriptionLevelCreateRequest(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 } @@ -1074,11 +1076,11 @@ func (client *ManagementClient) listOrderItemsAtSubscriptionLevelHandleResponse( } // NewListProductFamiliesPager - This method provides the list of product families for the given subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// productFamiliesRequest - Filters for showing the product families. -// options - ManagementClientListProductFamiliesOptions contains the optional parameters for the ManagementClient.ListProductFamilies -// method. +// - productFamiliesRequest - Filters for showing the product families. +// - options - ManagementClientListProductFamiliesOptions contains the optional parameters for the ManagementClient.NewListProductFamiliesPager +// method. func (client *ManagementClient) NewListProductFamiliesPager(productFamiliesRequest ProductFamiliesRequest, options *ManagementClientListProductFamiliesOptions) *runtime.Pager[ManagementClientListProductFamiliesResponse] { return runtime.NewPager(runtime.PagingHandler[ManagementClientListProductFamiliesResponse]{ More: func(page ManagementClientListProductFamiliesResponse) bool { @@ -1095,7 +1097,7 @@ func (client *ManagementClient) NewListProductFamiliesPager(productFamiliesReque if err != nil { return ManagementClientListProductFamiliesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientListProductFamiliesResponse{}, err } @@ -1114,7 +1116,7 @@ func (client *ManagementClient) listProductFamiliesCreateRequest(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.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 } @@ -1141,10 +1143,10 @@ func (client *ManagementClient) listProductFamiliesHandleResponse(resp *http.Res } // NewListProductFamiliesMetadataPager - This method provides the list of product families metadata for the given subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// options - ManagementClientListProductFamiliesMetadataOptions contains the optional parameters for the ManagementClient.ListProductFamiliesMetadata -// method. +// - options - ManagementClientListProductFamiliesMetadataOptions contains the optional parameters for the ManagementClient.NewListProductFamiliesMetadataPager +// method. func (client *ManagementClient) NewListProductFamiliesMetadataPager(options *ManagementClientListProductFamiliesMetadataOptions) *runtime.Pager[ManagementClientListProductFamiliesMetadataResponse] { return runtime.NewPager(runtime.PagingHandler[ManagementClientListProductFamiliesMetadataResponse]{ More: func(page ManagementClientListProductFamiliesMetadataResponse) bool { @@ -1161,7 +1163,7 @@ func (client *ManagementClient) NewListProductFamiliesMetadataPager(options *Man if err != nil { return ManagementClientListProductFamiliesMetadataResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientListProductFamiliesMetadataResponse{}, err } @@ -1180,7 +1182,7 @@ func (client *ManagementClient) listProductFamiliesMetadataCreateRequest(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.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 } @@ -1205,33 +1207,35 @@ func (client *ManagementClient) listProductFamiliesMetadataHandleResponse(resp * // BeginReturnOrderItem - Return order item. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// orderItemName - The name of the order item -// resourceGroupName - The name of the resource group. The name is case insensitive. -// returnOrderItemDetails - Return order item CurrentStatus. -// options - ManagementClientBeginReturnOrderItemOptions contains the optional parameters for the ManagementClient.BeginReturnOrderItem -// method. +// - orderItemName - The name of the order item +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - returnOrderItemDetails - Return order item CurrentStatus. +// - options - ManagementClientBeginReturnOrderItemOptions contains the optional parameters for the ManagementClient.BeginReturnOrderItem +// method. func (client *ManagementClient) BeginReturnOrderItem(ctx context.Context, orderItemName string, resourceGroupName string, returnOrderItemDetails ReturnOrderItemDetails, options *ManagementClientBeginReturnOrderItemOptions) (*runtime.Poller[ManagementClientReturnOrderItemResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.returnOrderItem(ctx, orderItemName, resourceGroupName, returnOrderItemDetails, options) if err != nil { return nil, err } - return runtime.NewPoller[ManagementClientReturnOrderItemResponse](resp, client.pl, nil) + return runtime.NewPoller[ManagementClientReturnOrderItemResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ManagementClientReturnOrderItemResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ManagementClientReturnOrderItemResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // ReturnOrderItem - Return order item. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 func (client *ManagementClient) returnOrderItem(ctx context.Context, orderItemName string, resourceGroupName string, returnOrderItemDetails ReturnOrderItemDetails, options *ManagementClientBeginReturnOrderItemOptions) (*http.Response, error) { req, err := client.returnOrderItemCreateRequest(ctx, orderItemName, resourceGroupName, returnOrderItemDetails, 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 } @@ -1256,7 +1260,7 @@ func (client *ManagementClient) returnOrderItemCreateRequest(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.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 } @@ -1269,34 +1273,36 @@ func (client *ManagementClient) returnOrderItemCreateRequest(ctx context.Context // BeginUpdateAddress - Updates the properties of an existing address. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// addressName - The name of the address Resource within the specified resource group. address names must be between 3 and -// 24 characters in length and use any alphanumeric and underscore only -// resourceGroupName - The name of the resource group. The name is case insensitive. -// addressUpdateParameter - Address update parameters from request body. -// options - ManagementClientBeginUpdateAddressOptions contains the optional parameters for the ManagementClient.BeginUpdateAddress -// method. +// - addressName - The name of the address Resource within the specified resource group. address names must be between 3 and +// 24 characters in length and use any alphanumeric and underscore only +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - addressUpdateParameter - Address update parameters from request body. +// - options - ManagementClientBeginUpdateAddressOptions contains the optional parameters for the ManagementClient.BeginUpdateAddress +// method. func (client *ManagementClient) BeginUpdateAddress(ctx context.Context, addressName string, resourceGroupName string, addressUpdateParameter AddressUpdateParameter, options *ManagementClientBeginUpdateAddressOptions) (*runtime.Poller[ManagementClientUpdateAddressResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.updateAddress(ctx, addressName, resourceGroupName, addressUpdateParameter, options) if err != nil { return nil, err } - return runtime.NewPoller[ManagementClientUpdateAddressResponse](resp, client.pl, nil) + return runtime.NewPoller[ManagementClientUpdateAddressResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ManagementClientUpdateAddressResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ManagementClientUpdateAddressResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // UpdateAddress - Updates the properties of an existing address. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 func (client *ManagementClient) updateAddress(ctx context.Context, addressName string, resourceGroupName string, addressUpdateParameter AddressUpdateParameter, options *ManagementClientBeginUpdateAddressOptions) (*http.Response, error) { req, err := client.updateAddressCreateRequest(ctx, addressName, resourceGroupName, addressUpdateParameter, 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 } @@ -1321,7 +1327,7 @@ func (client *ManagementClient) updateAddressCreateRequest(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.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 } @@ -1337,33 +1343,35 @@ func (client *ManagementClient) updateAddressCreateRequest(ctx context.Context, // BeginUpdateOrderItem - Updates the properties of an existing order item. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// orderItemName - The name of the order item -// resourceGroupName - The name of the resource group. The name is case insensitive. -// orderItemUpdateParameter - order item update parameters from request body. -// options - ManagementClientBeginUpdateOrderItemOptions contains the optional parameters for the ManagementClient.BeginUpdateOrderItem -// method. +// - orderItemName - The name of the order item +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - orderItemUpdateParameter - order item update parameters from request body. +// - options - ManagementClientBeginUpdateOrderItemOptions contains the optional parameters for the ManagementClient.BeginUpdateOrderItem +// method. func (client *ManagementClient) BeginUpdateOrderItem(ctx context.Context, orderItemName string, resourceGroupName string, orderItemUpdateParameter OrderItemUpdateParameter, options *ManagementClientBeginUpdateOrderItemOptions) (*runtime.Poller[ManagementClientUpdateOrderItemResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.updateOrderItem(ctx, orderItemName, resourceGroupName, orderItemUpdateParameter, options) if err != nil { return nil, err } - return runtime.NewPoller[ManagementClientUpdateOrderItemResponse](resp, client.pl, nil) + return runtime.NewPoller[ManagementClientUpdateOrderItemResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ManagementClientUpdateOrderItemResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ManagementClientUpdateOrderItemResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // UpdateOrderItem - Updates the properties of an existing order item. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 func (client *ManagementClient) updateOrderItem(ctx context.Context, orderItemName string, resourceGroupName string, orderItemUpdateParameter OrderItemUpdateParameter, options *ManagementClientBeginUpdateOrderItemOptions) (*http.Response, error) { req, err := client.updateOrderItemCreateRequest(ctx, orderItemName, resourceGroupName, orderItemUpdateParameter, 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 } @@ -1388,7 +1396,7 @@ func (client *ManagementClient) updateOrderItemCreateRequest(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.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/edgeorder/armedgeorder/management_client_example_test.go b/sdk/resourcemanager/edgeorder/armedgeorder/management_client_example_test.go new file mode 100644 index 000000000000..6a8fa16d731a --- /dev/null +++ b/sdk/resourcemanager/edgeorder/armedgeorder/management_client_example_test.go @@ -0,0 +1,2203 @@ +//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 armedgeorder_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/edgeorder/armedgeorder" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListOperations.json +func ExampleManagementClient_NewListOperationsPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewManagementClient().NewListOperationsPager(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 = armedgeorder.OperationListResult{ + // Value: []*armedgeorder.Operation{ + // { + // Name: to.Ptr("Microsoft.EdgeOrder/addresses/read"), + // Display: &armedgeorder.OperationDisplay{ + // Description: to.Ptr("List or get the Addresses"), + // Operation: to.Ptr("List or Get Addresses"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("Addresses"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorder.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrder/addresses/delete"), + // Display: &armedgeorder.OperationDisplay{ + // Description: to.Ptr("Delete the Addresses"), + // Operation: to.Ptr("Delete Addresses"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("Addresses"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorder.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrder/addresses/write"), + // Display: &armedgeorder.OperationDisplay{ + // Description: to.Ptr("Create or update the Addresses"), + // Operation: to.Ptr("Create or Update Addresses"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("Addresses"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorder.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrder/locations/operationResults/read"), + // Display: &armedgeorder.OperationDisplay{ + // Description: to.Ptr("List or get the Operation Results"), + // Operation: to.Ptr("List or Get Operation Results"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("Operation Results"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorder.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrder/operations/read"), + // Display: &armedgeorder.OperationDisplay{ + // Description: to.Ptr("List or get the Operations"), + // Operation: to.Ptr("List or Get Operations"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("Operations"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorder.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrder/locations/orders/read"), + // Display: &armedgeorder.OperationDisplay{ + // Description: to.Ptr("List or get the Order"), + // Operation: to.Ptr("List or Get Order"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("Order"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorder.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrder/orders/read"), + // Display: &armedgeorder.OperationDisplay{ + // Description: to.Ptr("List or get the Order"), + // Operation: to.Ptr("List or Get Order"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("Order"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorder.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrder/orderItems/cancel/action"), + // Display: &armedgeorder.OperationDisplay{ + // Description: to.Ptr("Cancels an OrderItem in progress."), + // Operation: to.Ptr("Cancel OrderItem"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("OrderItem"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorder.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrder/orderItems/return/action"), + // Display: &armedgeorder.OperationDisplay{ + // Description: to.Ptr("Return an OrderItem."), + // Operation: to.Ptr("Return OrderItem"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("OrderItem"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorder.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrder/orderItems/read"), + // Display: &armedgeorder.OperationDisplay{ + // Description: to.Ptr("List or get the OrderItem"), + // Operation: to.Ptr("List or Get OrderItem"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("OrderItem"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorder.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrder/orderItems/delete"), + // Display: &armedgeorder.OperationDisplay{ + // Description: to.Ptr("Delete the OrderItem"), + // Operation: to.Ptr("Delete OrderItem"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("OrderItem"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorder.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrder/orderItems/write"), + // Display: &armedgeorder.OperationDisplay{ + // Description: to.Ptr("Create or update the OrderItem"), + // Operation: to.Ptr("Create or Update OrderItem"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("OrderItem"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorder.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrder/productFamiliesMetadata/action"), + // Display: &armedgeorder.OperationDisplay{ + // Description: to.Ptr("This method lists or gets the product families metadata."), + // Operation: to.Ptr("List or Get product families metadata"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("ArmApiRes_Microsoft.EdgeOrder"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorder.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrder/listProductFamilies/read"), + // Display: &armedgeorder.OperationDisplay{ + // Description: to.Ptr("This method returns list of product families."), + // Operation: to.Ptr("List Product Families"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("ArmApiRes_Microsoft.EdgeOrder"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorder.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrder/listConfigurations/action"), + // Display: &armedgeorder.OperationDisplay{ + // Description: to.Ptr("This method returns list of product configurations."), + // Operation: to.Ptr("List Product Configurations"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("ArmApiRes_Microsoft.EdgeOrder"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorder.OriginUser), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListAddressesAtSubscriptionLevel.json +func ExampleManagementClient_NewListAddressesAtSubscriptionLevelPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewManagementClient().NewListAddressesAtSubscriptionLevelPager(&armedgeorder.ManagementClientListAddressesAtSubscriptionLevelOptions{Filter: nil, + SkipToken: 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.AddressResourceList = armedgeorder.AddressResourceList{ + // Value: []*armedgeorder.AddressResource{ + // { + // Name: to.Ptr("TestAddressName1"), + // Type: to.Ptr("Microsoft.EdgeOrder/addresses"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/addresses/TestAddressName1"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armedgeorder.AddressProperties{ + // AddressValidationStatus: to.Ptr(armedgeorder.AddressValidationStatusValid), + // ContactDetails: &armedgeorder.ContactDetails{ + // ContactName: to.Ptr("XXXX XXXX"), + // EmailList: []*string{ + // to.Ptr("xxxx@xxxx.xxx")}, + // Phone: to.Ptr("0000000000"), + // PhoneExtension: to.Ptr(""), + // }, + // ShippingAddress: &armedgeorder.ShippingAddress{ + // AddressType: to.Ptr(armedgeorder.AddressTypeNone), + // City: to.Ptr("San Francisco"), + // CompanyName: to.Ptr("Microsoft"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("94107"), + // StateOrProvince: to.Ptr("CA"), + // StreetAddress1: to.Ptr("16 TOWNSEND ST"), + // StreetAddress2: to.Ptr("UNIT 1"), + // }, + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("TestAddressName2"), + // Type: to.Ptr("Microsoft.EdgeOrder/addresses"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/addresses/TestAddressName2"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armedgeorder.AddressProperties{ + // AddressValidationStatus: to.Ptr(armedgeorder.AddressValidationStatusValid), + // ContactDetails: &armedgeorder.ContactDetails{ + // ContactName: to.Ptr("XXXX XXXX"), + // EmailList: []*string{ + // to.Ptr("xxxx@xxxx.xxx")}, + // Phone: to.Ptr("0000000000"), + // PhoneExtension: to.Ptr(""), + // }, + // ShippingAddress: &armedgeorder.ShippingAddress{ + // AddressType: to.Ptr(armedgeorder.AddressTypeNone), + // City: to.Ptr("San Francisco"), + // CompanyName: to.Ptr("Microsoft"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("94107"), + // StateOrProvince: to.Ptr("CA"), + // StreetAddress1: to.Ptr("16 TOWNSEND ST"), + // StreetAddress2: to.Ptr("UNIT 1"), + // }, + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListProductFamilies.json +func ExampleManagementClient_NewListProductFamiliesPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewManagementClient().NewListProductFamiliesPager(armedgeorder.ProductFamiliesRequest{ + FilterableProperties: map[string][]*armedgeorder.FilterableProperty{ + "azurestackedge": { + { + Type: to.Ptr(armedgeorder.SupportedFilterTypesShipToCountries), + SupportedValues: []*string{ + to.Ptr("US")}, + }}, + }, + }, &armedgeorder.ManagementClientListProductFamiliesOptions{Expand: to.Ptr("configurations"), + SkipToken: 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.ProductFamilies = armedgeorder.ProductFamilies{ + // Value: []*armedgeorder.ProductFamily{ + // { + // Properties: &armedgeorder.ProductFamilyProperties{ + // Description: &armedgeorder.Description{ + // Attributes: []*string{ + // }, + // DescriptionType: to.Ptr(armedgeorder.DescriptionTypeBase), + // Keywords: []*string{ + // }, + // Links: []*armedgeorder.Link{ + // }, + // ShortDescription: to.Ptr("Azure managed physical edge compute device"), + // }, + // AvailabilityInformation: &armedgeorder.AvailabilityInformation{ + // AvailabilityStage: to.Ptr(armedgeorder.AvailabilityStageAvailable), + // DisabledReason: to.Ptr(armedgeorder.DisabledReasonNone), + // }, + // DisplayName: to.Ptr("Azure Stack Edge"), + // HierarchyInformation: &armedgeorder.HierarchyInformation{ + // ConfigurationName: to.Ptr(""), + // ProductFamilyName: to.Ptr("azurestackedge"), + // ProductLineName: to.Ptr(""), + // ProductName: to.Ptr(""), + // }, + // ImageInformation: []*armedgeorder.ImageInformation{ + // }, + // FilterableProperties: []*armedgeorder.FilterableProperty{ + // { + // Type: to.Ptr(armedgeorder.SupportedFilterTypesShipToCountries), + // SupportedValues: []*string{ + // to.Ptr("US")}, + // }, + // { + // Type: to.Ptr(armedgeorder.SupportedFilterTypesDoubleEncryptionStatus), + // SupportedValues: []*string{ + // to.Ptr("Enabled")}, + // }}, + // ProductLines: []*armedgeorder.ProductLine{ + // { + // Properties: &armedgeorder.ProductLineProperties{ + // Description: &armedgeorder.Description{ + // Attributes: []*string{ + // }, + // DescriptionType: to.Ptr(armedgeorder.DescriptionTypeBase), + // Keywords: []*string{ + // }, + // Links: []*armedgeorder.Link{ + // }, + // }, + // AvailabilityInformation: &armedgeorder.AvailabilityInformation{ + // AvailabilityStage: to.Ptr(armedgeorder.AvailabilityStageAvailable), + // DisabledReason: to.Ptr(armedgeorder.DisabledReasonNone), + // }, + // DisplayName: to.Ptr("Azure Stack Edge"), + // HierarchyInformation: &armedgeorder.HierarchyInformation{ + // ConfigurationName: to.Ptr(""), + // ProductFamilyName: to.Ptr("azurestackedge"), + // ProductLineName: to.Ptr("azurestackedge"), + // ProductName: to.Ptr(""), + // }, + // ImageInformation: []*armedgeorder.ImageInformation{ + // }, + // FilterableProperties: []*armedgeorder.FilterableProperty{ + // { + // Type: to.Ptr(armedgeorder.SupportedFilterTypesShipToCountries), + // SupportedValues: []*string{ + // to.Ptr("US")}, + // }, + // { + // Type: to.Ptr(armedgeorder.SupportedFilterTypesDoubleEncryptionStatus), + // SupportedValues: []*string{ + // to.Ptr("Enabled")}, + // }}, + // Products: []*armedgeorder.Product{ + // { + // Properties: &armedgeorder.ProductProperties{ + // Description: &armedgeorder.Description{ + // Attributes: []*string{ + // to.Ptr("1U rack mount device with network data transfer capabilities"), + // to.Ptr("Hardware accelerated ML using Nvidia T4 GPU"), + // to.Ptr("Azure Private Edge Zones enabled")}, + // DescriptionType: to.Ptr(armedgeorder.DescriptionTypeBase), + // Keywords: []*string{ + // to.Ptr("GPU")}, + // Links: []*armedgeorder.Link{ + // { + // LinkType: to.Ptr(armedgeorder.LinkTypeSpecification), + // LinkURL: to.Ptr("https://aka.ms/edgeHWcenter-asepro-devicespec"), + // }, + // { + // LinkType: to.Ptr(armedgeorder.LinkTypeGeneric), + // LinkURL: to.Ptr("https://aka.ms/ase-gpu-billing"), + // }, + // { + // LinkType: to.Ptr(armedgeorder.LinkTypeTermsAndConditions), + // LinkURL: to.Ptr("https://aka.ms/ase-gpu-product-terms"), + // }, + // { + // LinkType: to.Ptr(armedgeorder.LinkTypeKnowMore), + // LinkURL: to.Ptr("https://aka.ms/edgeHWcenter-asepro-documentation"), + // }}, + // LongDescription: to.Ptr("Azure Stack Edge Pro is an AI-enabled edge computing device with network data transfer capabilities. The device is powered with NVIDIA T4 GPUs to provide accelerated AI inferencing at the edge. You can choose from the following configurations based upon your business need"), + // ShortDescription: to.Ptr("Azure managed physical edge compute device"), + // }, + // AvailabilityInformation: &armedgeorder.AvailabilityInformation{ + // AvailabilityStage: to.Ptr(armedgeorder.AvailabilityStageAvailable), + // DisabledReason: to.Ptr(armedgeorder.DisabledReasonNone), + // }, + // DisplayName: to.Ptr("Azure Stack Edge Pro - GPU"), + // HierarchyInformation: &armedgeorder.HierarchyInformation{ + // ConfigurationName: to.Ptr(""), + // ProductFamilyName: to.Ptr("azurestackedge"), + // ProductLineName: to.Ptr("azurestackedge"), + // ProductName: to.Ptr("azurestackedgegpu"), + // }, + // ImageInformation: []*armedgeorder.ImageInformation{ + // }, + // FilterableProperties: []*armedgeorder.FilterableProperty{ + // { + // Type: to.Ptr(armedgeorder.SupportedFilterTypesShipToCountries), + // SupportedValues: []*string{ + // to.Ptr("US")}, + // }}, + // Configurations: []*armedgeorder.Configuration{ + // { + // Properties: &armedgeorder.ConfigurationProperties{ + // Description: &armedgeorder.Description{ + // Attributes: []*string{ + // }, + // DescriptionType: to.Ptr(armedgeorder.DescriptionTypeBase), + // Keywords: []*string{ + // to.Ptr("GPU")}, + // Links: []*armedgeorder.Link{ + // }, + // LongDescription: to.Ptr(""), + // ShortDescription: to.Ptr(""), + // }, + // AvailabilityInformation: &armedgeorder.AvailabilityInformation{ + // AvailabilityStage: to.Ptr(armedgeorder.AvailabilityStageAvailable), + // DisabledReason: to.Ptr(armedgeorder.DisabledReasonNone), + // }, + // CostInformation: &armedgeorder.CostInformation{ + // BillingMeterDetails: []*armedgeorder.BillingMeterDetails{ + // }, + // }, + // DisplayName: to.Ptr("Azure Stack Edge Pro - 1 GPU"), + // HierarchyInformation: &armedgeorder.HierarchyInformation{ + // ConfigurationName: to.Ptr("edgep_base"), + // ProductFamilyName: to.Ptr("azurestackedge"), + // ProductLineName: to.Ptr("azurestackedge"), + // ProductName: to.Ptr("azurestackedgegpu"), + // }, + // ImageInformation: []*armedgeorder.ImageInformation{ + // }, + // FilterableProperties: []*armedgeorder.FilterableProperty{ + // { + // Type: to.Ptr(armedgeorder.SupportedFilterTypesShipToCountries), + // SupportedValues: []*string{ + // to.Ptr("US")}, + // }}, + // Dimensions: &armedgeorder.Dimensions{ + // Depth: to.Ptr[float64](2), + // Height: to.Ptr[float64](15), + // Length: to.Ptr[float64](50), + // LengthHeightUnit: to.Ptr(armedgeorder.LengthHeightUnitIN), + // Weight: to.Ptr[float64](50), + // WeightUnit: to.Ptr(armedgeorder.WeightMeasurementUnitLBS), + // Width: to.Ptr[float64](5), + // }, + // Specifications: []*armedgeorder.Specification{ + // { + // Name: to.Ptr("Usable compute"), + // Value: to.Ptr("40 vCPU"), + // }, + // { + // Name: to.Ptr("Usable memory"), + // Value: to.Ptr("102 GB"), + // }, + // { + // Name: to.Ptr("Usable storage"), + // Value: to.Ptr("4.2 TB"), + // }}, + // }, + // }}, + // }, + // }}, + // }, + // }}, + // ResourceProviderDetails: []*armedgeorder.ResourceProviderDetails{ + // { + // ResourceProviderNamespace: to.Ptr("Microsoft.DataBoxEdge"), + // }}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListConfigurations.json +func ExampleManagementClient_NewListConfigurationsPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewManagementClient().NewListConfigurationsPager(armedgeorder.ConfigurationsRequest{ + ConfigurationFilters: []*armedgeorder.ConfigurationFilters{ + { + FilterableProperty: []*armedgeorder.FilterableProperty{ + { + Type: to.Ptr(armedgeorder.SupportedFilterTypesShipToCountries), + SupportedValues: []*string{ + to.Ptr("US")}, + }}, + HierarchyInformation: &armedgeorder.HierarchyInformation{ + ProductFamilyName: to.Ptr("azurestackedge"), + ProductLineName: to.Ptr("azurestackedge"), + ProductName: to.Ptr("azurestackedgegpu"), + }, + }}, + }, &armedgeorder.ManagementClientListConfigurationsOptions{SkipToken: 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.Configurations = armedgeorder.Configurations{ + // Value: []*armedgeorder.Configuration{ + // { + // Properties: &armedgeorder.ConfigurationProperties{ + // Description: &armedgeorder.Description{ + // Attributes: []*string{ + // }, + // DescriptionType: to.Ptr(armedgeorder.DescriptionTypeBase), + // Keywords: []*string{ + // to.Ptr("GPU")}, + // Links: []*armedgeorder.Link{ + // }, + // LongDescription: to.Ptr(""), + // ShortDescription: to.Ptr(""), + // }, + // AvailabilityInformation: &armedgeorder.AvailabilityInformation{ + // AvailabilityStage: to.Ptr(armedgeorder.AvailabilityStageAvailable), + // DisabledReason: to.Ptr(armedgeorder.DisabledReasonNone), + // }, + // CostInformation: &armedgeorder.CostInformation{ + // BillingMeterDetails: []*armedgeorder.BillingMeterDetails{ + // }, + // }, + // DisplayName: to.Ptr("Azure Stack Edge Pro - 1 GPU"), + // HierarchyInformation: &armedgeorder.HierarchyInformation{ + // ConfigurationName: to.Ptr("edgep_base"), + // ProductFamilyName: to.Ptr("azurestackedge"), + // ProductLineName: to.Ptr("azurestackedge"), + // ProductName: to.Ptr("azurestackedgegpu"), + // }, + // ImageInformation: []*armedgeorder.ImageInformation{ + // }, + // FilterableProperties: []*armedgeorder.FilterableProperty{ + // { + // Type: to.Ptr(armedgeorder.SupportedFilterTypesShipToCountries), + // SupportedValues: []*string{ + // to.Ptr("US")}, + // }}, + // Dimensions: &armedgeorder.Dimensions{ + // Depth: to.Ptr[float64](2), + // Height: to.Ptr[float64](15), + // Length: to.Ptr[float64](50), + // LengthHeightUnit: to.Ptr(armedgeorder.LengthHeightUnitIN), + // Weight: to.Ptr[float64](50), + // WeightUnit: to.Ptr(armedgeorder.WeightMeasurementUnitLBS), + // Width: to.Ptr[float64](5), + // }, + // Specifications: []*armedgeorder.Specification{ + // { + // Name: to.Ptr("Usable compute"), + // Value: to.Ptr("40 vCPU"), + // }, + // { + // Name: to.Ptr("Usable memory"), + // Value: to.Ptr("102 GB"), + // }, + // { + // Name: to.Ptr("Usable storage"), + // Value: to.Ptr("4.2 TB"), + // }}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListProductFamiliesMetadata.json +func ExampleManagementClient_NewListProductFamiliesMetadataPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewManagementClient().NewListProductFamiliesMetadataPager(&armedgeorder.ManagementClientListProductFamiliesMetadataOptions{SkipToken: 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.ProductFamiliesMetadata = armedgeorder.ProductFamiliesMetadata{ + // Value: []*armedgeorder.ProductFamiliesMetadataDetails{ + // { + // Properties: &armedgeorder.ProductFamilyProperties{ + // Description: &armedgeorder.Description{ + // Attributes: []*string{ + // }, + // DescriptionType: to.Ptr(armedgeorder.DescriptionTypeBase), + // Keywords: []*string{ + // }, + // Links: []*armedgeorder.Link{ + // }, + // ShortDescription: to.Ptr("Azure managed physical edge compute device"), + // }, + // AvailabilityInformation: &armedgeorder.AvailabilityInformation{ + // AvailabilityStage: to.Ptr(armedgeorder.AvailabilityStageAvailable), + // DisabledReason: to.Ptr(armedgeorder.DisabledReasonNone), + // }, + // DisplayName: to.Ptr("Azure Stack Edge"), + // HierarchyInformation: &armedgeorder.HierarchyInformation{ + // ConfigurationName: to.Ptr(""), + // ProductFamilyName: to.Ptr("azurestackedge"), + // ProductLineName: to.Ptr(""), + // ProductName: to.Ptr(""), + // }, + // ImageInformation: []*armedgeorder.ImageInformation{ + // }, + // FilterableProperties: []*armedgeorder.FilterableProperty{ + // { + // Type: to.Ptr(armedgeorder.SupportedFilterTypesShipToCountries), + // SupportedValues: []*string{ + // to.Ptr("US")}, + // }, + // { + // Type: to.Ptr(armedgeorder.SupportedFilterTypesDoubleEncryptionStatus), + // SupportedValues: []*string{ + // to.Ptr("Enabled")}, + // }}, + // ProductLines: []*armedgeorder.ProductLine{ + // }, + // ResourceProviderDetails: []*armedgeorder.ResourceProviderDetails{ + // { + // ResourceProviderNamespace: to.Ptr("Microsoft.DataBoxEdge"), + // }}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListOrderAtSubscriptionLevel.json +func ExampleManagementClient_NewListOrderAtSubscriptionLevelPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewManagementClient().NewListOrderAtSubscriptionLevelPager(&armedgeorder.ManagementClientListOrderAtSubscriptionLevelOptions{SkipToken: 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.OrderResourceList = armedgeorder.OrderResourceList{ + // Value: []*armedgeorder.OrderResource{ + // { + // Name: to.Ptr("TestOrderItemName1"), + // Type: to.Ptr("Microsoft.EdgeOrder/orders"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/locations/eastus/orders/TestOrderName1"), + // Properties: &armedgeorder.OrderProperties{ + // CurrentStage: &armedgeorder.StageDetails{ + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:55:46.9437439+05:30"); return t}()), + // }, + // OrderItemIDs: []*string{ + // to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/orderItems/TestOrderItemName1")}, + // OrderStageHistory: []*armedgeorder.StageDetails{ + // { + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:55:46.9437439+05:30"); return t}()), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameInReview), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }}, + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("TestOrderItemName2"), + // Type: to.Ptr("Microsoft.EdgeOrder/orders"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/locations/eastus/orders/TestOrderName2"), + // Properties: &armedgeorder.OrderProperties{ + // CurrentStage: &armedgeorder.StageDetails{ + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusInProgress), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:58:46.5241979+05:30"); return t}()), + // }, + // OrderItemIDs: []*string{ + // to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/orderItems/TestOrderItemName2")}, + // OrderStageHistory: []*armedgeorder.StageDetails{ + // { + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameInReview), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }}, + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListOrderItemsAtSubscriptionLevel.json +func ExampleManagementClient_NewListOrderItemsAtSubscriptionLevelPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewManagementClient().NewListOrderItemsAtSubscriptionLevelPager(&armedgeorder.ManagementClientListOrderItemsAtSubscriptionLevelOptions{Filter: nil, + Expand: nil, + SkipToken: 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.OrderItemResourceList = armedgeorder.OrderItemResourceList{ + // Value: []*armedgeorder.OrderItemResource{ + // { + // Name: to.Ptr("TestOrderItemName1"), + // Type: to.Ptr("Microsoft.EdgeOrder/orderItems"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/orderItems/TestOrderItemName1"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armedgeorder.OrderItemProperties{ + // AddressDetails: &armedgeorder.AddressDetails{ + // ForwardAddress: &armedgeorder.AddressProperties{ + // AddressValidationStatus: to.Ptr(armedgeorder.AddressValidationStatusValid), + // ContactDetails: &armedgeorder.ContactDetails{ + // ContactName: to.Ptr("XXXX XXXX"), + // EmailList: []*string{ + // to.Ptr("xxxx@xxxx.xxx")}, + // Phone: to.Ptr("0000000000"), + // PhoneExtension: to.Ptr(""), + // }, + // ShippingAddress: &armedgeorder.ShippingAddress{ + // AddressType: to.Ptr(armedgeorder.AddressTypeNone), + // City: to.Ptr("San Francisco"), + // CompanyName: to.Ptr("Microsoft"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("94107"), + // StateOrProvince: to.Ptr("CA"), + // StreetAddress1: to.Ptr("16 TOWNSEND ST"), + // StreetAddress2: to.Ptr("UNIT 1"), + // }, + // }, + // }, + // OrderID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/locations/eastus/orders/TestOrderName1"), + // OrderItemDetails: &armedgeorder.OrderItemDetails{ + // CancellationStatus: to.Ptr(armedgeorder.OrderItemCancellationEnumNotCancellable), + // CurrentStage: &armedgeorder.StageDetails{ + // StageName: to.Ptr(armedgeorder.StageNameConfirmed), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:05:00.3575338+05:30"); return t}()), + // }, + // DeletionStatus: to.Ptr(armedgeorder.ActionStatusEnumNotAllowed), + // ManagementRpDetailsList: []*armedgeorder.ResourceProviderDetails{ + // { + // ResourceProviderNamespace: to.Ptr("Microsoft.DataBoxEdge"), + // }}, + // NotificationEmailList: []*string{ + // }, + // OrderItemStageHistory: []*armedgeorder.StageDetails{ + // { + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:55:54.3427968+05:30"); return t}()), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameConfirmed), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:05:00.3575338+05:30"); return t}()), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameReadyToShip), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameShipped), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameDelivered), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameInUse), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }}, + // OrderItemType: to.Ptr(armedgeorder.OrderItemTypePurchase), + // Preferences: &armedgeorder.Preferences{ + // TransportPreferences: &armedgeorder.TransportPreferences{ + // PreferredShipmentType: to.Ptr(armedgeorder.TransportShipmentTypesMicrosoftManaged), + // }, + // }, + // ProductDetails: &armedgeorder.ProductDetails{ + // Count: to.Ptr[int32](0), + // DisplayInfo: &armedgeorder.DisplayInfo{ + // ConfigurationDisplayName: to.Ptr("Azure Stack Edge Pro - 1 GPU"), + // ProductFamilyDisplayName: to.Ptr("Azure Stack Edge"), + // }, + // HierarchyInformation: &armedgeorder.HierarchyInformation{ + // ConfigurationName: to.Ptr("edgep_base"), + // ProductFamilyName: to.Ptr("azurestackedge"), + // ProductLineName: to.Ptr("azurestackedge"), + // ProductName: to.Ptr("azurestackedgegpu"), + // }, + // ProductDoubleEncryptionStatus: to.Ptr(armedgeorder.DoubleEncryptionStatusDisabled), + // }, + // ReturnStatus: to.Ptr(armedgeorder.OrderItemReturnEnumNotReturnable), + // }, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:55:10.2820482+05:30"); return t}()), + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("TestOrderItemName2"), + // Type: to.Ptr("Microsoft.EdgeOrder/orderItems"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/orderItems/TestOrderItemName2"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armedgeorder.OrderItemProperties{ + // AddressDetails: &armedgeorder.AddressDetails{ + // ForwardAddress: &armedgeorder.AddressProperties{ + // AddressValidationStatus: to.Ptr(armedgeorder.AddressValidationStatusValid), + // ContactDetails: &armedgeorder.ContactDetails{ + // ContactName: to.Ptr("XXXX XXXX"), + // EmailList: []*string{ + // to.Ptr("xxxx@xxxx.xxx")}, + // Phone: to.Ptr("0000000000"), + // PhoneExtension: to.Ptr(""), + // }, + // ShippingAddress: &armedgeorder.ShippingAddress{ + // AddressType: to.Ptr(armedgeorder.AddressTypeNone), + // City: to.Ptr("San Francisco"), + // CompanyName: to.Ptr("Microsoft"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("94107"), + // StateOrProvince: to.Ptr("CA"), + // StreetAddress1: to.Ptr("16 TOWNSEND ST"), + // StreetAddress2: to.Ptr("UNIT 1"), + // }, + // }, + // }, + // OrderID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/locations/eastus/orders/TestOrderName2"), + // OrderItemDetails: &armedgeorder.OrderItemDetails{ + // CancellationStatus: to.Ptr(armedgeorder.OrderItemCancellationEnumNotCancellable), + // CurrentStage: &armedgeorder.StageDetails{ + // StageName: to.Ptr(armedgeorder.StageNameConfirmed), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:07:29.9896685+05:30"); return t}()), + // }, + // DeletionStatus: to.Ptr(armedgeorder.ActionStatusEnumNotAllowed), + // ManagementRpDetailsList: []*armedgeorder.ResourceProviderDetails{ + // { + // ResourceProviderNamespace: to.Ptr("Microsoft.DataBoxEdge"), + // }}, + // NotificationEmailList: []*string{ + // }, + // OrderItemStageHistory: []*armedgeorder.StageDetails{ + // { + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:59:04.9701334+05:30"); return t}()), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameConfirmed), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:07:29.9896685+05:30"); return t}()), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameReadyToShip), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameShipped), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameDelivered), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameInUse), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }}, + // OrderItemType: to.Ptr(armedgeorder.OrderItemTypePurchase), + // Preferences: &armedgeorder.Preferences{ + // TransportPreferences: &armedgeorder.TransportPreferences{ + // PreferredShipmentType: to.Ptr(armedgeorder.TransportShipmentTypesMicrosoftManaged), + // }, + // }, + // ProductDetails: &armedgeorder.ProductDetails{ + // Count: to.Ptr[int32](0), + // DisplayInfo: &armedgeorder.DisplayInfo{ + // ConfigurationDisplayName: to.Ptr("Azure Stack Edge Pro - 1 GPU"), + // ProductFamilyDisplayName: to.Ptr("Azure Stack Edge"), + // }, + // HierarchyInformation: &armedgeorder.HierarchyInformation{ + // ConfigurationName: to.Ptr("edgep_base"), + // ProductFamilyName: to.Ptr("azurestackedge"), + // ProductLineName: to.Ptr("azurestackedge"), + // ProductName: to.Ptr("azurestackedgegpu"), + // }, + // ProductDoubleEncryptionStatus: to.Ptr(armedgeorder.DoubleEncryptionStatusDisabled), + // }, + // ReturnStatus: to.Ptr(armedgeorder.OrderItemReturnEnumNotReturnable), + // }, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:58:27.5824859+05:30"); return t}()), + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListAddressesAtResourceGroupLevel.json +func ExampleManagementClient_NewListAddressesAtResourceGroupLevelPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewManagementClient().NewListAddressesAtResourceGroupLevelPager("YourResourceGroupName", &armedgeorder.ManagementClientListAddressesAtResourceGroupLevelOptions{Filter: nil, + SkipToken: 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.AddressResourceList = armedgeorder.AddressResourceList{ + // Value: []*armedgeorder.AddressResource{ + // { + // Name: to.Ptr("TestAddressName1"), + // Type: to.Ptr("Microsoft.EdgeOrder/addresses"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/addresses/TestAddressName1"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armedgeorder.AddressProperties{ + // AddressValidationStatus: to.Ptr(armedgeorder.AddressValidationStatusValid), + // ContactDetails: &armedgeorder.ContactDetails{ + // ContactName: to.Ptr("XXXX XXXX"), + // EmailList: []*string{ + // to.Ptr("xxxx@xxxx.xxx")}, + // Phone: to.Ptr("0000000000"), + // PhoneExtension: to.Ptr(""), + // }, + // ShippingAddress: &armedgeorder.ShippingAddress{ + // AddressType: to.Ptr(armedgeorder.AddressTypeNone), + // City: to.Ptr("San Francisco"), + // CompanyName: to.Ptr("Microsoft"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("94107"), + // StateOrProvince: to.Ptr("CA"), + // StreetAddress1: to.Ptr("16 TOWNSEND ST"), + // StreetAddress2: to.Ptr("UNIT 1"), + // }, + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("TestAddressName2"), + // Type: to.Ptr("Microsoft.EdgeOrder/addresses"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/addresses/TestAddressName2"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armedgeorder.AddressProperties{ + // AddressValidationStatus: to.Ptr(armedgeorder.AddressValidationStatusValid), + // ContactDetails: &armedgeorder.ContactDetails{ + // ContactName: to.Ptr("YYYY YYYY"), + // EmailList: []*string{ + // to.Ptr("xxxx@xxxx.xxx")}, + // Phone: to.Ptr("0000000000"), + // PhoneExtension: to.Ptr(""), + // }, + // ShippingAddress: &armedgeorder.ShippingAddress{ + // AddressType: to.Ptr(armedgeorder.AddressTypeNone), + // City: to.Ptr("San Francisco"), + // CompanyName: to.Ptr("Microsoft"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("94107"), + // StateOrProvince: to.Ptr("CA"), + // StreetAddress1: to.Ptr("16 TOWNSEND ST"), + // StreetAddress2: to.Ptr("UNIT 1"), + // }, + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/GetAddressByName.json +func ExampleManagementClient_GetAddressByName() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewManagementClient().GetAddressByName(ctx, "TestAddressName1", "YourResourceGroupName", 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.AddressResource = armedgeorder.AddressResource{ + // Name: to.Ptr("TestAddressName1"), + // Type: to.Ptr("Microsoft.EdgeOrder/addresses"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/addresses/TestAddressName1"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armedgeorder.AddressProperties{ + // AddressValidationStatus: to.Ptr(armedgeorder.AddressValidationStatusValid), + // ContactDetails: &armedgeorder.ContactDetails{ + // ContactName: to.Ptr("XXXX XXXX"), + // EmailList: []*string{ + // to.Ptr("xxxx@xxxx.xxx")}, + // Phone: to.Ptr("0000000000"), + // PhoneExtension: to.Ptr(""), + // }, + // ShippingAddress: &armedgeorder.ShippingAddress{ + // AddressType: to.Ptr(armedgeorder.AddressTypeNone), + // City: to.Ptr("San Francisco"), + // CompanyName: to.Ptr("Microsoft"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("94107"), + // StateOrProvince: to.Ptr("CA"), + // StreetAddress1: to.Ptr("16 TOWNSEND ST"), + // StreetAddress2: to.Ptr("UNIT 1"), + // }, + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/CreateAddress.json +func ExampleManagementClient_BeginCreateAddress() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewManagementClient().BeginCreateAddress(ctx, "TestAddressName2", "YourResourceGroupName", armedgeorder.AddressResource{ + Location: to.Ptr("eastus"), + Properties: &armedgeorder.AddressProperties{ + ContactDetails: &armedgeorder.ContactDetails{ + ContactName: to.Ptr("XXXX XXXX"), + EmailList: []*string{ + to.Ptr("xxxx@xxxx.xxx")}, + Phone: to.Ptr("0000000000"), + PhoneExtension: to.Ptr(""), + }, + ShippingAddress: &armedgeorder.ShippingAddress{ + AddressType: to.Ptr(armedgeorder.AddressTypeNone), + City: to.Ptr("San Francisco"), + CompanyName: to.Ptr("Microsoft"), + Country: to.Ptr("US"), + PostalCode: to.Ptr("94107"), + StateOrProvince: to.Ptr("CA"), + StreetAddress1: to.Ptr("16 TOWNSEND ST"), + StreetAddress2: to.Ptr("UNIT 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.AddressResource = armedgeorder.AddressResource{ + // Name: to.Ptr("TestAddressName2"), + // Type: to.Ptr("Microsoft.EdgeOrder/addresses"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/addresses/TestAddressName2"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armedgeorder.AddressProperties{ + // AddressValidationStatus: to.Ptr(armedgeorder.AddressValidationStatusValid), + // ContactDetails: &armedgeorder.ContactDetails{ + // ContactName: to.Ptr("XXXX XXXX"), + // EmailList: []*string{ + // to.Ptr("xxxx@xxxx.xxx")}, + // Phone: to.Ptr("0000000000"), + // PhoneExtension: to.Ptr(""), + // }, + // ShippingAddress: &armedgeorder.ShippingAddress{ + // AddressType: to.Ptr(armedgeorder.AddressTypeNone), + // City: to.Ptr("San Francisco"), + // CompanyName: to.Ptr("Microsoft"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("94107"), + // StateOrProvince: to.Ptr("CA"), + // StreetAddress1: to.Ptr("16 TOWNSEND ST"), + // StreetAddress2: to.Ptr("UNIT 1"), + // }, + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/DeleteAddressByName.json +func ExampleManagementClient_BeginDeleteAddressByName() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewManagementClient().BeginDeleteAddressByName(ctx, "TestAddressName1", "YourResourceGroupName", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/UpdateAddress.json +func ExampleManagementClient_BeginUpdateAddress() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewManagementClient().BeginUpdateAddress(ctx, "TestAddressName2", "YourResourceGroupName", armedgeorder.AddressUpdateParameter{ + Properties: &armedgeorder.AddressUpdateProperties{ + ContactDetails: &armedgeorder.ContactDetails{ + ContactName: to.Ptr("YYYY YYYY"), + EmailList: []*string{ + to.Ptr("xxxx@xxxx.xxx")}, + Phone: to.Ptr("0000000000"), + PhoneExtension: to.Ptr(""), + }, + ShippingAddress: &armedgeorder.ShippingAddress{ + AddressType: to.Ptr(armedgeorder.AddressTypeNone), + City: to.Ptr("San Francisco"), + CompanyName: to.Ptr("Microsoft"), + Country: to.Ptr("US"), + PostalCode: to.Ptr("94107"), + StateOrProvince: to.Ptr("CA"), + StreetAddress1: to.Ptr("16 TOWNSEND ST"), + StreetAddress2: to.Ptr("UNIT 1"), + }, + }, + Tags: map[string]*string{ + "tag1": to.Ptr("value1"), + "tag2": to.Ptr("value2"), + }, + }, &armedgeorder.ManagementClientBeginUpdateAddressOptions{IfMatch: 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.AddressResource = armedgeorder.AddressResource{ + // Name: to.Ptr("TestAddressName2"), + // Type: to.Ptr("Microsoft.EdgeOrder/addresses"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/addresses/TestAddressName2"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armedgeorder.AddressProperties{ + // AddressValidationStatus: to.Ptr(armedgeorder.AddressValidationStatusValid), + // ContactDetails: &armedgeorder.ContactDetails{ + // ContactName: to.Ptr("YYYY YYYY"), + // EmailList: []*string{ + // to.Ptr("xxxx@xxxx.xxx")}, + // Phone: to.Ptr("0000000000"), + // PhoneExtension: to.Ptr(""), + // }, + // ShippingAddress: &armedgeorder.ShippingAddress{ + // AddressType: to.Ptr(armedgeorder.AddressTypeNone), + // City: to.Ptr("San Francisco"), + // CompanyName: to.Ptr("Microsoft"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("94107"), + // StateOrProvince: to.Ptr("CA"), + // StreetAddress1: to.Ptr("16 TOWNSEND ST"), + // StreetAddress2: to.Ptr("UNIT 1"), + // }, + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListOrderAtResourceGroupLevel.json +func ExampleManagementClient_NewListOrderAtResourceGroupLevelPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewManagementClient().NewListOrderAtResourceGroupLevelPager("YourResourceGroupName", &armedgeorder.ManagementClientListOrderAtResourceGroupLevelOptions{SkipToken: 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.OrderResourceList = armedgeorder.OrderResourceList{ + // Value: []*armedgeorder.OrderResource{ + // { + // Name: to.Ptr("TestOrderItemName1"), + // Type: to.Ptr("Microsoft.EdgeOrder/orders"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/locations/eastus/orders/TestOrderName1"), + // Properties: &armedgeorder.OrderProperties{ + // CurrentStage: &armedgeorder.StageDetails{ + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:55:46.9437439+05:30"); return t}()), + // }, + // OrderItemIDs: []*string{ + // to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/orderItems/TestOrderItemName1")}, + // OrderStageHistory: []*armedgeorder.StageDetails{ + // { + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:55:46.9437439+05:30"); return t}()), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameInReview), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }}, + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("TestOrderItemName2"), + // Type: to.Ptr("Microsoft.EdgeOrder/orders"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/locations/eastus/orders/TestOrderName2"), + // Properties: &armedgeorder.OrderProperties{ + // CurrentStage: &armedgeorder.StageDetails{ + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusInProgress), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:58:46.5241979+05:30"); return t}()), + // }, + // OrderItemIDs: []*string{ + // to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/orderItems/TestOrderItemName2")}, + // OrderStageHistory: []*armedgeorder.StageDetails{ + // { + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameInReview), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }}, + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/GetOrderByName.json +func ExampleManagementClient_GetOrderByName() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewManagementClient().GetOrderByName(ctx, "TestOrderName3", "YourResourceGroupName", "eastus", 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.OrderResource = armedgeorder.OrderResource{ + // Name: to.Ptr("TestOrderName3"), + // Type: to.Ptr("Microsoft.EdgeOrder/orders"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/locations/eastus/orders/TestOrderName3"), + // Properties: &armedgeorder.OrderProperties{ + // CurrentStage: &armedgeorder.StageDetails{ + // StageName: to.Ptr(armedgeorder.StageNameInReview), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:35:20.8521455+05:30"); return t}()), + // }, + // OrderItemIDs: []*string{ + // to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/orderItems/TestOrderItemName3")}, + // OrderStageHistory: []*armedgeorder.StageDetails{ + // { + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:30:30.2717243+05:30"); return t}()), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameInReview), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:35:20.8521455+05:30"); return t}()), + // }}, + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListOrderItemsAtResourceGroupLevel.json +func ExampleManagementClient_NewListOrderItemsAtResourceGroupLevelPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewManagementClient().NewListOrderItemsAtResourceGroupLevelPager("YourResourceGroupName", &armedgeorder.ManagementClientListOrderItemsAtResourceGroupLevelOptions{Filter: nil, + Expand: nil, + SkipToken: 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.OrderItemResourceList = armedgeorder.OrderItemResourceList{ + // Value: []*armedgeorder.OrderItemResource{ + // { + // Name: to.Ptr("TestOrderItemName1"), + // Type: to.Ptr("Microsoft.EdgeOrder/orderItems"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/orderItems/TestOrderItemName1"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armedgeorder.OrderItemProperties{ + // AddressDetails: &armedgeorder.AddressDetails{ + // ForwardAddress: &armedgeorder.AddressProperties{ + // AddressValidationStatus: to.Ptr(armedgeorder.AddressValidationStatusValid), + // ContactDetails: &armedgeorder.ContactDetails{ + // ContactName: to.Ptr("XXXX XXXX"), + // EmailList: []*string{ + // to.Ptr("xxxx@xxxx.xxx")}, + // Phone: to.Ptr("0000000000"), + // PhoneExtension: to.Ptr(""), + // }, + // ShippingAddress: &armedgeorder.ShippingAddress{ + // AddressType: to.Ptr(armedgeorder.AddressTypeNone), + // City: to.Ptr("San Francisco"), + // CompanyName: to.Ptr("Microsoft"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("94107"), + // StateOrProvince: to.Ptr("CA"), + // StreetAddress1: to.Ptr("16 TOWNSEND ST"), + // StreetAddress2: to.Ptr("UNIT 1"), + // }, + // }, + // }, + // OrderID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/locations/eastus/orders/TestOrderName1"), + // OrderItemDetails: &armedgeorder.OrderItemDetails{ + // CancellationStatus: to.Ptr(armedgeorder.OrderItemCancellationEnumNotCancellable), + // CurrentStage: &armedgeorder.StageDetails{ + // StageName: to.Ptr(armedgeorder.StageNameConfirmed), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:05:00.3575338+05:30"); return t}()), + // }, + // DeletionStatus: to.Ptr(armedgeorder.ActionStatusEnumNotAllowed), + // ManagementRpDetailsList: []*armedgeorder.ResourceProviderDetails{ + // { + // ResourceProviderNamespace: to.Ptr("Microsoft.DataBoxEdge"), + // }}, + // NotificationEmailList: []*string{ + // }, + // OrderItemStageHistory: []*armedgeorder.StageDetails{ + // { + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:55:54.3427968+05:30"); return t}()), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameConfirmed), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:05:00.3575338+05:30"); return t}()), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameReadyToShip), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameShipped), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameDelivered), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameInUse), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }}, + // OrderItemType: to.Ptr(armedgeorder.OrderItemTypePurchase), + // Preferences: &armedgeorder.Preferences{ + // TransportPreferences: &armedgeorder.TransportPreferences{ + // PreferredShipmentType: to.Ptr(armedgeorder.TransportShipmentTypesMicrosoftManaged), + // }, + // }, + // ProductDetails: &armedgeorder.ProductDetails{ + // Count: to.Ptr[int32](0), + // DisplayInfo: &armedgeorder.DisplayInfo{ + // ConfigurationDisplayName: to.Ptr("Azure Stack Edge Pro - 1 GPU"), + // ProductFamilyDisplayName: to.Ptr("Azure Stack Edge"), + // }, + // HierarchyInformation: &armedgeorder.HierarchyInformation{ + // ConfigurationName: to.Ptr("edgep_base"), + // ProductFamilyName: to.Ptr("azurestackedge"), + // ProductLineName: to.Ptr("azurestackedge"), + // ProductName: to.Ptr("azurestackedgegpu"), + // }, + // ProductDoubleEncryptionStatus: to.Ptr(armedgeorder.DoubleEncryptionStatusDisabled), + // }, + // ReturnStatus: to.Ptr(armedgeorder.OrderItemReturnEnumNotReturnable), + // }, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:55:10.2820482+05:30"); return t}()), + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("TestOrderItemName2"), + // Type: to.Ptr("Microsoft.EdgeOrder/orderItems"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/orderItems/TestOrderItemName2"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armedgeorder.OrderItemProperties{ + // AddressDetails: &armedgeorder.AddressDetails{ + // ForwardAddress: &armedgeorder.AddressProperties{ + // AddressValidationStatus: to.Ptr(armedgeorder.AddressValidationStatusValid), + // ContactDetails: &armedgeorder.ContactDetails{ + // ContactName: to.Ptr("XXXX XXXX"), + // EmailList: []*string{ + // to.Ptr("xxxx@xxxx.xxx")}, + // Phone: to.Ptr("0000000000"), + // PhoneExtension: to.Ptr(""), + // }, + // ShippingAddress: &armedgeorder.ShippingAddress{ + // AddressType: to.Ptr(armedgeorder.AddressTypeNone), + // City: to.Ptr("San Francisco"), + // CompanyName: to.Ptr("Microsoft"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("94107"), + // StateOrProvince: to.Ptr("CA"), + // StreetAddress1: to.Ptr("16 TOWNSEND ST"), + // StreetAddress2: to.Ptr("UNIT 1"), + // }, + // }, + // }, + // OrderID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/locations/eastus/orders/TestOrderName2"), + // OrderItemDetails: &armedgeorder.OrderItemDetails{ + // CancellationStatus: to.Ptr(armedgeorder.OrderItemCancellationEnumNotCancellable), + // CurrentStage: &armedgeorder.StageDetails{ + // StageName: to.Ptr(armedgeorder.StageNameConfirmed), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:07:29.9896685+05:30"); return t}()), + // }, + // DeletionStatus: to.Ptr(armedgeorder.ActionStatusEnumNotAllowed), + // ManagementRpDetailsList: []*armedgeorder.ResourceProviderDetails{ + // { + // ResourceProviderNamespace: to.Ptr("Microsoft.DataBoxEdge"), + // }}, + // NotificationEmailList: []*string{ + // }, + // OrderItemStageHistory: []*armedgeorder.StageDetails{ + // { + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:59:04.9701334+05:30"); return t}()), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameConfirmed), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:07:29.9896685+05:30"); return t}()), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameReadyToShip), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameShipped), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameDelivered), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameInUse), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }}, + // OrderItemType: to.Ptr(armedgeorder.OrderItemTypePurchase), + // Preferences: &armedgeorder.Preferences{ + // TransportPreferences: &armedgeorder.TransportPreferences{ + // PreferredShipmentType: to.Ptr(armedgeorder.TransportShipmentTypesMicrosoftManaged), + // }, + // }, + // ProductDetails: &armedgeorder.ProductDetails{ + // Count: to.Ptr[int32](0), + // DisplayInfo: &armedgeorder.DisplayInfo{ + // ConfigurationDisplayName: to.Ptr("Azure Stack Edge Pro - 1 GPU"), + // ProductFamilyDisplayName: to.Ptr("Azure Stack Edge"), + // }, + // HierarchyInformation: &armedgeorder.HierarchyInformation{ + // ConfigurationName: to.Ptr("edgep_base"), + // ProductFamilyName: to.Ptr("azurestackedge"), + // ProductLineName: to.Ptr("azurestackedge"), + // ProductName: to.Ptr("azurestackedgegpu"), + // }, + // ProductDoubleEncryptionStatus: to.Ptr(armedgeorder.DoubleEncryptionStatusDisabled), + // }, + // ReturnStatus: to.Ptr(armedgeorder.OrderItemReturnEnumNotReturnable), + // }, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:58:27.5824859+05:30"); return t}()), + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/GetOrderItemByName.json +func ExampleManagementClient_GetOrderItemByName() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewManagementClient().GetOrderItemByName(ctx, "TestOrderItemName1", "YourResourceGroupName", &armedgeorder.ManagementClientGetOrderItemByNameOptions{Expand: 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.OrderItemResource = armedgeorder.OrderItemResource{ + // Name: to.Ptr("TestOrderItemName1"), + // Type: to.Ptr("Microsoft.EdgeOrder/orderItems"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/orderItems/TestOrderItemName1"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armedgeorder.OrderItemProperties{ + // AddressDetails: &armedgeorder.AddressDetails{ + // ForwardAddress: &armedgeorder.AddressProperties{ + // AddressValidationStatus: to.Ptr(armedgeorder.AddressValidationStatusValid), + // ContactDetails: &armedgeorder.ContactDetails{ + // ContactName: to.Ptr("XXXX XXXX"), + // EmailList: []*string{ + // to.Ptr("xxxx@xxxx.xxx")}, + // Phone: to.Ptr("0000000000"), + // PhoneExtension: to.Ptr(""), + // }, + // ShippingAddress: &armedgeorder.ShippingAddress{ + // AddressType: to.Ptr(armedgeorder.AddressTypeNone), + // City: to.Ptr("San Francisco"), + // CompanyName: to.Ptr("Microsoft"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("94107"), + // StateOrProvince: to.Ptr("CA"), + // StreetAddress1: to.Ptr("16 TOWNSEND ST"), + // StreetAddress2: to.Ptr("UNIT 1"), + // }, + // }, + // }, + // OrderID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/locations/eastus/orders/TestOrderName1"), + // OrderItemDetails: &armedgeorder.OrderItemDetails{ + // CancellationStatus: to.Ptr(armedgeorder.OrderItemCancellationEnumNotCancellable), + // CurrentStage: &armedgeorder.StageDetails{ + // StageName: to.Ptr(armedgeorder.StageNameConfirmed), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:05:00.3575338+05:30"); return t}()), + // }, + // DeletionStatus: to.Ptr(armedgeorder.ActionStatusEnumNotAllowed), + // ManagementRpDetailsList: []*armedgeorder.ResourceProviderDetails{ + // { + // ResourceProviderNamespace: to.Ptr("Microsoft.DataBoxEdge"), + // }}, + // NotificationEmailList: []*string{ + // }, + // OrderItemStageHistory: []*armedgeorder.StageDetails{ + // { + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:55:54.3427968+05:30"); return t}()), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameConfirmed), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:05:00.3575338+05:30"); return t}()), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameReadyToShip), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameShipped), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameDelivered), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameInUse), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }}, + // OrderItemType: to.Ptr(armedgeorder.OrderItemTypePurchase), + // Preferences: &armedgeorder.Preferences{ + // TransportPreferences: &armedgeorder.TransportPreferences{ + // PreferredShipmentType: to.Ptr(armedgeorder.TransportShipmentTypesMicrosoftManaged), + // }, + // }, + // ProductDetails: &armedgeorder.ProductDetails{ + // Count: to.Ptr[int32](0), + // DisplayInfo: &armedgeorder.DisplayInfo{ + // ConfigurationDisplayName: to.Ptr("Azure Stack Edge Pro - 1 GPU"), + // ProductFamilyDisplayName: to.Ptr("Azure Stack Edge"), + // }, + // HierarchyInformation: &armedgeorder.HierarchyInformation{ + // ConfigurationName: to.Ptr("edgep_base"), + // ProductFamilyName: to.Ptr("azurestackedge"), + // ProductLineName: to.Ptr("azurestackedge"), + // ProductName: to.Ptr("azurestackedgegpu"), + // }, + // ProductDoubleEncryptionStatus: to.Ptr(armedgeorder.DoubleEncryptionStatusDisabled), + // }, + // ReturnStatus: to.Ptr(armedgeorder.OrderItemReturnEnumNotReturnable), + // }, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:55:10.2820482+05:30"); return t}()), + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/CreateOrderItem.json +func ExampleManagementClient_BeginCreateOrderItem() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewManagementClient().BeginCreateOrderItem(ctx, "TestOrderItemName2", "YourResourceGroupName", armedgeorder.OrderItemResource{ + Location: to.Ptr("eastus"), + Properties: &armedgeorder.OrderItemProperties{ + AddressDetails: &armedgeorder.AddressDetails{ + ForwardAddress: &armedgeorder.AddressProperties{ + ContactDetails: &armedgeorder.ContactDetails{ + ContactName: to.Ptr("XXXX XXXX"), + EmailList: []*string{ + to.Ptr("xxxx@xxxx.xxx")}, + Phone: to.Ptr("0000000000"), + PhoneExtension: to.Ptr(""), + }, + ShippingAddress: &armedgeorder.ShippingAddress{ + AddressType: to.Ptr(armedgeorder.AddressTypeNone), + City: to.Ptr("San Francisco"), + CompanyName: to.Ptr("Microsoft"), + Country: to.Ptr("US"), + PostalCode: to.Ptr("94107"), + StateOrProvince: to.Ptr("CA"), + StreetAddress1: to.Ptr("16 TOWNSEND ST"), + StreetAddress2: to.Ptr("UNIT 1"), + }, + }, + }, + OrderID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/locations/eastus/orders/TestOrderName2"), + OrderItemDetails: &armedgeorder.OrderItemDetails{ + OrderItemType: to.Ptr(armedgeorder.OrderItemTypePurchase), + Preferences: &armedgeorder.Preferences{ + TransportPreferences: &armedgeorder.TransportPreferences{ + PreferredShipmentType: to.Ptr(armedgeorder.TransportShipmentTypesMicrosoftManaged), + }, + }, + ProductDetails: &armedgeorder.ProductDetails{ + HierarchyInformation: &armedgeorder.HierarchyInformation{ + ConfigurationName: to.Ptr("edgep_base"), + ProductFamilyName: to.Ptr("azurestackedge"), + ProductLineName: to.Ptr("azurestackedge"), + ProductName: to.Ptr("azurestackedgegpu"), + }, + }, + }, + }, + }, 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.OrderItemResource = armedgeorder.OrderItemResource{ + // Name: to.Ptr("TestOrderItemName2"), + // Type: to.Ptr("Microsoft.EdgeOrder/orderItems"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/orderItems/TestOrderItemName2"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armedgeorder.OrderItemProperties{ + // AddressDetails: &armedgeorder.AddressDetails{ + // ForwardAddress: &armedgeorder.AddressProperties{ + // AddressValidationStatus: to.Ptr(armedgeorder.AddressValidationStatusValid), + // ContactDetails: &armedgeorder.ContactDetails{ + // ContactName: to.Ptr("XXXX XXXX"), + // EmailList: []*string{ + // to.Ptr("xxxx@xxxx.xxx")}, + // Phone: to.Ptr("0000000000"), + // PhoneExtension: to.Ptr(""), + // }, + // ShippingAddress: &armedgeorder.ShippingAddress{ + // AddressType: to.Ptr(armedgeorder.AddressTypeNone), + // City: to.Ptr("San Francisco"), + // CompanyName: to.Ptr("Microsoft"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("94107"), + // StateOrProvince: to.Ptr("CA"), + // StreetAddress1: to.Ptr("16 TOWNSEND ST"), + // StreetAddress2: to.Ptr("UNIT 1"), + // }, + // }, + // }, + // OrderID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/locations/eastus/orders/TestOrderName2"), + // OrderItemDetails: &armedgeorder.OrderItemDetails{ + // CancellationStatus: to.Ptr(armedgeorder.OrderItemCancellationEnumCancellable), + // CurrentStage: &armedgeorder.StageDetails{ + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusInProgress), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:58:27.5824859+05:30"); return t}()), + // }, + // DeletionStatus: to.Ptr(armedgeorder.ActionStatusEnumNotAllowed), + // ManagementRpDetailsList: []*armedgeorder.ResourceProviderDetails{ + // { + // ResourceProviderNamespace: to.Ptr("Microsoft.DataBoxEdge"), + // }}, + // NotificationEmailList: []*string{ + // }, + // OrderItemStageHistory: []*armedgeorder.StageDetails{ + // { + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameConfirmed), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameReadyToShip), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameShipped), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameDelivered), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameInUse), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }}, + // OrderItemType: to.Ptr(armedgeorder.OrderItemTypePurchase), + // Preferences: &armedgeorder.Preferences{ + // TransportPreferences: &armedgeorder.TransportPreferences{ + // PreferredShipmentType: to.Ptr(armedgeorder.TransportShipmentTypesMicrosoftManaged), + // }, + // }, + // ProductDetails: &armedgeorder.ProductDetails{ + // Count: to.Ptr[int32](0), + // DisplayInfo: &armedgeorder.DisplayInfo{ + // ConfigurationDisplayName: to.Ptr("Azure Stack Edge Pro - 1 GPU"), + // ProductFamilyDisplayName: to.Ptr("Azure Stack Edge"), + // }, + // HierarchyInformation: &armedgeorder.HierarchyInformation{ + // ConfigurationName: to.Ptr("edgep_base"), + // ProductFamilyName: to.Ptr("azurestackedge"), + // ProductLineName: to.Ptr("azurestackedge"), + // ProductName: to.Ptr("azurestackedgegpu"), + // }, + // ProductDoubleEncryptionStatus: to.Ptr(armedgeorder.DoubleEncryptionStatusDisabled), + // }, + // ReturnStatus: to.Ptr(armedgeorder.OrderItemReturnEnumNotReturnable), + // }, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T10:58:27.5824859+05:30"); return t}()), + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/DeleteOrderItemByName.json +func ExampleManagementClient_BeginDeleteOrderItemByName() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewManagementClient().BeginDeleteOrderItemByName(ctx, "TestOrderItemName3", "YourResourceGroupName", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/UpdateOrderItem.json +func ExampleManagementClient_BeginUpdateOrderItem() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewManagementClient().BeginUpdateOrderItem(ctx, "TestOrderItemName3", "YourResourceGroupName", armedgeorder.OrderItemUpdateParameter{ + Properties: &armedgeorder.OrderItemUpdateProperties{ + Preferences: &armedgeorder.Preferences{ + TransportPreferences: &armedgeorder.TransportPreferences{ + PreferredShipmentType: to.Ptr(armedgeorder.TransportShipmentTypesCustomerManaged), + }, + }, + }, + }, &armedgeorder.ManagementClientBeginUpdateOrderItemOptions{IfMatch: 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.OrderItemResource = armedgeorder.OrderItemResource{ + // Name: to.Ptr("TestOrderItemName3"), + // Type: to.Ptr("Microsoft.EdgeOrder/orderItems"), + // ID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/orderItems/TestOrderItemName3"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armedgeorder.OrderItemProperties{ + // AddressDetails: &armedgeorder.AddressDetails{ + // ForwardAddress: &armedgeorder.AddressProperties{ + // AddressValidationStatus: to.Ptr(armedgeorder.AddressValidationStatusValid), + // ContactDetails: &armedgeorder.ContactDetails{ + // ContactName: to.Ptr("XXXX XXXX"), + // EmailList: []*string{ + // to.Ptr("xxxx@xxxx.xxx")}, + // Phone: to.Ptr("0000000000"), + // PhoneExtension: to.Ptr(""), + // }, + // ShippingAddress: &armedgeorder.ShippingAddress{ + // AddressType: to.Ptr(armedgeorder.AddressTypeNone), + // City: to.Ptr("San Francisco"), + // CompanyName: to.Ptr("Microsoft"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("94107"), + // StateOrProvince: to.Ptr("CA"), + // StreetAddress1: to.Ptr("16 TOWNSEND ST"), + // StreetAddress2: to.Ptr("UNIT 1"), + // }, + // }, + // }, + // OrderID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/locations/eastus/orders/TestOrderName3"), + // OrderItemDetails: &armedgeorder.OrderItemDetails{ + // CancellationStatus: to.Ptr(armedgeorder.OrderItemCancellationEnumCancellable), + // CurrentStage: &armedgeorder.StageDetails{ + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:30:31.5838042+05:30"); return t}()), + // }, + // DeletionStatus: to.Ptr(armedgeorder.ActionStatusEnumNotAllowed), + // ManagementRpDetailsList: []*armedgeorder.ResourceProviderDetails{ + // { + // ResourceProviderNamespace: to.Ptr("Microsoft.DataBoxEdge"), + // }}, + // NotificationEmailList: []*string{ + // }, + // OrderItemStageHistory: []*armedgeorder.StageDetails{ + // { + // StageName: to.Ptr(armedgeorder.StageNamePlaced), + // StageStatus: to.Ptr(armedgeorder.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:30:31.5838042+05:30"); return t}()), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameConfirmed), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameReadyToShip), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameShipped), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameDelivered), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }, + // { + // StageName: to.Ptr(armedgeorder.StageNameInUse), + // StageStatus: to.Ptr(armedgeorder.StageStatusNone), + // }}, + // OrderItemType: to.Ptr(armedgeorder.OrderItemTypePurchase), + // Preferences: &armedgeorder.Preferences{ + // TransportPreferences: &armedgeorder.TransportPreferences{ + // PreferredShipmentType: to.Ptr(armedgeorder.TransportShipmentTypesCustomerManaged), + // }, + // }, + // ProductDetails: &armedgeorder.ProductDetails{ + // Count: to.Ptr[int32](0), + // DisplayInfo: &armedgeorder.DisplayInfo{ + // ConfigurationDisplayName: to.Ptr("Azure Stack Edge Pro - 1 GPU"), + // ProductFamilyDisplayName: to.Ptr("Azure Stack Edge"), + // }, + // HierarchyInformation: &armedgeorder.HierarchyInformation{ + // ConfigurationName: to.Ptr("edgep_base"), + // ProductFamilyName: to.Ptr("azurestackedge"), + // ProductLineName: to.Ptr("azurestackedge"), + // ProductName: to.Ptr("azurestackedgegpu"), + // }, + // ProductDoubleEncryptionStatus: to.Ptr(armedgeorder.DoubleEncryptionStatusDisabled), + // }, + // ReturnStatus: to.Ptr(armedgeorder.OrderItemReturnEnumNotReturnable), + // }, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T11:29:47.3483197+05:30"); return t}()), + // }, + // SystemData: &armedgeorder.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T05:30:00+05:30"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/CancelOrderItem.json +func ExampleManagementClient_CancelOrderItem() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewManagementClient().CancelOrderItem(ctx, "TestOrderItemName3", "YourResourceGroupName", armedgeorder.CancellationReason{ + Reason: to.Ptr("Order cancelled"), + }, 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ReturnOrderItem.json +func ExampleManagementClient_BeginReturnOrderItem() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewManagementClient().BeginReturnOrderItem(ctx, "TestOrderName4", "YourResourceGroupName", armedgeorder.ReturnOrderItemDetails{ + ReturnReason: to.Ptr("Order returned"), + }, 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/edgeorder/armedgeorder/zz_generated_models.go b/sdk/resourcemanager/edgeorder/armedgeorder/models.go similarity index 98% rename from sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_models.go rename to sdk/resourcemanager/edgeorder/armedgeorder/models.go index fd2d8afb2490..d5cb5feab65c 100644 --- a/sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_models.go +++ b/sdk/resourcemanager/edgeorder/armedgeorder/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 armedgeorder @@ -350,7 +351,7 @@ type EncryptionPreferences 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"` @@ -516,7 +517,7 @@ type ManagementClientGetOrderItemByNameOptions struct { Expand *string } -// ManagementClientListAddressesAtResourceGroupLevelOptions contains the optional parameters for the ManagementClient.ListAddressesAtResourceGroupLevel +// ManagementClientListAddressesAtResourceGroupLevelOptions contains the optional parameters for the ManagementClient.NewListAddressesAtResourceGroupLevelPager // method. type ManagementClientListAddressesAtResourceGroupLevelOptions struct { // $filter is supported to filter based on shipping address properties. Filter supports only equals operation. @@ -525,7 +526,7 @@ type ManagementClientListAddressesAtResourceGroupLevelOptions struct { SkipToken *string } -// ManagementClientListAddressesAtSubscriptionLevelOptions contains the optional parameters for the ManagementClient.ListAddressesAtSubscriptionLevel +// ManagementClientListAddressesAtSubscriptionLevelOptions contains the optional parameters for the ManagementClient.NewListAddressesAtSubscriptionLevelPager // method. type ManagementClientListAddressesAtSubscriptionLevelOptions struct { // $filter is supported to filter based on shipping address properties. Filter supports only equals operation. @@ -534,33 +535,34 @@ type ManagementClientListAddressesAtSubscriptionLevelOptions struct { SkipToken *string } -// ManagementClientListConfigurationsOptions contains the optional parameters for the ManagementClient.ListConfigurations +// ManagementClientListConfigurationsOptions contains the optional parameters for the ManagementClient.NewListConfigurationsPager // method. type ManagementClientListConfigurationsOptions struct { // $skipToken is supported on list of configurations, which provides the next page in the list of configurations. SkipToken *string } -// ManagementClientListOperationsOptions contains the optional parameters for the ManagementClient.ListOperations method. +// ManagementClientListOperationsOptions contains the optional parameters for the ManagementClient.NewListOperationsPager +// method. type ManagementClientListOperationsOptions struct { // placeholder for future optional parameters } -// ManagementClientListOrderAtResourceGroupLevelOptions contains the optional parameters for the ManagementClient.ListOrderAtResourceGroupLevel +// ManagementClientListOrderAtResourceGroupLevelOptions contains the optional parameters for the ManagementClient.NewListOrderAtResourceGroupLevelPager // method. type ManagementClientListOrderAtResourceGroupLevelOptions struct { // $skipToken is supported on Get list of order, which provides the next page in the list of order. SkipToken *string } -// ManagementClientListOrderAtSubscriptionLevelOptions contains the optional parameters for the ManagementClient.ListOrderAtSubscriptionLevel +// ManagementClientListOrderAtSubscriptionLevelOptions contains the optional parameters for the ManagementClient.NewListOrderAtSubscriptionLevelPager // method. type ManagementClientListOrderAtSubscriptionLevelOptions struct { // $skipToken is supported on Get list of order, which provides the next page in the list of order. SkipToken *string } -// ManagementClientListOrderItemsAtResourceGroupLevelOptions contains the optional parameters for the ManagementClient.ListOrderItemsAtResourceGroupLevel +// ManagementClientListOrderItemsAtResourceGroupLevelOptions contains the optional parameters for the ManagementClient.NewListOrderItemsAtResourceGroupLevelPager // method. type ManagementClientListOrderItemsAtResourceGroupLevelOptions struct { // $expand is supported on device details, forward shipping details and reverse shipping details parameters. Each of these @@ -574,7 +576,7 @@ type ManagementClientListOrderItemsAtResourceGroupLevelOptions struct { SkipToken *string } -// ManagementClientListOrderItemsAtSubscriptionLevelOptions contains the optional parameters for the ManagementClient.ListOrderItemsAtSubscriptionLevel +// ManagementClientListOrderItemsAtSubscriptionLevelOptions contains the optional parameters for the ManagementClient.NewListOrderItemsAtSubscriptionLevelPager // method. type ManagementClientListOrderItemsAtSubscriptionLevelOptions struct { // $expand is supported on device details, forward shipping details and reverse shipping details parameters. Each of these @@ -588,7 +590,7 @@ type ManagementClientListOrderItemsAtSubscriptionLevelOptions struct { SkipToken *string } -// ManagementClientListProductFamiliesMetadataOptions contains the optional parameters for the ManagementClient.ListProductFamiliesMetadata +// ManagementClientListProductFamiliesMetadataOptions contains the optional parameters for the ManagementClient.NewListProductFamiliesMetadataPager // method. type ManagementClientListProductFamiliesMetadataOptions struct { // $skipToken is supported on list of product families metadata, which provides the next page in the list of product families @@ -596,7 +598,7 @@ type ManagementClientListProductFamiliesMetadataOptions struct { SkipToken *string } -// ManagementClientListProductFamiliesOptions contains the optional parameters for the ManagementClient.ListProductFamilies +// ManagementClientListProductFamiliesOptions contains the optional parameters for the ManagementClient.NewListProductFamiliesPager // method. type ManagementClientListProductFamiliesOptions struct { // $expand is supported on configurations parameter for product, which provides details on the configurations for the product. diff --git a/sdk/resourcemanager/edgeorder/armedgeorder/models_serde.go b/sdk/resourcemanager/edgeorder/armedgeorder/models_serde.go new file mode 100644 index 000000000000..65f13f9adbd1 --- /dev/null +++ b/sdk/resourcemanager/edgeorder/armedgeorder/models_serde.go @@ -0,0 +1,2858 @@ +//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 armedgeorder + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AddressDetails. +func (a AddressDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "forwardAddress", a.ForwardAddress) + populate(objectMap, "returnAddress", a.ReturnAddress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AddressDetails. +func (a *AddressDetails) UnmarshalJSON(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 "forwardAddress": + err = unpopulate(val, "ForwardAddress", &a.ForwardAddress) + delete(rawMsg, key) + case "returnAddress": + err = unpopulate(val, "ReturnAddress", &a.ReturnAddress) + 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 AddressProperties. +func (a AddressProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addressValidationStatus", a.AddressValidationStatus) + populate(objectMap, "contactDetails", a.ContactDetails) + populate(objectMap, "shippingAddress", a.ShippingAddress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AddressProperties. +func (a *AddressProperties) UnmarshalJSON(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 "addressValidationStatus": + err = unpopulate(val, "AddressValidationStatus", &a.AddressValidationStatus) + delete(rawMsg, key) + case "contactDetails": + err = unpopulate(val, "ContactDetails", &a.ContactDetails) + delete(rawMsg, key) + case "shippingAddress": + err = unpopulate(val, "ShippingAddress", &a.ShippingAddress) + 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 AddressResource. +func (a AddressResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AddressResource. +func (a *AddressResource) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + 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 AddressResourceList. +func (a AddressResourceList) 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 AddressResourceList. +func (a *AddressResourceList) UnmarshalJSON(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 AddressUpdateParameter. +func (a AddressUpdateParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AddressUpdateParameter. +func (a *AddressUpdateParameter) UnmarshalJSON(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) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + 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 AddressUpdateProperties. +func (a AddressUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contactDetails", a.ContactDetails) + populate(objectMap, "shippingAddress", a.ShippingAddress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AddressUpdateProperties. +func (a *AddressUpdateProperties) UnmarshalJSON(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 "contactDetails": + err = unpopulate(val, "ContactDetails", &a.ContactDetails) + delete(rawMsg, key) + case "shippingAddress": + err = unpopulate(val, "ShippingAddress", &a.ShippingAddress) + 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 AvailabilityInformation. +func (a AvailabilityInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "availabilityStage", a.AvailabilityStage) + populate(objectMap, "disabledReason", a.DisabledReason) + populate(objectMap, "disabledReasonMessage", a.DisabledReasonMessage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailabilityInformation. +func (a *AvailabilityInformation) UnmarshalJSON(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 "availabilityStage": + err = unpopulate(val, "AvailabilityStage", &a.AvailabilityStage) + delete(rawMsg, key) + case "disabledReason": + err = unpopulate(val, "DisabledReason", &a.DisabledReason) + delete(rawMsg, key) + case "disabledReasonMessage": + err = unpopulate(val, "DisabledReasonMessage", &a.DisabledReasonMessage) + 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 BasicInformation. +func (b BasicInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "availabilityInformation", b.AvailabilityInformation) + populate(objectMap, "costInformation", b.CostInformation) + populate(objectMap, "description", b.Description) + populate(objectMap, "displayName", b.DisplayName) + populate(objectMap, "hierarchyInformation", b.HierarchyInformation) + populate(objectMap, "imageInformation", b.ImageInformation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BasicInformation. +func (b *BasicInformation) UnmarshalJSON(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 "availabilityInformation": + err = unpopulate(val, "AvailabilityInformation", &b.AvailabilityInformation) + delete(rawMsg, key) + case "costInformation": + err = unpopulate(val, "CostInformation", &b.CostInformation) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &b.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &b.DisplayName) + delete(rawMsg, key) + case "hierarchyInformation": + err = unpopulate(val, "HierarchyInformation", &b.HierarchyInformation) + delete(rawMsg, key) + case "imageInformation": + err = unpopulate(val, "ImageInformation", &b.ImageInformation) + 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 BillingMeterDetails. +func (b BillingMeterDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "frequency", b.Frequency) + populate(objectMap, "meterDetails", b.MeterDetails) + populate(objectMap, "meteringType", b.MeteringType) + populate(objectMap, "name", b.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BillingMeterDetails. +func (b *BillingMeterDetails) UnmarshalJSON(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 "frequency": + err = unpopulate(val, "Frequency", &b.Frequency) + delete(rawMsg, key) + case "meterDetails": + b.MeterDetails, err = unmarshalMeterDetailsClassification(val) + delete(rawMsg, key) + case "meteringType": + err = unpopulate(val, "MeteringType", &b.MeteringType) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &b.Name) + 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 CancellationReason. +func (c CancellationReason) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CancellationReason. +func (c *CancellationReason) UnmarshalJSON(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 "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 CommonProperties. +func (c CommonProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "availabilityInformation", c.AvailabilityInformation) + populate(objectMap, "costInformation", c.CostInformation) + populate(objectMap, "description", c.Description) + populate(objectMap, "displayName", c.DisplayName) + populate(objectMap, "filterableProperties", c.FilterableProperties) + populate(objectMap, "hierarchyInformation", c.HierarchyInformation) + populate(objectMap, "imageInformation", c.ImageInformation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommonProperties. +func (c *CommonProperties) UnmarshalJSON(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 "availabilityInformation": + err = unpopulate(val, "AvailabilityInformation", &c.AvailabilityInformation) + delete(rawMsg, key) + case "costInformation": + err = unpopulate(val, "CostInformation", &c.CostInformation) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &c.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &c.DisplayName) + delete(rawMsg, key) + case "filterableProperties": + err = unpopulate(val, "FilterableProperties", &c.FilterableProperties) + delete(rawMsg, key) + case "hierarchyInformation": + err = unpopulate(val, "HierarchyInformation", &c.HierarchyInformation) + delete(rawMsg, key) + case "imageInformation": + err = unpopulate(val, "ImageInformation", &c.ImageInformation) + 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, "properties", c.Properties) + 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 "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 ConfigurationFilters. +func (c ConfigurationFilters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "filterableProperty", c.FilterableProperty) + populate(objectMap, "hierarchyInformation", c.HierarchyInformation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationFilters. +func (c *ConfigurationFilters) UnmarshalJSON(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 "filterableProperty": + err = unpopulate(val, "FilterableProperty", &c.FilterableProperty) + delete(rawMsg, key) + case "hierarchyInformation": + err = unpopulate(val, "HierarchyInformation", &c.HierarchyInformation) + 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, "availabilityInformation", c.AvailabilityInformation) + populate(objectMap, "costInformation", c.CostInformation) + populate(objectMap, "description", c.Description) + populate(objectMap, "dimensions", c.Dimensions) + populate(objectMap, "displayName", c.DisplayName) + populate(objectMap, "filterableProperties", c.FilterableProperties) + populate(objectMap, "hierarchyInformation", c.HierarchyInformation) + populate(objectMap, "imageInformation", c.ImageInformation) + populate(objectMap, "specifications", c.Specifications) + 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 "availabilityInformation": + err = unpopulate(val, "AvailabilityInformation", &c.AvailabilityInformation) + delete(rawMsg, key) + case "costInformation": + err = unpopulate(val, "CostInformation", &c.CostInformation) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &c.Description) + delete(rawMsg, key) + case "dimensions": + err = unpopulate(val, "Dimensions", &c.Dimensions) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &c.DisplayName) + delete(rawMsg, key) + case "filterableProperties": + err = unpopulate(val, "FilterableProperties", &c.FilterableProperties) + delete(rawMsg, key) + case "hierarchyInformation": + err = unpopulate(val, "HierarchyInformation", &c.HierarchyInformation) + delete(rawMsg, key) + case "imageInformation": + err = unpopulate(val, "ImageInformation", &c.ImageInformation) + delete(rawMsg, key) + case "specifications": + err = unpopulate(val, "Specifications", &c.Specifications) + 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 Configurations. +func (c Configurations) 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 Configurations. +func (c *Configurations) UnmarshalJSON(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 ConfigurationsRequest. +func (c ConfigurationsRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "configurationFilters", c.ConfigurationFilters) + populate(objectMap, "customerSubscriptionDetails", c.CustomerSubscriptionDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationsRequest. +func (c *ConfigurationsRequest) UnmarshalJSON(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 "configurationFilters": + err = unpopulate(val, "ConfigurationFilters", &c.ConfigurationFilters) + delete(rawMsg, key) + case "customerSubscriptionDetails": + err = unpopulate(val, "CustomerSubscriptionDetails", &c.CustomerSubscriptionDetails) + 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 ContactDetails. +func (c ContactDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contactName", c.ContactName) + populate(objectMap, "emailList", c.EmailList) + populate(objectMap, "mobile", c.Mobile) + populate(objectMap, "phone", c.Phone) + populate(objectMap, "phoneExtension", c.PhoneExtension) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContactDetails. +func (c *ContactDetails) UnmarshalJSON(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 "contactName": + err = unpopulate(val, "ContactName", &c.ContactName) + delete(rawMsg, key) + case "emailList": + err = unpopulate(val, "EmailList", &c.EmailList) + delete(rawMsg, key) + case "mobile": + err = unpopulate(val, "Mobile", &c.Mobile) + delete(rawMsg, key) + case "phone": + err = unpopulate(val, "Phone", &c.Phone) + delete(rawMsg, key) + case "phoneExtension": + err = unpopulate(val, "PhoneExtension", &c.PhoneExtension) + 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 CostInformation. +func (c CostInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingInfoUrl", c.BillingInfoURL) + populate(objectMap, "billingMeterDetails", c.BillingMeterDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CostInformation. +func (c *CostInformation) UnmarshalJSON(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 "billingInfoUrl": + err = unpopulate(val, "BillingInfoURL", &c.BillingInfoURL) + delete(rawMsg, key) + case "billingMeterDetails": + err = unpopulate(val, "BillingMeterDetails", &c.BillingMeterDetails) + 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 CustomerSubscriptionDetails. +func (c CustomerSubscriptionDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "locationPlacementId", c.LocationPlacementID) + populate(objectMap, "quotaId", c.QuotaID) + populate(objectMap, "registeredFeatures", c.RegisteredFeatures) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomerSubscriptionDetails. +func (c *CustomerSubscriptionDetails) UnmarshalJSON(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 "locationPlacementId": + err = unpopulate(val, "LocationPlacementID", &c.LocationPlacementID) + delete(rawMsg, key) + case "quotaId": + err = unpopulate(val, "QuotaID", &c.QuotaID) + delete(rawMsg, key) + case "registeredFeatures": + err = unpopulate(val, "RegisteredFeatures", &c.RegisteredFeatures) + 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 CustomerSubscriptionRegisteredFeatures. +func (c CustomerSubscriptionRegisteredFeatures) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "state", c.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomerSubscriptionRegisteredFeatures. +func (c *CustomerSubscriptionRegisteredFeatures) UnmarshalJSON(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 "state": + err = unpopulate(val, "State", &c.State) + 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 Description. +func (d Description) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "attributes", d.Attributes) + populate(objectMap, "descriptionType", d.DescriptionType) + populate(objectMap, "keywords", d.Keywords) + populate(objectMap, "links", d.Links) + populate(objectMap, "longDescription", d.LongDescription) + populate(objectMap, "shortDescription", d.ShortDescription) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Description. +func (d *Description) UnmarshalJSON(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 "attributes": + err = unpopulate(val, "Attributes", &d.Attributes) + delete(rawMsg, key) + case "descriptionType": + err = unpopulate(val, "DescriptionType", &d.DescriptionType) + delete(rawMsg, key) + case "keywords": + err = unpopulate(val, "Keywords", &d.Keywords) + delete(rawMsg, key) + case "links": + err = unpopulate(val, "Links", &d.Links) + delete(rawMsg, key) + case "longDescription": + err = unpopulate(val, "LongDescription", &d.LongDescription) + delete(rawMsg, key) + case "shortDescription": + err = unpopulate(val, "ShortDescription", &d.ShortDescription) + 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 DeviceDetails. +func (d DeviceDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "managementResourceId", d.ManagementResourceID) + populate(objectMap, "managementResourceTenantId", d.ManagementResourceTenantID) + populate(objectMap, "serialNumber", d.SerialNumber) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceDetails. +func (d *DeviceDetails) UnmarshalJSON(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 "managementResourceId": + err = unpopulate(val, "ManagementResourceID", &d.ManagementResourceID) + delete(rawMsg, key) + case "managementResourceTenantId": + err = unpopulate(val, "ManagementResourceTenantID", &d.ManagementResourceTenantID) + delete(rawMsg, key) + case "serialNumber": + err = unpopulate(val, "SerialNumber", &d.SerialNumber) + 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 Dimensions. +func (d Dimensions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "depth", d.Depth) + populate(objectMap, "height", d.Height) + populate(objectMap, "length", d.Length) + populate(objectMap, "lengthHeightUnit", d.LengthHeightUnit) + populate(objectMap, "weight", d.Weight) + populate(objectMap, "weightUnit", d.WeightUnit) + populate(objectMap, "width", d.Width) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Dimensions. +func (d *Dimensions) UnmarshalJSON(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 "depth": + err = unpopulate(val, "Depth", &d.Depth) + delete(rawMsg, key) + case "height": + err = unpopulate(val, "Height", &d.Height) + delete(rawMsg, key) + case "length": + err = unpopulate(val, "Length", &d.Length) + delete(rawMsg, key) + case "lengthHeightUnit": + err = unpopulate(val, "LengthHeightUnit", &d.LengthHeightUnit) + delete(rawMsg, key) + case "weight": + err = unpopulate(val, "Weight", &d.Weight) + delete(rawMsg, key) + case "weightUnit": + err = unpopulate(val, "WeightUnit", &d.WeightUnit) + delete(rawMsg, key) + case "width": + err = unpopulate(val, "Width", &d.Width) + 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 DisplayInfo. +func (d DisplayInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "configurationDisplayName", d.ConfigurationDisplayName) + populate(objectMap, "productFamilyDisplayName", d.ProductFamilyDisplayName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DisplayInfo. +func (d *DisplayInfo) UnmarshalJSON(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 "configurationDisplayName": + err = unpopulate(val, "ConfigurationDisplayName", &d.ConfigurationDisplayName) + delete(rawMsg, key) + case "productFamilyDisplayName": + err = unpopulate(val, "ProductFamilyDisplayName", &d.ProductFamilyDisplayName) + 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 EncryptionPreferences. +func (e EncryptionPreferences) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "doubleEncryptionStatus", e.DoubleEncryptionStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EncryptionPreferences. +func (e *EncryptionPreferences) UnmarshalJSON(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 "doubleEncryptionStatus": + err = unpopulate(val, "DoubleEncryptionStatus", &e.DoubleEncryptionStatus) + 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 ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "info", &e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FilterableProperty. +func (f FilterableProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "supportedValues", f.SupportedValues) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FilterableProperty. +func (f *FilterableProperty) UnmarshalJSON(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 "supportedValues": + err = unpopulate(val, "SupportedValues", &f.SupportedValues) + 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 ForwardShippingDetails. +func (f ForwardShippingDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "carrierDisplayName", f.CarrierDisplayName) + populate(objectMap, "carrierName", f.CarrierName) + populate(objectMap, "trackingId", f.TrackingID) + populate(objectMap, "trackingUrl", f.TrackingURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ForwardShippingDetails. +func (f *ForwardShippingDetails) UnmarshalJSON(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 "carrierDisplayName": + err = unpopulate(val, "CarrierDisplayName", &f.CarrierDisplayName) + delete(rawMsg, key) + case "carrierName": + err = unpopulate(val, "CarrierName", &f.CarrierName) + delete(rawMsg, key) + case "trackingId": + err = unpopulate(val, "TrackingID", &f.TrackingID) + delete(rawMsg, key) + case "trackingUrl": + err = unpopulate(val, "TrackingURL", &f.TrackingURL) + 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 HierarchyInformation. +func (h HierarchyInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "configurationName", h.ConfigurationName) + populate(objectMap, "productFamilyName", h.ProductFamilyName) + populate(objectMap, "productLineName", h.ProductLineName) + populate(objectMap, "productName", h.ProductName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HierarchyInformation. +func (h *HierarchyInformation) UnmarshalJSON(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 "configurationName": + err = unpopulate(val, "ConfigurationName", &h.ConfigurationName) + delete(rawMsg, key) + case "productFamilyName": + err = unpopulate(val, "ProductFamilyName", &h.ProductFamilyName) + delete(rawMsg, key) + case "productLineName": + err = unpopulate(val, "ProductLineName", &h.ProductLineName) + delete(rawMsg, key) + case "productName": + err = unpopulate(val, "ProductName", &h.ProductName) + 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 ImageInformation. +func (i ImageInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "imageType", i.ImageType) + populate(objectMap, "imageUrl", i.ImageURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageInformation. +func (i *ImageInformation) UnmarshalJSON(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 "imageType": + err = unpopulate(val, "ImageType", &i.ImageType) + delete(rawMsg, key) + case "imageUrl": + err = unpopulate(val, "ImageURL", &i.ImageURL) + 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 Link. +func (l Link) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "linkType", l.LinkType) + populate(objectMap, "linkUrl", l.LinkURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Link. +func (l *Link) UnmarshalJSON(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 "linkType": + err = unpopulate(val, "LinkType", &l.LinkType) + delete(rawMsg, key) + case "linkUrl": + err = unpopulate(val, "LinkURL", &l.LinkURL) + 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 ManagementResourcePreferences. +func (m ManagementResourcePreferences) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "preferredManagementResourceId", m.PreferredManagementResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagementResourcePreferences. +func (m *ManagementResourcePreferences) UnmarshalJSON(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 "preferredManagementResourceId": + err = unpopulate(val, "PreferredManagementResourceID", &m.PreferredManagementResourceID) + 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 MeterDetails. +func (m MeterDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["billingType"] = m.BillingType + populate(objectMap, "chargingType", m.ChargingType) + populate(objectMap, "multiplier", m.Multiplier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MeterDetails. +func (m *MeterDetails) UnmarshalJSON(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 "billingType": + err = unpopulate(val, "BillingType", &m.BillingType) + delete(rawMsg, key) + case "chargingType": + err = unpopulate(val, "ChargingType", &m.ChargingType) + delete(rawMsg, key) + case "multiplier": + err = unpopulate(val, "Multiplier", &m.Multiplier) + 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 NotificationPreference. +func (n NotificationPreference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sendNotification", n.SendNotification) + populate(objectMap, "stageName", n.StageName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NotificationPreference. +func (n *NotificationPreference) UnmarshalJSON(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 "sendNotification": + err = unpopulate(val, "SendNotification", &n.SendNotification) + delete(rawMsg, key) + case "stageName": + err = unpopulate(val, "StageName", &n.StageName) + 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, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]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 OrderItemDetails. +func (o OrderItemDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cancellationReason", o.CancellationReason) + populate(objectMap, "cancellationStatus", o.CancellationStatus) + populate(objectMap, "currentStage", o.CurrentStage) + populate(objectMap, "deletionStatus", o.DeletionStatus) + populate(objectMap, "error", o.Error) + populate(objectMap, "forwardShippingDetails", o.ForwardShippingDetails) + populate(objectMap, "managementRpDetails", o.ManagementRpDetails) + populate(objectMap, "managementRpDetailsList", o.ManagementRpDetailsList) + populate(objectMap, "notificationEmailList", o.NotificationEmailList) + populate(objectMap, "orderItemStageHistory", o.OrderItemStageHistory) + populate(objectMap, "orderItemType", o.OrderItemType) + populate(objectMap, "preferences", o.Preferences) + populate(objectMap, "productDetails", o.ProductDetails) + populate(objectMap, "returnReason", o.ReturnReason) + populate(objectMap, "returnStatus", o.ReturnStatus) + populate(objectMap, "reverseShippingDetails", o.ReverseShippingDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrderItemDetails. +func (o *OrderItemDetails) UnmarshalJSON(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 "cancellationReason": + err = unpopulate(val, "CancellationReason", &o.CancellationReason) + delete(rawMsg, key) + case "cancellationStatus": + err = unpopulate(val, "CancellationStatus", &o.CancellationStatus) + delete(rawMsg, key) + case "currentStage": + err = unpopulate(val, "CurrentStage", &o.CurrentStage) + delete(rawMsg, key) + case "deletionStatus": + err = unpopulate(val, "DeletionStatus", &o.DeletionStatus) + delete(rawMsg, key) + case "error": + err = unpopulate(val, "Error", &o.Error) + delete(rawMsg, key) + case "forwardShippingDetails": + err = unpopulate(val, "ForwardShippingDetails", &o.ForwardShippingDetails) + delete(rawMsg, key) + case "managementRpDetails": + err = unpopulate(val, "ManagementRpDetails", &o.ManagementRpDetails) + delete(rawMsg, key) + case "managementRpDetailsList": + err = unpopulate(val, "ManagementRpDetailsList", &o.ManagementRpDetailsList) + delete(rawMsg, key) + case "notificationEmailList": + err = unpopulate(val, "NotificationEmailList", &o.NotificationEmailList) + delete(rawMsg, key) + case "orderItemStageHistory": + err = unpopulate(val, "OrderItemStageHistory", &o.OrderItemStageHistory) + delete(rawMsg, key) + case "orderItemType": + err = unpopulate(val, "OrderItemType", &o.OrderItemType) + delete(rawMsg, key) + case "preferences": + err = unpopulate(val, "Preferences", &o.Preferences) + delete(rawMsg, key) + case "productDetails": + err = unpopulate(val, "ProductDetails", &o.ProductDetails) + delete(rawMsg, key) + case "returnReason": + err = unpopulate(val, "ReturnReason", &o.ReturnReason) + delete(rawMsg, key) + case "returnStatus": + err = unpopulate(val, "ReturnStatus", &o.ReturnStatus) + delete(rawMsg, key) + case "reverseShippingDetails": + err = unpopulate(val, "ReverseShippingDetails", &o.ReverseShippingDetails) + 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 OrderItemProperties. +func (o OrderItemProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addressDetails", o.AddressDetails) + populate(objectMap, "orderId", o.OrderID) + populate(objectMap, "orderItemDetails", o.OrderItemDetails) + populateTimeRFC3339(objectMap, "startTime", o.StartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrderItemProperties. +func (o *OrderItemProperties) UnmarshalJSON(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 "addressDetails": + err = unpopulate(val, "AddressDetails", &o.AddressDetails) + delete(rawMsg, key) + case "orderId": + err = unpopulate(val, "OrderID", &o.OrderID) + delete(rawMsg, key) + case "orderItemDetails": + err = unpopulate(val, "OrderItemDetails", &o.OrderItemDetails) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &o.StartTime) + 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 OrderItemResource. +func (o OrderItemResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", o.ID) + populate(objectMap, "location", o.Location) + populate(objectMap, "name", o.Name) + populate(objectMap, "properties", o.Properties) + 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 OrderItemResource. +func (o *OrderItemResource) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &o.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + 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 OrderItemResourceList. +func (o OrderItemResourceList) 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 OrderItemResourceList. +func (o *OrderItemResourceList) UnmarshalJSON(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 OrderItemUpdateParameter. +func (o OrderItemUpdateParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", o.Properties) + populate(objectMap, "tags", o.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrderItemUpdateParameter. +func (o *OrderItemUpdateParameter) UnmarshalJSON(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 "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &o.Tags) + 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 OrderItemUpdateProperties. +func (o OrderItemUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "forwardAddress", o.ForwardAddress) + populate(objectMap, "notificationEmailList", o.NotificationEmailList) + populate(objectMap, "preferences", o.Preferences) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrderItemUpdateProperties. +func (o *OrderItemUpdateProperties) UnmarshalJSON(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 "forwardAddress": + err = unpopulate(val, "ForwardAddress", &o.ForwardAddress) + delete(rawMsg, key) + case "notificationEmailList": + err = unpopulate(val, "NotificationEmailList", &o.NotificationEmailList) + delete(rawMsg, key) + case "preferences": + err = unpopulate(val, "Preferences", &o.Preferences) + 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 OrderProperties. +func (o OrderProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currentStage", o.CurrentStage) + populate(objectMap, "orderItemIds", o.OrderItemIDs) + populate(objectMap, "orderStageHistory", o.OrderStageHistory) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrderProperties. +func (o *OrderProperties) UnmarshalJSON(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 "currentStage": + err = unpopulate(val, "CurrentStage", &o.CurrentStage) + delete(rawMsg, key) + case "orderItemIds": + err = unpopulate(val, "OrderItemIDs", &o.OrderItemIDs) + delete(rawMsg, key) + case "orderStageHistory": + err = unpopulate(val, "OrderStageHistory", &o.OrderStageHistory) + 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 OrderResource. +func (o OrderResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + populate(objectMap, "properties", o.Properties) + populate(objectMap, "systemData", o.SystemData) + populate(objectMap, "type", o.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrderResource. +func (o *OrderResource) UnmarshalJSON(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 "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &o.SystemData) + 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 OrderResourceList. +func (o OrderResourceList) 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 OrderResourceList. +func (o *OrderResourceList) UnmarshalJSON(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 Pav2MeterDetails. +func (p Pav2MeterDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["billingType"] = BillingTypePav2 + populate(objectMap, "chargingType", p.ChargingType) + populate(objectMap, "meterGuid", p.MeterGUID) + populate(objectMap, "multiplier", p.Multiplier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Pav2MeterDetails. +func (p *Pav2MeterDetails) UnmarshalJSON(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 "billingType": + err = unpopulate(val, "BillingType", &p.BillingType) + delete(rawMsg, key) + case "chargingType": + err = unpopulate(val, "ChargingType", &p.ChargingType) + delete(rawMsg, key) + case "meterGuid": + err = unpopulate(val, "MeterGUID", &p.MeterGUID) + delete(rawMsg, key) + case "multiplier": + err = unpopulate(val, "Multiplier", &p.Multiplier) + 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 Preferences. +func (p Preferences) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "encryptionPreferences", p.EncryptionPreferences) + populate(objectMap, "managementResourcePreferences", p.ManagementResourcePreferences) + populate(objectMap, "notificationPreferences", p.NotificationPreferences) + populate(objectMap, "transportPreferences", p.TransportPreferences) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Preferences. +func (p *Preferences) UnmarshalJSON(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 "encryptionPreferences": + err = unpopulate(val, "EncryptionPreferences", &p.EncryptionPreferences) + delete(rawMsg, key) + case "managementResourcePreferences": + err = unpopulate(val, "ManagementResourcePreferences", &p.ManagementResourcePreferences) + delete(rawMsg, key) + case "notificationPreferences": + err = unpopulate(val, "NotificationPreferences", &p.NotificationPreferences) + delete(rawMsg, key) + case "transportPreferences": + err = unpopulate(val, "TransportPreferences", &p.TransportPreferences) + 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 Product. +func (p Product) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Product. +func (p *Product) UnmarshalJSON(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 "properties": + err = unpopulate(val, "Properties", &p.Properties) + 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 ProductDetails. +func (p ProductDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", p.Count) + populate(objectMap, "deviceDetails", p.DeviceDetails) + populate(objectMap, "displayInfo", p.DisplayInfo) + populate(objectMap, "hierarchyInformation", p.HierarchyInformation) + populate(objectMap, "productDoubleEncryptionStatus", p.ProductDoubleEncryptionStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductDetails. +func (p *ProductDetails) UnmarshalJSON(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 "count": + err = unpopulate(val, "Count", &p.Count) + delete(rawMsg, key) + case "deviceDetails": + err = unpopulate(val, "DeviceDetails", &p.DeviceDetails) + delete(rawMsg, key) + case "displayInfo": + err = unpopulate(val, "DisplayInfo", &p.DisplayInfo) + delete(rawMsg, key) + case "hierarchyInformation": + err = unpopulate(val, "HierarchyInformation", &p.HierarchyInformation) + delete(rawMsg, key) + case "productDoubleEncryptionStatus": + err = unpopulate(val, "ProductDoubleEncryptionStatus", &p.ProductDoubleEncryptionStatus) + 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 ProductFamilies. +func (p ProductFamilies) 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 ProductFamilies. +func (p *ProductFamilies) UnmarshalJSON(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 ProductFamiliesMetadata. +func (p ProductFamiliesMetadata) 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 ProductFamiliesMetadata. +func (p *ProductFamiliesMetadata) UnmarshalJSON(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 ProductFamiliesMetadataDetails. +func (p ProductFamiliesMetadataDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductFamiliesMetadataDetails. +func (p *ProductFamiliesMetadataDetails) UnmarshalJSON(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 "properties": + err = unpopulate(val, "Properties", &p.Properties) + 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 ProductFamiliesRequest. +func (p ProductFamiliesRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customerSubscriptionDetails", p.CustomerSubscriptionDetails) + populate(objectMap, "filterableProperties", p.FilterableProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductFamiliesRequest. +func (p *ProductFamiliesRequest) UnmarshalJSON(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 "customerSubscriptionDetails": + err = unpopulate(val, "CustomerSubscriptionDetails", &p.CustomerSubscriptionDetails) + delete(rawMsg, key) + case "filterableProperties": + err = unpopulate(val, "FilterableProperties", &p.FilterableProperties) + 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 ProductFamily. +func (p ProductFamily) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductFamily. +func (p *ProductFamily) UnmarshalJSON(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 "properties": + err = unpopulate(val, "Properties", &p.Properties) + 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 ProductFamilyProperties. +func (p ProductFamilyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "availabilityInformation", p.AvailabilityInformation) + populate(objectMap, "costInformation", p.CostInformation) + populate(objectMap, "description", p.Description) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "filterableProperties", p.FilterableProperties) + populate(objectMap, "hierarchyInformation", p.HierarchyInformation) + populate(objectMap, "imageInformation", p.ImageInformation) + populate(objectMap, "productLines", p.ProductLines) + populate(objectMap, "resourceProviderDetails", p.ResourceProviderDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductFamilyProperties. +func (p *ProductFamilyProperties) UnmarshalJSON(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 "availabilityInformation": + err = unpopulate(val, "AvailabilityInformation", &p.AvailabilityInformation) + delete(rawMsg, key) + case "costInformation": + err = unpopulate(val, "CostInformation", &p.CostInformation) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "filterableProperties": + err = unpopulate(val, "FilterableProperties", &p.FilterableProperties) + delete(rawMsg, key) + case "hierarchyInformation": + err = unpopulate(val, "HierarchyInformation", &p.HierarchyInformation) + delete(rawMsg, key) + case "imageInformation": + err = unpopulate(val, "ImageInformation", &p.ImageInformation) + delete(rawMsg, key) + case "productLines": + err = unpopulate(val, "ProductLines", &p.ProductLines) + delete(rawMsg, key) + case "resourceProviderDetails": + err = unpopulate(val, "ResourceProviderDetails", &p.ResourceProviderDetails) + 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 ProductLine. +func (p ProductLine) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductLine. +func (p *ProductLine) UnmarshalJSON(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 "properties": + err = unpopulate(val, "Properties", &p.Properties) + 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 ProductLineProperties. +func (p ProductLineProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "availabilityInformation", p.AvailabilityInformation) + populate(objectMap, "costInformation", p.CostInformation) + populate(objectMap, "description", p.Description) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "filterableProperties", p.FilterableProperties) + populate(objectMap, "hierarchyInformation", p.HierarchyInformation) + populate(objectMap, "imageInformation", p.ImageInformation) + populate(objectMap, "products", p.Products) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductLineProperties. +func (p *ProductLineProperties) UnmarshalJSON(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 "availabilityInformation": + err = unpopulate(val, "AvailabilityInformation", &p.AvailabilityInformation) + delete(rawMsg, key) + case "costInformation": + err = unpopulate(val, "CostInformation", &p.CostInformation) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "filterableProperties": + err = unpopulate(val, "FilterableProperties", &p.FilterableProperties) + delete(rawMsg, key) + case "hierarchyInformation": + err = unpopulate(val, "HierarchyInformation", &p.HierarchyInformation) + delete(rawMsg, key) + case "imageInformation": + err = unpopulate(val, "ImageInformation", &p.ImageInformation) + delete(rawMsg, key) + case "products": + err = unpopulate(val, "Products", &p.Products) + 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 ProductProperties. +func (p ProductProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "availabilityInformation", p.AvailabilityInformation) + populate(objectMap, "configurations", p.Configurations) + populate(objectMap, "costInformation", p.CostInformation) + populate(objectMap, "description", p.Description) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "filterableProperties", p.FilterableProperties) + populate(objectMap, "hierarchyInformation", p.HierarchyInformation) + populate(objectMap, "imageInformation", p.ImageInformation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductProperties. +func (p *ProductProperties) UnmarshalJSON(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 "availabilityInformation": + err = unpopulate(val, "AvailabilityInformation", &p.AvailabilityInformation) + delete(rawMsg, key) + case "configurations": + err = unpopulate(val, "Configurations", &p.Configurations) + delete(rawMsg, key) + case "costInformation": + err = unpopulate(val, "CostInformation", &p.CostInformation) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "filterableProperties": + err = unpopulate(val, "FilterableProperties", &p.FilterableProperties) + delete(rawMsg, key) + case "hierarchyInformation": + err = unpopulate(val, "HierarchyInformation", &p.HierarchyInformation) + delete(rawMsg, key) + case "imageInformation": + err = unpopulate(val, "ImageInformation", &p.ImageInformation) + 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 PurchaseMeterDetails. +func (p PurchaseMeterDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["billingType"] = BillingTypePurchase + populate(objectMap, "chargingType", p.ChargingType) + populate(objectMap, "multiplier", p.Multiplier) + populate(objectMap, "productId", p.ProductID) + populate(objectMap, "skuId", p.SKUID) + populate(objectMap, "termId", p.TermID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PurchaseMeterDetails. +func (p *PurchaseMeterDetails) UnmarshalJSON(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 "billingType": + err = unpopulate(val, "BillingType", &p.BillingType) + delete(rawMsg, key) + case "chargingType": + err = unpopulate(val, "ChargingType", &p.ChargingType) + delete(rawMsg, key) + case "multiplier": + err = unpopulate(val, "Multiplier", &p.Multiplier) + delete(rawMsg, key) + case "productId": + err = unpopulate(val, "ProductID", &p.ProductID) + delete(rawMsg, key) + case "skuId": + err = unpopulate(val, "SKUID", &p.SKUID) + delete(rawMsg, key) + case "termId": + err = unpopulate(val, "TermID", &p.TermID) + 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 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 ResourceProviderDetails. +func (r ResourceProviderDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceProviderNamespace", r.ResourceProviderNamespace) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderDetails. +func (r *ResourceProviderDetails) UnmarshalJSON(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 "resourceProviderNamespace": + err = unpopulate(val, "ResourceProviderNamespace", &r.ResourceProviderNamespace) + 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 ReturnOrderItemDetails. +func (r ReturnOrderItemDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "returnAddress", r.ReturnAddress) + populate(objectMap, "returnReason", r.ReturnReason) + populate(objectMap, "serviceTag", r.ServiceTag) + populate(objectMap, "shippingBoxRequired", r.ShippingBoxRequired) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReturnOrderItemDetails. +func (r *ReturnOrderItemDetails) UnmarshalJSON(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 "returnAddress": + err = unpopulate(val, "ReturnAddress", &r.ReturnAddress) + delete(rawMsg, key) + case "returnReason": + err = unpopulate(val, "ReturnReason", &r.ReturnReason) + delete(rawMsg, key) + case "serviceTag": + err = unpopulate(val, "ServiceTag", &r.ServiceTag) + delete(rawMsg, key) + case "shippingBoxRequired": + err = unpopulate(val, "ShippingBoxRequired", &r.ShippingBoxRequired) + 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 ReverseShippingDetails. +func (r ReverseShippingDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "carrierDisplayName", r.CarrierDisplayName) + populate(objectMap, "carrierName", r.CarrierName) + populate(objectMap, "sasKeyForLabel", r.SasKeyForLabel) + populate(objectMap, "trackingId", r.TrackingID) + populate(objectMap, "trackingUrl", r.TrackingURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReverseShippingDetails. +func (r *ReverseShippingDetails) UnmarshalJSON(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 "carrierDisplayName": + err = unpopulate(val, "CarrierDisplayName", &r.CarrierDisplayName) + delete(rawMsg, key) + case "carrierName": + err = unpopulate(val, "CarrierName", &r.CarrierName) + delete(rawMsg, key) + case "sasKeyForLabel": + err = unpopulate(val, "SasKeyForLabel", &r.SasKeyForLabel) + delete(rawMsg, key) + case "trackingId": + err = unpopulate(val, "TrackingID", &r.TrackingID) + delete(rawMsg, key) + case "trackingUrl": + err = unpopulate(val, "TrackingURL", &r.TrackingURL) + 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 ShippingAddress. +func (s ShippingAddress) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addressType", s.AddressType) + populate(objectMap, "city", s.City) + populate(objectMap, "companyName", s.CompanyName) + populate(objectMap, "country", s.Country) + populate(objectMap, "postalCode", s.PostalCode) + populate(objectMap, "stateOrProvince", s.StateOrProvince) + populate(objectMap, "streetAddress1", s.StreetAddress1) + populate(objectMap, "streetAddress2", s.StreetAddress2) + populate(objectMap, "streetAddress3", s.StreetAddress3) + populate(objectMap, "zipExtendedCode", s.ZipExtendedCode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ShippingAddress. +func (s *ShippingAddress) UnmarshalJSON(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 "addressType": + err = unpopulate(val, "AddressType", &s.AddressType) + delete(rawMsg, key) + case "city": + err = unpopulate(val, "City", &s.City) + delete(rawMsg, key) + case "companyName": + err = unpopulate(val, "CompanyName", &s.CompanyName) + delete(rawMsg, key) + case "country": + err = unpopulate(val, "Country", &s.Country) + delete(rawMsg, key) + case "postalCode": + err = unpopulate(val, "PostalCode", &s.PostalCode) + delete(rawMsg, key) + case "stateOrProvince": + err = unpopulate(val, "StateOrProvince", &s.StateOrProvince) + delete(rawMsg, key) + case "streetAddress1": + err = unpopulate(val, "StreetAddress1", &s.StreetAddress1) + delete(rawMsg, key) + case "streetAddress2": + err = unpopulate(val, "StreetAddress2", &s.StreetAddress2) + delete(rawMsg, key) + case "streetAddress3": + err = unpopulate(val, "StreetAddress3", &s.StreetAddress3) + delete(rawMsg, key) + case "zipExtendedCode": + err = unpopulate(val, "ZipExtendedCode", &s.ZipExtendedCode) + 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 ShippingDetails. +func (s ShippingDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "carrierDisplayName", s.CarrierDisplayName) + populate(objectMap, "carrierName", s.CarrierName) + populate(objectMap, "trackingId", s.TrackingID) + populate(objectMap, "trackingUrl", s.TrackingURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ShippingDetails. +func (s *ShippingDetails) UnmarshalJSON(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 "carrierDisplayName": + err = unpopulate(val, "CarrierDisplayName", &s.CarrierDisplayName) + delete(rawMsg, key) + case "carrierName": + err = unpopulate(val, "CarrierName", &s.CarrierName) + delete(rawMsg, key) + case "trackingId": + err = unpopulate(val, "TrackingID", &s.TrackingID) + delete(rawMsg, key) + case "trackingUrl": + err = unpopulate(val, "TrackingURL", &s.TrackingURL) + 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 Specification. +func (s Specification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Specification. +func (s *Specification) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StageDetails. +func (s StageDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "stageName", s.StageName) + populate(objectMap, "stageStatus", s.StageStatus) + populateTimeRFC3339(objectMap, "startTime", s.StartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StageDetails. +func (s *StageDetails) UnmarshalJSON(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 "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "stageName": + err = unpopulate(val, "StageName", &s.StageName) + delete(rawMsg, key) + case "stageStatus": + err = unpopulate(val, "StageStatus", &s.StageStatus) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &s.StartTime) + 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 TransportPreferences. +func (t TransportPreferences) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "preferredShipmentType", t.PreferredShipmentType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransportPreferences. +func (t *TransportPreferences) UnmarshalJSON(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 "preferredShipmentType": + err = unpopulate(val, "PreferredShipmentType", &t.PreferredShipmentType) + 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/edgeorder/armedgeorder/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/edgeorder/armedgeorder/polymorphic_helpers.go similarity index 95% rename from sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_polymorphic_helpers.go rename to sdk/resourcemanager/edgeorder/armedgeorder/polymorphic_helpers.go index 6e3b4d42c7ef..d96ed7a1da06 100644 --- a/sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_polymorphic_helpers.go +++ b/sdk/resourcemanager/edgeorder/armedgeorder/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 armedgeorder @@ -14,7 +15,7 @@ func unmarshalMeterDetailsClassification(rawMsg json.RawMessage) (MeterDetailsCl 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/edgeorder/armedgeorder/zz_generated_response_types.go b/sdk/resourcemanager/edgeorder/armedgeorder/response_types.go similarity index 75% rename from sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_response_types.go rename to sdk/resourcemanager/edgeorder/armedgeorder/response_types.go index 7035d4820784..dc88e1117db6 100644 --- a/sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_response_types.go +++ b/sdk/resourcemanager/edgeorder/armedgeorder/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 armedgeorder @@ -13,22 +14,22 @@ type ManagementClientCancelOrderItemResponse struct { // placeholder for future response values } -// ManagementClientCreateAddressResponse contains the response from method ManagementClient.CreateAddress. +// ManagementClientCreateAddressResponse contains the response from method ManagementClient.BeginCreateAddress. type ManagementClientCreateAddressResponse struct { AddressResource } -// ManagementClientCreateOrderItemResponse contains the response from method ManagementClient.CreateOrderItem. +// ManagementClientCreateOrderItemResponse contains the response from method ManagementClient.BeginCreateOrderItem. type ManagementClientCreateOrderItemResponse struct { OrderItemResource } -// ManagementClientDeleteAddressByNameResponse contains the response from method ManagementClient.DeleteAddressByName. +// ManagementClientDeleteAddressByNameResponse contains the response from method ManagementClient.BeginDeleteAddressByName. type ManagementClientDeleteAddressByNameResponse struct { // placeholder for future response values } -// ManagementClientDeleteOrderItemByNameResponse contains the response from method ManagementClient.DeleteOrderItemByName. +// ManagementClientDeleteOrderItemByNameResponse contains the response from method ManagementClient.BeginDeleteOrderItemByName. type ManagementClientDeleteOrderItemByNameResponse struct { // placeholder for future response values } @@ -48,67 +49,67 @@ type ManagementClientGetOrderItemByNameResponse struct { OrderItemResource } -// ManagementClientListAddressesAtResourceGroupLevelResponse contains the response from method ManagementClient.ListAddressesAtResourceGroupLevel. +// ManagementClientListAddressesAtResourceGroupLevelResponse contains the response from method ManagementClient.NewListAddressesAtResourceGroupLevelPager. type ManagementClientListAddressesAtResourceGroupLevelResponse struct { AddressResourceList } -// ManagementClientListAddressesAtSubscriptionLevelResponse contains the response from method ManagementClient.ListAddressesAtSubscriptionLevel. +// ManagementClientListAddressesAtSubscriptionLevelResponse contains the response from method ManagementClient.NewListAddressesAtSubscriptionLevelPager. type ManagementClientListAddressesAtSubscriptionLevelResponse struct { AddressResourceList } -// ManagementClientListConfigurationsResponse contains the response from method ManagementClient.ListConfigurations. +// ManagementClientListConfigurationsResponse contains the response from method ManagementClient.NewListConfigurationsPager. type ManagementClientListConfigurationsResponse struct { Configurations } -// ManagementClientListOperationsResponse contains the response from method ManagementClient.ListOperations. +// ManagementClientListOperationsResponse contains the response from method ManagementClient.NewListOperationsPager. type ManagementClientListOperationsResponse struct { OperationListResult } -// ManagementClientListOrderAtResourceGroupLevelResponse contains the response from method ManagementClient.ListOrderAtResourceGroupLevel. +// ManagementClientListOrderAtResourceGroupLevelResponse contains the response from method ManagementClient.NewListOrderAtResourceGroupLevelPager. type ManagementClientListOrderAtResourceGroupLevelResponse struct { OrderResourceList } -// ManagementClientListOrderAtSubscriptionLevelResponse contains the response from method ManagementClient.ListOrderAtSubscriptionLevel. +// ManagementClientListOrderAtSubscriptionLevelResponse contains the response from method ManagementClient.NewListOrderAtSubscriptionLevelPager. type ManagementClientListOrderAtSubscriptionLevelResponse struct { OrderResourceList } -// ManagementClientListOrderItemsAtResourceGroupLevelResponse contains the response from method ManagementClient.ListOrderItemsAtResourceGroupLevel. +// ManagementClientListOrderItemsAtResourceGroupLevelResponse contains the response from method ManagementClient.NewListOrderItemsAtResourceGroupLevelPager. type ManagementClientListOrderItemsAtResourceGroupLevelResponse struct { OrderItemResourceList } -// ManagementClientListOrderItemsAtSubscriptionLevelResponse contains the response from method ManagementClient.ListOrderItemsAtSubscriptionLevel. +// ManagementClientListOrderItemsAtSubscriptionLevelResponse contains the response from method ManagementClient.NewListOrderItemsAtSubscriptionLevelPager. type ManagementClientListOrderItemsAtSubscriptionLevelResponse struct { OrderItemResourceList } -// ManagementClientListProductFamiliesMetadataResponse contains the response from method ManagementClient.ListProductFamiliesMetadata. +// ManagementClientListProductFamiliesMetadataResponse contains the response from method ManagementClient.NewListProductFamiliesMetadataPager. type ManagementClientListProductFamiliesMetadataResponse struct { ProductFamiliesMetadata } -// ManagementClientListProductFamiliesResponse contains the response from method ManagementClient.ListProductFamilies. +// ManagementClientListProductFamiliesResponse contains the response from method ManagementClient.NewListProductFamiliesPager. type ManagementClientListProductFamiliesResponse struct { ProductFamilies } -// ManagementClientReturnOrderItemResponse contains the response from method ManagementClient.ReturnOrderItem. +// ManagementClientReturnOrderItemResponse contains the response from method ManagementClient.BeginReturnOrderItem. type ManagementClientReturnOrderItemResponse struct { // placeholder for future response values } -// ManagementClientUpdateAddressResponse contains the response from method ManagementClient.UpdateAddress. +// ManagementClientUpdateAddressResponse contains the response from method ManagementClient.BeginUpdateAddress. type ManagementClientUpdateAddressResponse struct { AddressResource } -// ManagementClientUpdateOrderItemResponse contains the response from method ManagementClient.UpdateOrderItem. +// ManagementClientUpdateOrderItemResponse contains the response from method ManagementClient.BeginUpdateOrderItem. type ManagementClientUpdateOrderItemResponse struct { OrderItemResource } diff --git a/sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_time_rfc3339.go b/sdk/resourcemanager/edgeorder/armedgeorder/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/edgeorder/armedgeorder/time_rfc3339.go index 581885d97b0b..a75499478d05 100644 --- a/sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/edgeorder/armedgeorder/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 armedgeorder @@ -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/edgeorder/armedgeorder/ze_generated_example_edgeordermanagementclient_client_test.go b/sdk/resourcemanager/edgeorder/armedgeorder/ze_generated_example_edgeordermanagementclient_client_test.go deleted file mode 100644 index 46126594bf36..000000000000 --- a/sdk/resourcemanager/edgeorder/armedgeorder/ze_generated_example_edgeordermanagementclient_client_test.go +++ /dev/null @@ -1,667 +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 armedgeorder_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/edgeorder/armedgeorder" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListOperations.json -func ExampleManagementClient_NewListOperationsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListOperationsPager(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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListAddressesAtSubscriptionLevel.json -func ExampleManagementClient_NewListAddressesAtSubscriptionLevelPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListAddressesAtSubscriptionLevelPager(&armedgeorder.ManagementClientListAddressesAtSubscriptionLevelOptions{Filter: nil, - SkipToken: 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListProductFamilies.json -func ExampleManagementClient_NewListProductFamiliesPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListProductFamiliesPager(armedgeorder.ProductFamiliesRequest{ - FilterableProperties: map[string][]*armedgeorder.FilterableProperty{ - "azurestackedge": { - { - Type: to.Ptr(armedgeorder.SupportedFilterTypesShipToCountries), - SupportedValues: []*string{ - to.Ptr("US")}, - }}, - }, - }, - &armedgeorder.ManagementClientListProductFamiliesOptions{Expand: to.Ptr("configurations"), - SkipToken: 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListConfigurations.json -func ExampleManagementClient_NewListConfigurationsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListConfigurationsPager(armedgeorder.ConfigurationsRequest{ - ConfigurationFilters: []*armedgeorder.ConfigurationFilters{ - { - FilterableProperty: []*armedgeorder.FilterableProperty{ - { - Type: to.Ptr(armedgeorder.SupportedFilterTypesShipToCountries), - SupportedValues: []*string{ - to.Ptr("US")}, - }}, - HierarchyInformation: &armedgeorder.HierarchyInformation{ - ProductFamilyName: to.Ptr("azurestackedge"), - ProductLineName: to.Ptr("azurestackedge"), - ProductName: to.Ptr("azurestackedgegpu"), - }, - }}, - }, - &armedgeorder.ManagementClientListConfigurationsOptions{SkipToken: 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListProductFamiliesMetadata.json -func ExampleManagementClient_NewListProductFamiliesMetadataPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListProductFamiliesMetadataPager(&armedgeorder.ManagementClientListProductFamiliesMetadataOptions{SkipToken: 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListOrderAtSubscriptionLevel.json -func ExampleManagementClient_NewListOrderAtSubscriptionLevelPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListOrderAtSubscriptionLevelPager(&armedgeorder.ManagementClientListOrderAtSubscriptionLevelOptions{SkipToken: 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListOrderItemsAtSubscriptionLevel.json -func ExampleManagementClient_NewListOrderItemsAtSubscriptionLevelPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListOrderItemsAtSubscriptionLevelPager(&armedgeorder.ManagementClientListOrderItemsAtSubscriptionLevelOptions{Filter: nil, - Expand: nil, - SkipToken: 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListAddressesAtResourceGroupLevel.json -func ExampleManagementClient_NewListAddressesAtResourceGroupLevelPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListAddressesAtResourceGroupLevelPager("YourResourceGroupName", - &armedgeorder.ManagementClientListAddressesAtResourceGroupLevelOptions{Filter: nil, - SkipToken: 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/GetAddressByName.json -func ExampleManagementClient_GetAddressByName() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetAddressByName(ctx, - "TestAddressName1", - "YourResourceGroupName", - 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/CreateAddress.json -func ExampleManagementClient_BeginCreateAddress() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateAddress(ctx, - "TestAddressName2", - "YourResourceGroupName", - armedgeorder.AddressResource{ - Location: to.Ptr("eastus"), - Properties: &armedgeorder.AddressProperties{ - ContactDetails: &armedgeorder.ContactDetails{ - ContactName: to.Ptr("XXXX XXXX"), - EmailList: []*string{ - to.Ptr("xxxx@xxxx.xxx")}, - Phone: to.Ptr("0000000000"), - PhoneExtension: to.Ptr(""), - }, - ShippingAddress: &armedgeorder.ShippingAddress{ - AddressType: to.Ptr(armedgeorder.AddressTypeNone), - City: to.Ptr("San Francisco"), - CompanyName: to.Ptr("Microsoft"), - Country: to.Ptr("US"), - PostalCode: to.Ptr("94107"), - StateOrProvince: to.Ptr("CA"), - StreetAddress1: to.Ptr("16 TOWNSEND ST"), - StreetAddress2: to.Ptr("UNIT 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/DeleteAddressByName.json -func ExampleManagementClient_BeginDeleteAddressByName() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDeleteAddressByName(ctx, - "TestAddressName1", - "YourResourceGroupName", - 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/UpdateAddress.json -func ExampleManagementClient_BeginUpdateAddress() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdateAddress(ctx, - "TestAddressName2", - "YourResourceGroupName", - armedgeorder.AddressUpdateParameter{ - Properties: &armedgeorder.AddressUpdateProperties{ - ContactDetails: &armedgeorder.ContactDetails{ - ContactName: to.Ptr("YYYY YYYY"), - EmailList: []*string{ - to.Ptr("xxxx@xxxx.xxx")}, - Phone: to.Ptr("0000000000"), - PhoneExtension: to.Ptr(""), - }, - ShippingAddress: &armedgeorder.ShippingAddress{ - AddressType: to.Ptr(armedgeorder.AddressTypeNone), - City: to.Ptr("San Francisco"), - CompanyName: to.Ptr("Microsoft"), - Country: to.Ptr("US"), - PostalCode: to.Ptr("94107"), - StateOrProvince: to.Ptr("CA"), - StreetAddress1: to.Ptr("16 TOWNSEND ST"), - StreetAddress2: to.Ptr("UNIT 1"), - }, - }, - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - }, - }, - &armedgeorder.ManagementClientBeginUpdateAddressOptions{IfMatch: 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListOrderAtResourceGroupLevel.json -func ExampleManagementClient_NewListOrderAtResourceGroupLevelPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListOrderAtResourceGroupLevelPager("YourResourceGroupName", - &armedgeorder.ManagementClientListOrderAtResourceGroupLevelOptions{SkipToken: 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/GetOrderByName.json -func ExampleManagementClient_GetOrderByName() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetOrderByName(ctx, - "TestOrderName3", - "YourResourceGroupName", - "eastus", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListOrderItemsAtResourceGroupLevel.json -func ExampleManagementClient_NewListOrderItemsAtResourceGroupLevelPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListOrderItemsAtResourceGroupLevelPager("YourResourceGroupName", - &armedgeorder.ManagementClientListOrderItemsAtResourceGroupLevelOptions{Filter: nil, - Expand: nil, - SkipToken: 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/GetOrderItemByName.json -func ExampleManagementClient_GetOrderItemByName() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetOrderItemByName(ctx, - "TestOrderItemName1", - "YourResourceGroupName", - &armedgeorder.ManagementClientGetOrderItemByNameOptions{Expand: 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/CreateOrderItem.json -func ExampleManagementClient_BeginCreateOrderItem() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrderItem(ctx, - "TestOrderItemName2", - "YourResourceGroupName", - armedgeorder.OrderItemResource{ - Location: to.Ptr("eastus"), - Properties: &armedgeorder.OrderItemProperties{ - AddressDetails: &armedgeorder.AddressDetails{ - ForwardAddress: &armedgeorder.AddressProperties{ - ContactDetails: &armedgeorder.ContactDetails{ - ContactName: to.Ptr("XXXX XXXX"), - EmailList: []*string{ - to.Ptr("xxxx@xxxx.xxx")}, - Phone: to.Ptr("0000000000"), - PhoneExtension: to.Ptr(""), - }, - ShippingAddress: &armedgeorder.ShippingAddress{ - AddressType: to.Ptr(armedgeorder.AddressTypeNone), - City: to.Ptr("San Francisco"), - CompanyName: to.Ptr("Microsoft"), - Country: to.Ptr("US"), - PostalCode: to.Ptr("94107"), - StateOrProvince: to.Ptr("CA"), - StreetAddress1: to.Ptr("16 TOWNSEND ST"), - StreetAddress2: to.Ptr("UNIT 1"), - }, - }, - }, - OrderID: to.Ptr("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.EdgeOrder/locations/eastus/orders/TestOrderName2"), - OrderItemDetails: &armedgeorder.OrderItemDetails{ - OrderItemType: to.Ptr(armedgeorder.OrderItemTypePurchase), - Preferences: &armedgeorder.Preferences{ - TransportPreferences: &armedgeorder.TransportPreferences{ - PreferredShipmentType: to.Ptr(armedgeorder.TransportShipmentTypesMicrosoftManaged), - }, - }, - ProductDetails: &armedgeorder.ProductDetails{ - HierarchyInformation: &armedgeorder.HierarchyInformation{ - ConfigurationName: to.Ptr("edgep_base"), - ProductFamilyName: to.Ptr("azurestackedge"), - ProductLineName: to.Ptr("azurestackedge"), - ProductName: to.Ptr("azurestackedgegpu"), - }, - }, - }, - }, - }, - 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/DeleteOrderItemByName.json -func ExampleManagementClient_BeginDeleteOrderItemByName() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDeleteOrderItemByName(ctx, - "TestOrderItemName3", - "YourResourceGroupName", - 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/UpdateOrderItem.json -func ExampleManagementClient_BeginUpdateOrderItem() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdateOrderItem(ctx, - "TestOrderItemName3", - "YourResourceGroupName", - armedgeorder.OrderItemUpdateParameter{ - Properties: &armedgeorder.OrderItemUpdateProperties{ - Preferences: &armedgeorder.Preferences{ - TransportPreferences: &armedgeorder.TransportPreferences{ - PreferredShipmentType: to.Ptr(armedgeorder.TransportShipmentTypesCustomerManaged), - }, - }, - }, - }, - &armedgeorder.ManagementClientBeginUpdateOrderItemOptions{IfMatch: 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/CancelOrderItem.json -func ExampleManagementClient_CancelOrderItem() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.CancelOrderItem(ctx, - "TestOrderItemName3", - "YourResourceGroupName", - armedgeorder.CancellationReason{ - Reason: to.Ptr("Order cancelled"), - }, - 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/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ReturnOrderItem.json -func ExampleManagementClient_BeginReturnOrderItem() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorder.NewManagementClient("YourSubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginReturnOrderItem(ctx, - "TestOrderName4", - "YourResourceGroupName", - armedgeorder.ReturnOrderItemDetails{ - ReturnReason: to.Ptr("Order returned"), - }, - 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/edgeorder/armedgeorder/zz_generated_models_serde.go b/sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_models_serde.go deleted file mode 100644 index 7d60f83fb113..000000000000 --- a/sdk/resourcemanager/edgeorder/armedgeorder/zz_generated_models_serde.go +++ /dev/null @@ -1,431 +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 armedgeorder - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type AddressResource. -func (a AddressResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", a.ID) - populate(objectMap, "location", a.Location) - populate(objectMap, "name", a.Name) - populate(objectMap, "properties", a.Properties) - populate(objectMap, "systemData", a.SystemData) - populate(objectMap, "tags", a.Tags) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type AddressUpdateParameter. -func (a AddressUpdateParameter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "properties", a.Properties) - populate(objectMap, "tags", a.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type BillingMeterDetails. -func (b *BillingMeterDetails) UnmarshalJSON(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 "frequency": - err = unpopulate(val, "Frequency", &b.Frequency) - delete(rawMsg, key) - case "meterDetails": - b.MeterDetails, err = unmarshalMeterDetailsClassification(val) - delete(rawMsg, key) - case "meteringType": - err = unpopulate(val, "MeteringType", &b.MeteringType) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &b.Name) - 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 ConfigurationFilters. -func (c ConfigurationFilters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "filterableProperty", c.FilterableProperty) - populate(objectMap, "hierarchyInformation", c.HierarchyInformation) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ConfigurationsRequest. -func (c ConfigurationsRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "configurationFilters", c.ConfigurationFilters) - populate(objectMap, "customerSubscriptionDetails", c.CustomerSubscriptionDetails) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ContactDetails. -func (c ContactDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "contactName", c.ContactName) - populate(objectMap, "emailList", c.EmailList) - populate(objectMap, "mobile", c.Mobile) - populate(objectMap, "phone", c.Phone) - populate(objectMap, "phoneExtension", c.PhoneExtension) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type CustomerSubscriptionDetails. -func (c CustomerSubscriptionDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "locationPlacementId", c.LocationPlacementID) - populate(objectMap, "quotaId", c.QuotaID) - populate(objectMap, "registeredFeatures", c.RegisteredFeatures) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. -func (e ErrorDetail) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "additionalInfo", e.AdditionalInfo) - populate(objectMap, "code", e.Code) - populate(objectMap, "details", e.Details) - populate(objectMap, "message", e.Message) - populate(objectMap, "target", e.Target) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type FilterableProperty. -func (f FilterableProperty) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "supportedValues", f.SupportedValues) - populate(objectMap, "type", f.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type OrderItemDetails. -func (o OrderItemDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "cancellationReason", o.CancellationReason) - populate(objectMap, "cancellationStatus", o.CancellationStatus) - populate(objectMap, "currentStage", o.CurrentStage) - populate(objectMap, "deletionStatus", o.DeletionStatus) - populate(objectMap, "error", o.Error) - populate(objectMap, "forwardShippingDetails", o.ForwardShippingDetails) - populate(objectMap, "managementRpDetails", o.ManagementRpDetails) - populate(objectMap, "managementRpDetailsList", o.ManagementRpDetailsList) - populate(objectMap, "notificationEmailList", o.NotificationEmailList) - populate(objectMap, "orderItemStageHistory", o.OrderItemStageHistory) - populate(objectMap, "orderItemType", o.OrderItemType) - populate(objectMap, "preferences", o.Preferences) - populate(objectMap, "productDetails", o.ProductDetails) - populate(objectMap, "returnReason", o.ReturnReason) - populate(objectMap, "returnStatus", o.ReturnStatus) - populate(objectMap, "reverseShippingDetails", o.ReverseShippingDetails) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type OrderItemProperties. -func (o OrderItemProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "addressDetails", o.AddressDetails) - populate(objectMap, "orderId", o.OrderID) - populate(objectMap, "orderItemDetails", o.OrderItemDetails) - populateTimeRFC3339(objectMap, "startTime", o.StartTime) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OrderItemProperties. -func (o *OrderItemProperties) UnmarshalJSON(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 "addressDetails": - err = unpopulate(val, "AddressDetails", &o.AddressDetails) - delete(rawMsg, key) - case "orderId": - err = unpopulate(val, "OrderID", &o.OrderID) - delete(rawMsg, key) - case "orderItemDetails": - err = unpopulate(val, "OrderItemDetails", &o.OrderItemDetails) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &o.StartTime) - 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 OrderItemResource. -func (o OrderItemResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", o.ID) - populate(objectMap, "location", o.Location) - populate(objectMap, "name", o.Name) - populate(objectMap, "properties", o.Properties) - 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 OrderItemUpdateParameter. -func (o OrderItemUpdateParameter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "properties", o.Properties) - populate(objectMap, "tags", o.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type OrderItemUpdateProperties. -func (o OrderItemUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "forwardAddress", o.ForwardAddress) - populate(objectMap, "notificationEmailList", o.NotificationEmailList) - populate(objectMap, "preferences", o.Preferences) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type OrderProperties. -func (o OrderProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "currentStage", o.CurrentStage) - populate(objectMap, "orderItemIds", o.OrderItemIDs) - populate(objectMap, "orderStageHistory", o.OrderStageHistory) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Pav2MeterDetails. -func (p *Pav2MeterDetails) UnmarshalJSON(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 "billingType": - err = unpopulate(val, "BillingType", &p.BillingType) - delete(rawMsg, key) - case "chargingType": - err = unpopulate(val, "ChargingType", &p.ChargingType) - delete(rawMsg, key) - case "meterGuid": - err = unpopulate(val, "MeterGUID", &p.MeterGUID) - delete(rawMsg, key) - case "multiplier": - err = unpopulate(val, "Multiplier", &p.Multiplier) - 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 Preferences. -func (p Preferences) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "encryptionPreferences", p.EncryptionPreferences) - populate(objectMap, "managementResourcePreferences", p.ManagementResourcePreferences) - populate(objectMap, "notificationPreferences", p.NotificationPreferences) - populate(objectMap, "transportPreferences", p.TransportPreferences) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ProductDetails. -func (p ProductDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "count", p.Count) - populate(objectMap, "deviceDetails", p.DeviceDetails) - populate(objectMap, "displayInfo", p.DisplayInfo) - populate(objectMap, "hierarchyInformation", p.HierarchyInformation) - populate(objectMap, "productDoubleEncryptionStatus", p.ProductDoubleEncryptionStatus) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ProductFamiliesRequest. -func (p ProductFamiliesRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "customerSubscriptionDetails", p.CustomerSubscriptionDetails) - populate(objectMap, "filterableProperties", p.FilterableProperties) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type PurchaseMeterDetails. -func (p *PurchaseMeterDetails) UnmarshalJSON(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 "billingType": - err = unpopulate(val, "BillingType", &p.BillingType) - delete(rawMsg, key) - case "chargingType": - err = unpopulate(val, "ChargingType", &p.ChargingType) - delete(rawMsg, key) - case "multiplier": - err = unpopulate(val, "Multiplier", &p.Multiplier) - delete(rawMsg, key) - case "productId": - err = unpopulate(val, "ProductID", &p.ProductID) - delete(rawMsg, key) - case "skuId": - err = unpopulate(val, "SKUID", &p.SKUID) - delete(rawMsg, key) - case "termId": - err = unpopulate(val, "TermID", &p.TermID) - 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 StageDetails. -func (s StageDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "displayName", s.DisplayName) - populate(objectMap, "stageName", s.StageName) - populate(objectMap, "stageStatus", s.StageStatus) - populateTimeRFC3339(objectMap, "startTime", s.StartTime) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type StageDetails. -func (s *StageDetails) UnmarshalJSON(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 "displayName": - err = unpopulate(val, "DisplayName", &s.DisplayName) - delete(rawMsg, key) - case "stageName": - err = unpopulate(val, "StageName", &s.StageName) - delete(rawMsg, key) - case "stageStatus": - err = unpopulate(val, "StageStatus", &s.StageStatus) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &s.StartTime) - 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 -}